use of com.github.javaparser.ast.type.VarType in project javaparser by javaparser.
the class VarTypeTest method resolveAReferenceType.
@Test
public void resolveAReferenceType() {
CompilationUnit ast = javaParser.parse(ParseStart.COMPILATION_UNIT, provider("class X{void x(){var abc = \"\";}}")).getResult().get();
VarType varType = ast.findFirst(VarType.class).get();
ResolvedType resolvedType = varType.resolve();
assertEquals(new ReferenceTypeImpl(new ReflectionClassDeclaration(String.class, typeSolver), typeSolver), resolvedType);
}
use of com.github.javaparser.ast.type.VarType in project javaparser by javaparser.
the class VarTypeTest method failResolveNoInitializer.
@Test(expected = IllegalStateException.class)
public void failResolveNoInitializer() {
CompilationUnit ast = javaParser.parse(ParseStart.COMPILATION_UNIT, provider("class X{void x(){var abc;}}")).getResult().get();
VarType varType = ast.findFirst(VarType.class).get();
varType.resolve();
}
use of com.github.javaparser.ast.type.VarType in project javaparser by javaparser.
the class VarTypeTest method failResolveWrongLocation.
@Test(expected = IllegalStateException.class)
public void failResolveWrongLocation() {
CompilationUnit ast = javaParser.parse(ParseStart.COMPILATION_UNIT, provider("class X{void x(var x){};}")).getResult().get();
VarType varType = ast.findFirst(VarType.class).get();
varType.resolve();
}
use of com.github.javaparser.ast.type.VarType in project javaparser by javaparser.
the class VarTypeTest method resolveAPrimitive.
@Test
public void resolveAPrimitive() {
CompilationUnit ast = javaParser.parse(ParseStart.COMPILATION_UNIT, provider("class X{void x(){var abc = 1;}}")).getResult().get();
VarType varType = ast.findFirst(VarType.class).get();
ResolvedType resolvedType = varType.resolve();
assertEquals(ResolvedPrimitiveType.INT, resolvedType);
}
Aggregations