下面列出了javax.lang.model.element.QualifiedNameable#com.sun.source.util.Trees 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static void main(String[] args) throws IOException {
JavaFileObject sfo = new SimpleJavaFileObject(URI.create("myfo:/Test.java"),Kind.SOURCE) {
public CharSequence getCharContent(boolean ignoreEncodingErrors) {
return "class BadName { Object o = j; }";
}
};
List<? extends JavaFileObject> files = Arrays.asList(sfo);
JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
JavacTask ct = (JavacTask)tool.getTask(null, null, null, null, null, files);
Iterable<? extends CompilationUnitTree> compUnits = ct.parse();
CompilationUnitTree cu = compUnits.iterator().next();
ClassTree cdef = (ClassTree)cu.getTypeDecls().get(0);
JCVariableDecl vdef = (JCVariableDecl)cdef.getMembers().get(0);
TreePath path = TreePath.getPath(cu, vdef.init);
Trees.instance(ct).getScope(path);
}
@Test
void testPositionForEnumModifiers() throws IOException {
final String theString = "public";
String code = "package test; " + theString + " enum Test {A;}";
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, fm, null, null,
null, Arrays.asList(new MyFileObject(code)));
CompilationUnitTree cut = ct.parse().iterator().next();
SourcePositions pos = Trees.instance(ct).getSourcePositions();
ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
ModifiersTree mt = clazz.getModifiers();
int spos = code.indexOf(theString);
int epos = spos + theString.length();
assertEquals("testPositionForEnumModifiers",
spos, pos.getStartPosition(cut, mt));
assertEquals("testPositionForEnumModifiers",
epos, pos.getEndPosition(cut, mt));
}
private void addPackageContent(PackageElement pe, EnumSet<ElementKind> kinds, DeclaredType baseType, Set<? extends Element> toExclude, String prefix, int substitutionOffset, JavadocContext jdctx) {
CompilationInfo controller = jdctx.javac;
Element srcEl = jdctx.handle.resolve(controller);
Elements elements = controller.getElements();
Types types = controller.getTypes();
Trees trees = controller.getTrees();
TreeUtilities tu = controller.getTreeUtilities();
ElementUtilities eu = controller.getElementUtilities();
TreePath docpath = srcEl != null ? trees.getPath(srcEl) : null;
Scope scope = docpath != null ? trees.getScope(docpath) : tu.scopeFor(caretOffset);
for(Element e : pe.getEnclosedElements()) {
if ((e.getKind().isClass() || e.getKind().isInterface()) && (toExclude == null || !toExclude.contains(e))) {
String name = e.getSimpleName().toString();
if (Utilities.startsWith(name, prefix) && (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(e))
&& trees.isAccessible(scope, (TypeElement)e)
&& isOfKindAndType(e.asType(), e, kinds, baseType, scope, trees, types)
&& !Utilities.isExcluded(eu.getElementName(e, true))) {
items.add(JavadocCompletionItem.createTypeItem(jdctx.javac, (TypeElement) e, substitutionOffset, null, elements.isDeprecated(e)/*, isOfSmartType(env, e.asType(), smartTypes)*/));
}
}
}
}
@Test
void testPositionForEnumModifiers() throws IOException {
final String theString = "public";
String code = "package test; " + theString + " enum Test {A;}";
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
null, Arrays.asList(new MyFileObject(code)));
CompilationUnitTree cut = ct.parse().iterator().next();
SourcePositions pos = Trees.instance(ct).getSourcePositions();
ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
ModifiersTree mt = clazz.getModifiers();
int spos = code.indexOf(theString);
int epos = spos + theString.length();
assertEquals("testPositionForEnumModifiers",
spos, pos.getStartPosition(cut, mt));
assertEquals("testPositionForEnumModifiers",
epos, pos.getEndPosition(cut, mt));
}
@Nullable
private ClassTree findEnclosingLocalOrAnonymousClass(ClassTree classTree) {
Symbol.ClassSymbol symbol = ASTHelpers.getSymbol(classTree);
// we need this while loop since we can have a NestingKind.NESTED class (i.e., a nested
// class declared at the top-level within its enclosing class) nested (possibly deeply)
// within a NestingKind.ANONYMOUS or NestingKind.LOCAL class
while (symbol.getNestingKind().isNested()) {
if (symbol.getNestingKind().equals(NestingKind.ANONYMOUS)
|| symbol.getNestingKind().equals(NestingKind.LOCAL)) {
return Trees.instance(JavacProcessingEnvironment.instance(context)).getTree(symbol);
} else {
// symbol.owner is the enclosing element, which could be a class or a method.
// if it's a class, the enclClass() method will (surprisingly) return the class itself,
// so this works
symbol = symbol.owner.enclClass();
}
}
return null;
}
/** {@inheritDoc} */
@Override public void init(ProcessingEnvironment procEnv) {
super.init(procEnv);
if (System.getProperty("lombok.disable") != null) {
lombokDisabled = true;
return;
}
this.processingEnv = (JavacProcessingEnvironment) procEnv;
placePostCompileAndDontMakeForceRoundDummiesHook();
transformer = new JavacTransformer(procEnv.getMessager());
trees = Trees.instance(procEnv);
SortedSet<Long> p = transformer.getPriorities();
if (p.isEmpty()) {
this.priorityLevels = new long[] {0L};
this.priorityLevelsRequiringResolutionReset = new HashSet<Long>();
} else {
this.priorityLevels = new long[p.size()];
int i = 0;
for (Long prio : p) this.priorityLevels[i++] = prio;
this.priorityLevelsRequiringResolutionReset = transformer.getPrioritiesRequiringResolutionReset();
}
}
@Test
void testNewClassWithEnclosing() throws IOException {
final String theString = "Test.this.new d()";
String code = "package test; class Test { " +
"class d {} private void method() { " +
"Object o = " + theString + "; } }";
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
null, Arrays.asList(new MyFileObject(code)));
CompilationUnitTree cut = ct.parse().iterator().next();
SourcePositions pos = Trees.instance(ct).getSourcePositions();
ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
ExpressionTree est =
((VariableTree) ((MethodTree) clazz.getMembers().get(1)).getBody().getStatements().get(0)).getInitializer();
final int spos = code.indexOf(theString);
final int epos = spos + theString.length();
assertEquals("testNewClassWithEnclosing",
spos, pos.getStartPosition(cut, est));
assertEquals("testNewClassWithEnclosing",
epos, pos.getEndPosition(cut, est));
}
public static void main(String[] args) throws IOException {
JavaFileObject sfo = new SimpleJavaFileObject(URI.create("myfo:/Test.java"),Kind.SOURCE) {
public CharSequence getCharContent(boolean ignoreEncodingErrors) {
return "class BadName { Object o = j; }";
}
};
List<? extends JavaFileObject> files = Arrays.asList(sfo);
JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
JavacTask ct = (JavacTask)tool.getTask(null, null, null, null, null, files);
Iterable<? extends CompilationUnitTree> compUnits = ct.parse();
CompilationUnitTree cu = compUnits.iterator().next();
ClassTree cdef = (ClassTree)cu.getTypeDecls().get(0);
JCVariableDecl vdef = (JCVariableDecl)cdef.getMembers().get(0);
TreePath path = TreePath.getPath(cu, vdef.init);
Trees.instance(ct).getScope(path);
}
private Location getLocation(final String name, final TreePath treePath) {
return new Location() {
public String toString() {
if (treePath == null)
return name + " (Unknown Source)";
// just like stack trace, we just print the file name and
// not the whole path. The idea is that the package name should
// provide enough clue on which directory it lives.
CompilationUnitTree compilationUnit = treePath.getCompilationUnit();
Trees trees = Trees.instance(env);
long startPosition = trees.getSourcePositions().getStartPosition(compilationUnit, treePath.getLeaf());
return name + "(" +
compilationUnit.getSourceFile().getName() + ":" + compilationUnit.getLineMap().getLineNumber(startPosition) +
")";
}
};
}
@Override
public Tree visitCompilationUnit(CompilationUnitTree node, Element p) {
this.referencedPrivateElement = new HashSet<Element>();
Tree result = super.visitCompilationUnit(node, p);
for (Element privEl : this.referencedPrivateElement) {
problem = MoveTransformer.createProblem(problem, false, NbBundle.getMessage(InnerToOuterRefactoringPlugin.class, "WRN_InnerToOuterRefToPrivate", privEl));
}
Trees trees = workingCopy.getTrees();
CompilationUnitTree newNode = node;
for (ImportTree imp : node.getImports()) {
if(imp.isStatic()) {
Tree qualIdent = imp.getQualifiedIdentifier();
TypeElement el = workingCopy.getElements().getTypeElement(qualIdent.toString());
if(inner.equals(el)) {
newNode = make.removeCompUnitImport(newNode, imp);
}
}
}
if(newNode != node) {
rewrite(node, newNode);
}
return result;
}
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
new TestPathScanner<Void>() {
@Override
public void visit(Void t) {
}
};
TypeElement currentClass = elements.getTypeElement("TypesCachesCleared");
Trees trees = Trees.instance(processingEnv);
TreePath path = trees.getPath(currentClass);
new TreePathScanner<Void, Void>() {
@Override public Void visitClass(ClassTree node, Void p) {
trees.getElement(getCurrentPath());
return super.visitClass(node, p);
}
}.scan(path, null);
return false;
}
@Test
void testPositionForEnumModifiers() throws IOException {
final String theString = "public";
String code = "package test; " + theString + " enum Test {A;}";
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
null, Arrays.asList(new MyFileObject(code)));
CompilationUnitTree cut = ct.parse().iterator().next();
SourcePositions pos = Trees.instance(ct).getSourcePositions();
ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
ModifiersTree mt = clazz.getModifiers();
int spos = code.indexOf(theString);
int epos = spos + theString.length();
assertEquals("testPositionForEnumModifiers",
spos, pos.getStartPosition(cut, mt));
assertEquals("testPositionForEnumModifiers",
epos, pos.getEndPosition(cut, mt));
}
@Test
void testNewClassWithEnclosing() throws IOException {
final String theString = "Test.this.new d()";
String code = "package test; class Test { " +
"class d {} private void method() { " +
"Object o = " + theString + "; } }";
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
null, Arrays.asList(new MyFileObject(code)));
CompilationUnitTree cut = ct.parse().iterator().next();
SourcePositions pos = Trees.instance(ct).getSourcePositions();
ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
ExpressionTree est =
((VariableTree) ((MethodTree) clazz.getMembers().get(1)).getBody().getStatements().get(0)).getInitializer();
final int spos = code.indexOf(theString);
final int epos = spos + theString.length();
assertEquals("testNewClassWithEnclosing",
spos, pos.getStartPosition(cut, est));
assertEquals("testNewClassWithEnclosing",
epos, pos.getEndPosition(cut, est));
}
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
Trees trees = Trees.instance(processingEnv);
if (round++ == 0) {
for (Element e: roundEnv.getRootElements()) {
TreePath p = trees.getPath(e);
new Scanner().scan(p, trees);
}
}
return false;
}
public static void main(String... args) throws IOException {
class MyFileObject extends SimpleJavaFileObject {
MyFileObject() {
super(URI.create("myfo:///Test.java"), SOURCE);
}
@Override
public String getCharContent(boolean ignoreEncodingErrors) {
// 0 1 2 3
// 01234567890123456 7890 123456789012345
return "@SuppressWarning(\"foo\") @Deprecated class Test { Test() { } }";
}
}
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
List<JavaFileObject> compilationUnits =
Collections.<JavaFileObject>singletonList(new MyFileObject());
JavacTask task = (JavacTask)javac.getTask(null, null, null, null, null, compilationUnits);
Trees trees = Trees.instance(task);
CompilationUnitTree toplevel = task.parse().iterator().next();
ClassTree classTree = (ClassTree)toplevel.getTypeDecls().get(0);
List<? extends Tree> annotations = classTree.getModifiers().getAnnotations();
Tree tree1 = annotations.get(0);
Tree tree2 = annotations.get(1);
long pos = trees.getSourcePositions().getStartPosition(toplevel, tree1);
if (pos != 0)
throw new AssertionError(String.format("Start pos for %s is incorrect (%s)!",
tree1, pos));
pos = trees.getSourcePositions().getEndPosition(toplevel, tree1);
if (pos != 23)
throw new AssertionError(String.format("End pos for %s is incorrect (%s)!",
tree1, pos));
pos = trees.getSourcePositions().getStartPosition(toplevel, tree2);
if (pos != 24)
throw new AssertionError(String.format("Start pos for %s is incorrect (%s)!",
tree2, pos));
pos = trees.getSourcePositions().getEndPosition(toplevel, tree2);
if (pos != 35)
throw new AssertionError(String.format("End pos for %s is incorrect (%s)!",
tree2, pos));
}
@Override public Void visitCompilationUnit(CompilationUnitTree tree, JavacTask task) {
cu = tree;
Trees trees = Trees.instance(task);
sourcePositions = trees.getSourcePositions();
try {
source = String.valueOf(tree.getSourceFile().getCharContent(true));
} catch (IOException e) {
throw new Error(e);
}
return super.visitCompilationUnit(tree, task);
}
@Test
void testPositionAnnotationNoPackage187551() throws IOException {
String code = "\[email protected] Test {}";
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
null, Arrays.asList(new MyFileObject(code)));
CompilationUnitTree cut = ct.parse().iterator().next();
ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
Trees t = Trees.instance(ct);
assertEquals("testPositionAnnotationNoPackage187551",
1, t.getSourcePositions().getStartPosition(cut, clazz));
}
private void addInitializedFieldsForBlock(
VisitorState state,
Trees trees,
Symbol.ClassSymbol classSymbol,
ImmutableSet.Builder<Element> initInSomeInitializerBuilder,
BlockTree block,
TreePath path) {
AccessPathNullnessAnalysis nullnessAnalysis = getNullnessAnalysis(state);
Set<Element> nonnullAtExit =
nullnessAnalysis.getNonnullFieldsOfReceiverAtExit(path, state.context);
initInSomeInitializerBuilder.addAll(nonnullAtExit);
Set<Element> safeInitMethods = getSafeInitMethods(block, classSymbol, state);
addGuaranteedNonNullFromInvokes(
state, trees, safeInitMethods, nullnessAnalysis, initInSomeInitializerBuilder);
}
@Override public Void visitCompilationUnit(CompilationUnitTree tree, JavacTask task) {
cu = tree;
Trees trees = Trees.instance(task);
sourcePositions = trees.getSourcePositions();
try {
source = String.valueOf(tree.getSourceFile().getCharContent(true));
} catch (IOException e) {
throw new Error(e);
}
return super.visitCompilationUnit(tree, task);
}
/**
* @param entities relevant entities from class
* @param notInitializedInConstructors those fields not initialized in some constructor
* @param state visitor state
* @return those fields from notInitializedInConstructors that are not initialized in any
* initializer method
*/
private Set<Symbol> notAssignedInAnyInitializer(
FieldInitEntities entities, Set<Symbol> notInitializedInConstructors, VisitorState state) {
Trees trees = getTreesInstance(state);
Symbol.ClassSymbol classSymbol = entities.classSymbol();
ImmutableSet.Builder<Element> initInSomeInitializerBuilder = ImmutableSet.builder();
for (MethodTree initMethodTree : entities.instanceInitializerMethods()) {
if (initMethodTree.getBody() == null) {
continue;
}
addInitializedFieldsForBlock(
state,
trees,
classSymbol,
initInSomeInitializerBuilder,
initMethodTree.getBody(),
new TreePath(state.getPath(), initMethodTree));
}
for (BlockTree block : entities.instanceInitializerBlocks()) {
addInitializedFieldsForBlock(
state,
trees,
classSymbol,
initInSomeInitializerBuilder,
block,
new TreePath(state.getPath(), block));
}
Set<Symbol> result = new LinkedHashSet<>();
ImmutableSet<Element> initInSomeInitializer = initInSomeInitializerBuilder.build();
for (Symbol fieldSymbol : notInitializedInConstructors) {
if (!initInSomeInitializer.contains(fieldSymbol)) {
result.add(fieldSymbol);
}
}
return result;
}
public static void main(String... args) throws IOException {
class MyFileObject extends SimpleJavaFileObject {
MyFileObject() {
super(URI.create("myfo:///Test.java"), SOURCE);
}
@Override
public String getCharContent(boolean ignoreEncodingErrors) {
// 0 1 2
// 0123456789012345678901234
return "class Test { Test() { } }";
}
}
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
List<JavaFileObject> compilationUnits =
Collections.<JavaFileObject>singletonList(new MyFileObject());
JavacTask task = (JavacTask)javac.getTask(null, null, null, null, null,
compilationUnits);
Trees trees = Trees.instance(task);
CompilationUnitTree toplevel = task.parse().iterator().next();
Tree tree = ((ClassTree)toplevel.getTypeDecls().get(0)).getMembers().get(0);
long pos = trees.getSourcePositions().getStartPosition(toplevel, tree);
if (pos != 13)
throw new AssertionError(String.format("Start pos for %s is incorrect (%s)!",
tree, pos));
pos = trees.getSourcePositions().getEndPosition(toplevel, tree);
if (pos != 23)
throw new AssertionError(String.format("End pos for %s is incorrect (%s)!",
tree, pos));
}
public DeptectiveTreeVisitor(JavacTask task, Log log, PackageReferenceHandler packageReferenceHandler) {
elements = task.getElements();
types = task.getTypes();
trees = Trees.instance(task);
this.log = log;
this.packageReferenceHandler = packageReferenceHandler;
}
public void init(JavacTask task, String... args) {
BasicJavacTask impl = (BasicJavacTask)task;
Context context = impl.getContext();
log = Log.instance(context);
trees = Trees.instance(task);
messages = new Messages();
task.addTaskListener(new PostAnalyzeTaskListener());
}
public void openTestsuite(TestsuiteNode node) {
Children childrens = node.getChildren();
if (childrens != null) {
Node child = childrens.getNodeAt(0);
if ((child != null) && (child instanceof MavenJUnitTestMethodNode)) {
final FileObject fo = ((MavenJUnitTestMethodNode) child).getTestcaseFileObject();
if (fo != null) {
final long[] line = new long[]{0};
JavaSource javaSource = JavaSource.forFileObject(fo);
if (javaSource != null) {
try {
javaSource.runUserActionTask(new Task<CompilationController>() {
@Override
public void run(CompilationController compilationController) throws Exception {
compilationController.toPhase(Phase.ELEMENTS_RESOLVED);
Trees trees = compilationController.getTrees();
CompilationUnitTree compilationUnitTree = compilationController.getCompilationUnit();
List<? extends Tree> typeDecls = compilationUnitTree.getTypeDecls();
for (Tree tree : typeDecls) {
Element element = trees.getElement(trees.getPath(compilationUnitTree, tree));
if (element != null && element.getKind() == ElementKind.CLASS && element.getSimpleName().contentEquals(fo.getName())) {
long pos = trees.getSourcePositions().getStartPosition(compilationUnitTree, tree);
line[0] = compilationUnitTree.getLineMap().getLineNumber(pos);
break;
}
}
}
}, true);
} catch (IOException ioe) {
ErrorManager.getDefault().notify(ioe);
}
}
UIJavaUtils.openFile(fo, (int) line[0]);
}
}
}
}
@Override
public Tree visitIdentifier(IdentifierTree identifierTree, Trees trees) {
//rename shadowed variable
TreePath currentPath = getCurrentPath();
CharSequence newName = originalToNewName.get(trees.getElement(currentPath));
if (newName != null) {
IdentifierTree newTree = copy.getTreeMaker().Identifier(newName);
copy.rewrite(identifierTree, newTree);
}
return super.visitIdentifier(identifierTree, trees);
}
@Test
void testPositionAnnotationNoPackage187551() throws IOException {
String code = "\[email protected] Test {}";
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
null, Arrays.asList(new MyFileObject(code)));
CompilationUnitTree cut = ct.parse().iterator().next();
ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
Trees t = Trees.instance(ct);
assertEquals("testPositionAnnotationNoPackage187551",
1, t.getSourcePositions().getStartPosition(cut, clazz));
}
private boolean checkChange(CompilationController javac, PositionBounds span) throws IOException, BadLocationException {
final int begin = span.getBegin().getOffset();
final Trees trees = javac.getTrees();
TreePath path = javac.getTreeUtilities().pathFor(begin + 1);
if (path == null) {
return false;
}
Element element = trees.getElement(path);
if (element == null) {
return false;
}
TreePath decl = trees.getPath(element);
if (decl != null) {
SourcePositions sourcePositions = trees.getSourcePositions();
long declBegin = sourcePositions.getStartPosition(decl.getCompilationUnit(), decl.getLeaf());
FileObject fo = SourceUtils.getFile(element, javac.getClasspathInfo());
Document doc = javac.getDocument();
GuardedSectionManager guards = GuardedSectionManager.getInstance((StyledDocument) doc);
if (fo != javac.getFileObject() || guards != null && !isGuarded(guards, doc.createPosition((int) declBegin))) {
// tree being refactored is declared outside of this file
// or out of guarded sections. It should be safe to make change
return true;
}
} else {
// e.g. package; change is OK
return true;
}
return false;
}
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
Trees trees = Trees.instance(processingEnv);
Elements elements = processingEnv.getElementUtils();
Element pack = elements.getTypeElement("Test").getEnclosingElement();
for (Element root : pack.getEnclosedElements()) {
TreePath tp = trees.getPath(root);
new OwnerCheck(trees, pack).scan(tp.getCompilationUnit(), null);
}
return false;
}
@Override
public Tree visitClass(ClassTree node, Element source) {
final GeneratorUtilities genUtils = GeneratorUtilities.get(workingCopy);
final TreePath classPath = getCurrentPath();
ClassTree classTree = node;
translateQueue.addLast(new HashMap<Tree, Tree>());
Element el = workingCopy.getTrees().getElement(getCurrentPath());
inSuperClass = el.equals(source);
Tree value = super.visitClass(classTree, source);
if (inSuperClass) {
classTree = rewriteSuperClass(el, classTree, genUtils);
} else {
TypeMirror tm = el.asType();
Types types = workingCopy.getTypes();
Trees trees = workingCopy.getTrees();
if (types.isSubtype(types.erasure(tm), types.erasure(source.asType()))) {
classTree = rewriteSubClass(el, source, genUtils, trees, node);
}
}
Map<Tree, Tree> original2Translated = translateQueue.pollLast();
classTree = (ClassTree) workingCopy.getTreeUtilities().translate(classTree, original2Translated);
if (/* final boolean notTopLevel = classPath.getParentPath().getLeaf().getKind() != Tree.Kind.COMPILATION_UNIT; */
!translateQueue.isEmpty()) {
translateQueue.getLast().put(node, classTree);
} else {
rewrite(node, classTree);
}
return value;
}
@Test
void testPositionAnnotationNoPackage187551() throws IOException {
String code = "\[email protected] Test {}";
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
null, Arrays.asList(new MyFileObject(code)));
CompilationUnitTree cut = ct.parse().iterator().next();
ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
Trees t = Trees.instance(ct);
assertEquals("testPositionAnnotationNoPackage187551",
1, t.getSourcePositions().getStartPosition(cut, clazz));
}