Skip to content

Commit

Permalink
Merge branch 'develop' into feature/endToEndTests-Rework
Browse files Browse the repository at this point in the history
# Conflicts:
#	core/src/main/java/de/jplag/GreedyStringTiling.java
  • Loading branch information
TwoOfTwelve committed Oct 31, 2023
2 parents 58c62fc + 366e47b commit bbf8e06
Show file tree
Hide file tree
Showing 23 changed files with 1,639 additions and 892 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ jobs:
run: cp -r ./docs/. ./wiki

- name: Deploy 🚀
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
repository: wiki
2 changes: 1 addition & 1 deletion .github/workflows/report-viewer-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Checkout 🛎️
uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: "18"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/report-viewer-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Checkout 🛎️
uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: "18"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/report-viewer-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Checkout 🛎️
uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: "18"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/report-viewer-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Checkout 🛎️
uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: "18"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/report-viewer-prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Checkout 🛎️
uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: "18"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/report-viewer-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Checkout 🛎️
uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: "18"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/report-viewer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Checkout 🛎️
uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: "18"

Expand Down
23 changes: 9 additions & 14 deletions core/src/main/java/de/jplag/GreedyStringTiling.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.jplag;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.List;
Expand All @@ -22,7 +23,6 @@
public class GreedyStringTiling {

private final int minimumMatchLength;
private final int minimumNeighborLength;
private final JPlagOptions options;
private final ConcurrentMap<TokenType, Integer> tokenTypeValues;
private final Map<Submission, Set<Token>> baseCodeMarkings = new IdentityHashMap<>();
Expand All @@ -33,8 +33,8 @@ public class GreedyStringTiling {
public GreedyStringTiling(JPlagOptions options) {
this.options = options;
// Ensures 1 <= neighborLength <= minimumTokenMatch
this.minimumNeighborLength = Math.min(Math.max(options.mergingOptions().minimumNeighborLength(), 1), options.minimumTokenMatch());
this.minimumMatchLength = options.mergingOptions().enabled() ? this.minimumNeighborLength : options.minimumTokenMatch();
int minimumNeighborLength = Math.min(Math.max(options.mergingOptions().minimumNeighborLength(), 1), options.minimumTokenMatch());
this.minimumMatchLength = options.mergingOptions().enabled() ? minimumNeighborLength : options.minimumTokenMatch();
this.tokenTypeValues = new ConcurrentHashMap<>();
this.tokenTypeValues.put(SharedTokenType.FILE_END, 0);
}
Expand Down Expand Up @@ -78,20 +78,15 @@ public final JPlagComparison generateBaseCodeMarking(Submission submission, Subm
public final JPlagComparison compare(Submission firstSubmission, Submission secondSubmission) {
Submission smallerSubmission;
Submission largerSubmission;
if (firstSubmission.getTokenList().size() > secondSubmission.getTokenList().size()) {
smallerSubmission = secondSubmission;
largerSubmission = firstSubmission;
} else if (firstSubmission.getTokenList().size() < secondSubmission.getTokenList().size()) {
Comparator<Submission> submissionComparator = Comparator.comparing((Submission it) -> it.getTokenList().size())
.thenComparing(Submission::getName);

if (submissionComparator.compare(firstSubmission, secondSubmission) <= 0) {
smallerSubmission = firstSubmission;
largerSubmission = secondSubmission;
} else {
if (firstSubmission.getName().compareTo(secondSubmission.getName()) < 0) {
smallerSubmission = firstSubmission;
largerSubmission = secondSubmission;
} else {
smallerSubmission = secondSubmission;
largerSubmission = firstSubmission;
}
smallerSubmission = secondSubmission;
largerSubmission = firstSubmission;
}
return compareInternal(smallerSubmission, largerSubmission);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ public void ignoreLinesByPrefix(String prefix) {
this.ignoreByCondition(line -> line.trim().startsWith(prefix));
}

/**
* Ignores lines that match the given regular expression. Whitespaces to the left and right of the line will be trimmed
* first.
* @param regex The regular expression
*/
public void ignoreLinesByRegex(String regex) {
this.ignoreByCondition(line -> line.trim().matches(regex));
}

public void ignoreLinesByContains(String content) {
this.ignoreByCondition(line -> line.contains(content));
}
Expand Down
5 changes: 5 additions & 0 deletions languages/csharp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
</dependency>
<dependency>
<groupId>de.jplag</groupId>
<artifactId>language-antlr-utils</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>

<build>
Expand Down
19 changes: 3 additions & 16 deletions languages/csharp/src/main/java/de/jplag/csharp/CSharpLanguage.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
package de.jplag.csharp;

import java.io.File;
import java.util.List;
import java.util.Set;

import org.kohsuke.MetaInfServices;

import de.jplag.ParsingException;
import de.jplag.Token;
import de.jplag.antlr.AbstractAntlrLanguage;

/**
* C# language with full support of C# 6 features and below.
* @author Timur Saglam
*/
@MetaInfServices(de.jplag.Language.class)
public class CSharpLanguage implements de.jplag.Language {
public class CSharpLanguage extends AbstractAntlrLanguage {
private static final String NAME = "C# 6 Parser";
private static final String IDENTIFIER = "csharp";
private static final String[] FILE_ENDINGS = new String[] {".cs", ".CS"};
private static final int DEFAULT_MIN_TOKEN_MATCH = 8;

private final CSharpParserAdapter parser;

public CSharpLanguage() {
parser = new CSharpParserAdapter();
super(new CSharpParserAdapter());
}

@Override
Expand All @@ -45,9 +37,4 @@ public String getIdentifier() {
public int minimumTokenMatch() {
return DEFAULT_MIN_TOKEN_MATCH;
}

@Override
public List<Token> parse(Set<File> files) throws ParsingException {
return parser.parse(files);
}
}
Loading

0 comments on commit bbf8e06

Please sign in to comment.