Skip to content

Commit

Permalink
Add C# to LanguageComposition (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmccarp authored Aug 24, 2024
1 parent 04c95c6 commit 5e402c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies {
implementation("org.openrewrite:rewrite-yaml")
implementation("org.openrewrite:rewrite-python:$latest")
implementation("org.openrewrite:rewrite-kotlin:$latest")
implementation("org.openrewrite:rewrite-csharp:$latest")

testRuntimeOnly("org.openrewrite:rewrite-java-17")
}
13 changes: 13 additions & 0 deletions src/main/java/org/openrewrite/LanguageComposition.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import lombok.Value;
import org.jspecify.annotations.Nullable;
import org.openrewrite.binary.Binary;
import org.openrewrite.csharp.tree.Cs;
import org.openrewrite.groovy.tree.G;
import org.openrewrite.hcl.tree.Hcl;
import org.openrewrite.java.tree.J;
Expand Down Expand Up @@ -317,6 +318,18 @@ public TreeVisitor<?, ExecutionContext> getScanner(Accumulator acc) {
s.getClass().getName(),
genericLineCount,
hasParseFailure));
} else if (s instanceof Cs.CompilationUnit) {
Counts csharpCounts = acc.getFolderToLanguageToCounts()
.computeIfAbsent(folderPath, k -> new HashMap<>())
.computeIfAbsent("C#", k -> new Counts());
csharpCounts.fileCount++;
csharpCounts.lineCount += genericLineCount;
perFileReport.insertRow(ctx, new LanguageCompositionPerFile.Row(
s.getSourcePath().toString(),
"C#",
s.getClass().getName(),
genericLineCount,
hasParseFailure));
} else {
Counts unknownCounts = acc.getFolderToLanguageToCounts()
.computeIfAbsent(folderPath, k -> new HashMap<>())
Expand Down

0 comments on commit 5e402c0

Please sign in to comment.