-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into report-viewer/upgr…
…ade-eslint-config
- Loading branch information
Showing
30 changed files
with
546 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
languages/java/src/test/resources/de/jplag/java/tokenPositions/Anno_1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
>@SuppressWarnings | ||
$| J_ANNO 17 | ||
>class Anno {} |
3 changes: 3 additions & 0 deletions
3
languages/java/src/test/resources/de/jplag/java/tokenPositions/Anno_2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
>@SuppressWarnings("SomeWarning") | ||
$| J_ANNO 17 | ||
>class Anno {} |
6 changes: 6 additions & 0 deletions
6
languages/java/src/test/resources/de/jplag/java/tokenPositions/Anno_3.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
>class Anno { | ||
> @Deprecated | ||
$ | J_ANNO 11 | ||
> public void testFunction() { | ||
> } | ||
>} |
7 changes: 7 additions & 0 deletions
7
languages/java/src/test/resources/de/jplag/java/tokenPositions/Anno_4.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
>import javax.annotation.processing.Generated; | ||
> | ||
>class Anno { | ||
> public void testMethod(@Generated String param) { | ||
$ | J_ANNO 10 | ||
> } | ||
>} |
3 changes: 3 additions & 0 deletions
3
languages/java/src/test/resources/de/jplag/java/tokenPositions/JAnnoTBegin-End_1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
>public @interface MyAnnotation {} | ||
$ | J_ANNO_T_BEGIN 23 | ||
$ | J_ANNO_T_END 1 |
4 changes: 4 additions & 0 deletions
4
languages/java/src/test/resources/de/jplag/java/tokenPositions/JAnnoTBegin-End_2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
>public @interface MyAnnotation { | ||
$ | J_ANNO_T_BEGIN 23 | ||
>} | ||
$| J_ANNO_T_END 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>de.jplag</groupId> | ||
<artifactId>languages</artifactId> | ||
<version>${revision}</version> | ||
</parent> | ||
<artifactId>multi-language</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>de.jplag</groupId> | ||
<artifactId>java</artifactId> | ||
<version>${revision}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>de.jplag</groupId> | ||
<artifactId>cpp</artifactId> | ||
<version>${revision}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
55 changes: 55 additions & 0 deletions
55
languages/multi-language/src/main/java/de/jplag/multilang/MultiLanguage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package de.jplag.multilang; | ||
|
||
import java.io.File; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import org.kohsuke.MetaInfServices; | ||
|
||
import de.jplag.Language; | ||
import de.jplag.LanguageLoader; | ||
import de.jplag.ParsingException; | ||
import de.jplag.Token; | ||
import de.jplag.options.LanguageOptions; | ||
|
||
@MetaInfServices(Language.class) | ||
public class MultiLanguage implements Language { | ||
private final MultiLanguageOptions options; | ||
|
||
public MultiLanguage() { | ||
this.options = new MultiLanguageOptions(); | ||
} | ||
|
||
@Override | ||
public String[] suffixes() { | ||
return LanguageLoader.getAllAvailableLanguages().values().stream().filter(it -> it != this).flatMap(it -> Arrays.stream(it.suffixes())) | ||
.toArray(String[]::new); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "multi-language"; | ||
} | ||
|
||
@Override | ||
public String getIdentifier() { | ||
return "multi"; | ||
} | ||
|
||
@Override | ||
public int minimumTokenMatch() { | ||
return this.options.getLanguages().stream().mapToInt(Language::minimumTokenMatch).min().orElse(9); | ||
} | ||
|
||
@Override | ||
public List<Token> parse(Set<File> files, boolean normalize) throws ParsingException { | ||
MultiLanguageParser parser = new MultiLanguageParser(this.options); | ||
return parser.parseFiles(files, normalize); | ||
} | ||
|
||
@Override | ||
public LanguageOptions getOptions() { | ||
return this.options; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
languages/multi-language/src/main/java/de/jplag/multilang/MultiLanguageOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package de.jplag.multilang; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import de.jplag.Language; | ||
import de.jplag.LanguageLoader; | ||
import de.jplag.options.LanguageOption; | ||
import de.jplag.options.LanguageOptions; | ||
import de.jplag.options.OptionType; | ||
|
||
public class MultiLanguageOptions extends LanguageOptions { | ||
private static final String ERROR_LANGUAGE_NOT_FOUND = "The selected language %s could not be found"; | ||
private static final String ERROR_NOT_ENOUGH_LANGUAGES = "To use multi language specify at least 1 language"; | ||
private static final String OPTION_DESCRIPTION_LANGUAGES = "The languages that should be used. This is a ',' separated list"; | ||
|
||
private final LanguageOption<String> languageNames = createOption(OptionType.string(), "languages", OPTION_DESCRIPTION_LANGUAGES); | ||
private List<Language> languages = null; | ||
|
||
public List<Language> getLanguages() { | ||
if (this.languages == null) { | ||
if (languageNames.getValue() == null) { | ||
throw new IllegalArgumentException(ERROR_NOT_ENOUGH_LANGUAGES); | ||
} | ||
|
||
this.languages = Arrays.stream(languageNames.getValue().split(",")) | ||
.map(name -> LanguageLoader.getLanguage(name) | ||
.orElseThrow(() -> new IllegalArgumentException(String.format(ERROR_LANGUAGE_NOT_FOUND, name)))) | ||
.filter(language -> !language.getClass().equals(MultiLanguage.class)).toList(); | ||
|
||
if (this.languages.isEmpty()) { | ||
throw new IllegalArgumentException(ERROR_NOT_ENOUGH_LANGUAGES); | ||
} | ||
} | ||
|
||
return this.languages; | ||
} | ||
|
||
public LanguageOption<String> getLanguageNames() { | ||
return this.languageNames; | ||
} | ||
} |
Oops, something went wrong.