Skip to content

Commit

Permalink
Merge pull request #1330 from jplag/feature/rewrite-csharp-tests
Browse files Browse the repository at this point in the history
Feature/rewrite csharp module
  • Loading branch information
tsaglam authored Oct 30, 2023
2 parents e5a4e76 + 9b55f4c commit 5183486
Show file tree
Hide file tree
Showing 10 changed files with 1,301 additions and 565 deletions.
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 5183486

Please sign in to comment.