This repository has been archived by the owner on Apr 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b17cb8
commit 91533c2
Showing
11 changed files
with
105 additions
and
100 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package dev.dart.pkg2; | ||
|
||
public class C2 { | ||
public static int CONSTANT = 12; | ||
public static int CONSTANT = 12; | ||
} |
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
9 changes: 4 additions & 5 deletions
9
...ummarizer/src/main/java/com/github/hegde/mahesh/apisummarizer/disasm/AsmClassVisitor.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
11 changes: 5 additions & 6 deletions
11
...y/ApiSummarizer/src/main/java/com/github/hegde/mahesh/apisummarizer/disasm/TypeUtils.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
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
89 changes: 44 additions & 45 deletions
89
...Summarizer/src/test/java/com/github/hegde/mahesh/apisummarizer/DocletSummarizerTests.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 |
---|---|---|
@@ -1,57 +1,56 @@ | ||
package com.github.hegde.mahesh.apisummarizer; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import com.github.hegde.mahesh.apisummarizer.doclet.SummarizerDoclet; | ||
import com.github.hegde.mahesh.apisummarizer.elements.ClassDecl; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class DocletSummarizerTests { | ||
private List<ClassDecl> parsedDecls; | ||
private final Map<String, ClassDecl> classesByName = new HashMap<>(); | ||
|
||
@Before | ||
public void setUp() { | ||
var opts = new Main.SummarizerOptions(); | ||
opts.sourcePaths = "src/test/resources/"; | ||
// javadoc tool API is quite inflexible, in that we cannot pass an doclet object, but a class | ||
// So any state we want to access from it has to be either serialized or saved in static fields. | ||
// This means we lose lot of control over loading of files etc.. | ||
// Here, TestDoclet simply stores the result in a static variable which we can get and check later. | ||
Main.runDocletWithClass(SummarizerDoclet.TestDoclet.class, List.of("com.example.Example"), opts); | ||
parsedDecls = SummarizerDoclet.TestDoclet.getClassDecls(); | ||
for (var decl : parsedDecls) { | ||
classesByName.put(decl.binaryName, decl); | ||
} | ||
} | ||
|
||
@Test | ||
public void checkNumberOfClasses() { | ||
Assert.assertEquals(2, parsedDecls.size()); | ||
} | ||
|
||
@Test | ||
public void checkNamesOfClasses() { | ||
var names = parsedDecls.stream() | ||
.map(decl -> decl.binaryName) | ||
.collect(Collectors.toSet()); | ||
assertTrue(names.contains("com.example.Example")); | ||
assertTrue(names.contains("com.example.Example$Aux")); | ||
} | ||
|
||
@Test | ||
public void checkNumberOfFieldsAndMethods() { | ||
var example = classesByName.get("com.example.Example"); | ||
assertEquals("Example", example.simpleName); | ||
assertEquals(3, example.fields.size()); | ||
assertEquals(3, example.methods.size()); | ||
private List<ClassDecl> parsedDecls; | ||
private final Map<String, ClassDecl> classesByName = new HashMap<>(); | ||
|
||
@Before | ||
public void setUp() { | ||
var opts = new Main.SummarizerOptions(); | ||
opts.sourcePaths = "src/test/resources/"; | ||
// javadoc tool API is quite inflexible, in that we cannot pass an doclet object, but a class | ||
// So any state we want to access from it has to be either serialized or saved in static fields. | ||
// This means we lose lot of control over loading of files etc.. | ||
// Here, TestDoclet simply stores the result in a static variable which we can get and check | ||
// later. | ||
Main.runDocletWithClass( | ||
SummarizerDoclet.TestDoclet.class, List.of("com.example.Example"), opts); | ||
parsedDecls = SummarizerDoclet.TestDoclet.getClassDecls(); | ||
for (var decl : parsedDecls) { | ||
classesByName.put(decl.binaryName, decl); | ||
} | ||
} | ||
|
||
@Test | ||
public void checkNumberOfClasses() { | ||
Assert.assertEquals(2, parsedDecls.size()); | ||
} | ||
|
||
@Test | ||
public void checkNamesOfClasses() { | ||
var names = parsedDecls.stream().map(decl -> decl.binaryName).collect(Collectors.toSet()); | ||
assertTrue(names.contains("com.example.Example")); | ||
assertTrue(names.contains("com.example.Example$Aux")); | ||
} | ||
|
||
@Test | ||
public void checkNumberOfFieldsAndMethods() { | ||
var example = classesByName.get("com.example.Example"); | ||
assertEquals("Example", example.simpleName); | ||
assertEquals(3, example.fields.size()); | ||
assertEquals(3, example.methods.size()); | ||
} | ||
} |
37 changes: 20 additions & 17 deletions
37
jni_gen/third_party/ApiSummarizer/src/test/resources/com/example/Example.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 |
---|---|---|
@@ -1,26 +1,29 @@ | ||
package com.example; | ||
|
||
public class Example { | ||
static final boolean staticFinalField = true; | ||
static final boolean staticFinalField = true; | ||
|
||
Example(int instanceField) { | ||
this.instanceField = instanceField; | ||
} | ||
Example(int instanceField) { | ||
this.instanceField = instanceField; | ||
} | ||
|
||
static String staticField = "hello"; | ||
static String getStaticField() { | ||
return staticField; | ||
} | ||
static String staticField = "hello"; | ||
|
||
int instanceField; | ||
int getInstanceField() { | ||
return instanceField; | ||
} | ||
static String getStaticField() { | ||
return staticField; | ||
} | ||
|
||
int instanceField; | ||
|
||
int getInstanceField() { | ||
return instanceField; | ||
} | ||
|
||
public static class Aux extends Example { | ||
static int nothing = 0; | ||
|
||
public static class Aux extends Example { | ||
static int nothing = 0; | ||
static Example getAnExample() { | ||
return new Example(); | ||
} | ||
static Example getAnExample() { | ||
return new Example(); | ||
} | ||
} | ||
} |