Added new directory for LCA_JP3_27_0 with working files
This commit is contained in:
@@ -1,22 +0,0 @@
|
|||||||
import com.github.javaparser.JavaParser;
|
|
||||||
import com.github.javaparser.ParserConfiguration;
|
|
||||||
import com.github.javaparser.ParserConfiguration.LanguageLevel;
|
|
||||||
import com.github.javaparser.ast.CompilationUnit;
|
|
||||||
|
|
||||||
public class LCA_JP3_27_0 {
|
|
||||||
public static void main(String[] args) throws Exception{
|
|
||||||
if (args.length == 0) {
|
|
||||||
System.out.println("Usage: java LCA_JP3_27_0 <JavaSourceFile>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ParserConfiguration config = new ParserConfiguration()
|
|
||||||
.setLanguageLevel(LanguageLevel.JAVA_9);
|
|
||||||
|
|
||||||
JavaParser parser = new JavaParser(config);
|
|
||||||
|
|
||||||
String code = "module x {}";
|
|
||||||
parser.parse(code).getResult().ifPresent(System.out::println);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,52 @@
|
|||||||
|
import com.github.javaparser.JavaParser;
|
||||||
|
import com.github.javaparser.ParserConfiguration;
|
||||||
|
import com.github.javaparser.ast.CompilationUnit;
|
||||||
|
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
|
||||||
|
import com.github.javaparser.ast.body.MethodDeclaration;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitorAdapter;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ParserConfiguration.LanguageLevel.JAVA_8;
|
||||||
|
|
||||||
|
public class LCA_JP3_27_0 {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
if (args.length == 0) {
|
||||||
|
System.out.println("Usage: java LCA_JP3_27_0 <JavaSourceFile>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configure parser for Java 8
|
||||||
|
ParserConfiguration config = new ParserConfiguration();
|
||||||
|
config.setLanguageLevel(JAVA_8);
|
||||||
|
JavaParser parser = new JavaParser(config);
|
||||||
|
|
||||||
|
// Parse the file
|
||||||
|
FileInputStream in = new FileInputStream(new File(args[0]));
|
||||||
|
CompilationUnit cu = parser.parse(in).getResult().get();
|
||||||
|
in.close();
|
||||||
|
|
||||||
|
// Visit and find local classes
|
||||||
|
LocalClassVisitor visitor = new LocalClassVisitor();
|
||||||
|
visitor.visit(cu, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
static class LocalClassVisitor extends VoidVisitorAdapter<Void> {
|
||||||
|
private boolean insideMethod = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visit(MethodDeclaration n, Void arg) {
|
||||||
|
insideMethod = true;
|
||||||
|
super.visit(n, arg);
|
||||||
|
insideMethod = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visit(ClassOrInterfaceDeclaration n, Void arg) {
|
||||||
|
System.out.println("Local class: " + n.getNameAsString());
|
||||||
|
super.visit(n, arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -0,0 +1,17 @@
|
|||||||
|
public class test {
|
||||||
|
void methodOne() {
|
||||||
|
public class Helper234 {
|
||||||
|
void doStuff() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private class Helper2 {
|
||||||
|
void doStuff() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void methodTwo() {
|
||||||
|
System.out.println("Hello");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user