use of com.github.javaparser.ast.ImportDeclaration in project javaparser by javaparser.
the class SourceFileInfoExtractor method solve.
private void solve(Node node) {
if (node instanceof ClassOrInterfaceDeclaration) {
solveTypeDecl((ClassOrInterfaceDeclaration) node);
} else if (node instanceof Expression) {
if ((requireParentNode(node) instanceof ImportDeclaration) || (requireParentNode(node) instanceof Expression) || (requireParentNode(node) instanceof MethodDeclaration) || (requireParentNode(node) instanceof PackageDeclaration)) {
// skip
} else if ((requireParentNode(node) instanceof Statement) || (requireParentNode(node) instanceof VariableDeclarator)) {
try {
ResolvedType ref = JavaParserFacade.get(typeSolver).getType(node);
out.println(" Line " + node.getRange().get().begin.line + ") " + node + " ==> " + ref.describe());
ok++;
} catch (UnsupportedOperationException upe) {
unsupported++;
err.println(upe.getMessage());
throw upe;
} catch (RuntimeException re) {
ko++;
err.println(re.getMessage());
throw re;
}
}
}
}
use of com.github.javaparser.ast.ImportDeclaration in project javaparser by javaparser.
the class ImportDeclarationTest method singleTypeImportDeclaration.
@Test
public void singleTypeImportDeclaration() {
ImportDeclaration i = JavaParser.parseImport("import a.b.c.X;");
assertEquals("a.b.c.X", i.getNameAsString());
}
use of com.github.javaparser.ast.ImportDeclaration in project javaparser by javaparser.
the class ImportDeclarationTest method staticImportOnDemandDeclaration.
@Test
public void staticImportOnDemandDeclaration() {
ImportDeclaration i = JavaParser.parseImport("import static a.b.c.X.*;");
assertEquals("a.b.c.X", i.getNameAsString());
}
use of com.github.javaparser.ast.ImportDeclaration in project javaparser by javaparser.
the class ImportDeclarationTest method typeImportOnDemandDeclaration.
@Test
public void typeImportOnDemandDeclaration() {
ImportDeclaration i = JavaParser.parseImport("import a.b.c.D.*;");
assertEquals("a.b.c.D", i.getName().toString());
assertEquals("D", i.getName().getIdentifier());
}
use of com.github.javaparser.ast.ImportDeclaration in project javaparser by javaparser.
the class ImportDeclarationTest method singleStaticImportDeclaration.
@Test
public void singleStaticImportDeclaration() {
ImportDeclaration i = JavaParser.parseImport("import static a.b.c.X.def;");
assertEquals("a.b.c.X", i.getName().getQualifier().get().asString());
assertEquals("def", i.getName().getIdentifier());
}
Aggregations