Java Code Examples for com.sun.tools.javac.tree.JCTree#toString()
The following examples show how to use
com.sun.tools.javac.tree.JCTree#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TreeAnalyzer.java From meghanada-server with GNU General Public License v3.0 | 6 votes |
private static void analyzeAnnotationTree( final Source src, final EndPosTable endPosTable, final AnnotationTree at) { if (at instanceof JCTree.JCAnnotation) { JCTree.JCAnnotation anno = (JCTree.JCAnnotation) at; int startPos = anno.getPreferredPosition(); int endPos = anno.getEndPosition(endPosTable); JCTree annotationType = anno.getAnnotationType(); int annotationTypeEndPosition = annotationType.getEndPosition(endPosTable); Range range; if (endPos != annotationTypeEndPosition) { startPos = annotationTypeEndPosition; } range = Range.create(src, startPos + 1, endPos); Type type = anno.type; Annotation annotation; if (nonNull(type)) { annotation = new Annotation(type.toString(), startPos, range); } else { annotation = new Annotation(annotationType.toString(), startPos, range); } src.annotationMap.put(range.begin.line, annotation); } }
Example 2
Source File: TypeAnnotationsPretty.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
void checkMatch(String code, JCTree tree) { String expect = code.replace("\n", NL); String found = tree.toString(); if (!expect.equals(found)) { mismatches.add("Expected: " + expect + NL + "Obtained: " + found); } else { matches.add("Passed: " + expect); } }
Example 3
Source File: TypeAnnotationsPretty.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
void checkMatch(String code, JCTree tree) { String expect = code.replace("\n", NL); String found = tree.toString(); if (!expect.equals(found)) { mismatches.add("Expected: " + expect + NL + "Obtained: " + found); } else { matches.add("Passed: " + expect); } }
Example 4
Source File: TypeAnnotationsPretty.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
void checkMatch(String code, JCTree tree) { String expect = code.replace("\n", NL); String found = tree.toString(); if (!expect.equals(found)) { mismatches.add("Expected: " + expect + NL + "Obtained: " + found); } else { matches.add("Passed: " + expect); } }
Example 5
Source File: TypeAnnotationsPretty.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
void checkMatch(String code, JCTree tree) { String expect = code.replace("\n", NL); String found = tree.toString(); if (!expect.equals(found)) { mismatches.add("Expected: " + expect + NL + "Obtained: " + found); } else { matches.add("Passed: " + expect); } }
Example 6
Source File: JavaUtil.java From javaide with GNU General Public License v3.0 | 5 votes |
@Nullable public static IClass jcTypeToClass(JCTree.JCCompilationUnit unit, JCTree type) { if (type == null) { return null; } String className; if (type instanceof JCTree.JCTypeApply) { //generic return jcTypeToClass(unit, ((JCTree.JCTypeApply) type).getType()); } else { className = type.toString(); } //try to find full class name className = findImportedClassName(unit, className); return JavaClassManager.getInstance().getParsedClass(className); }
Example 7
Source File: TypeAnnotationsPretty.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
void checkMatch(String code, JCTree tree) { String expect = code.replace("\n", NL); String found = tree.toString(); if (!expect.equals(found)) { mismatches.add("Expected: " + expect + NL + "Obtained: " + found); } else { matches.add("Passed: " + expect); } }
Example 8
Source File: TypeAnnotationsPretty.java From hottub with GNU General Public License v2.0 | 5 votes |
void checkMatch(String code, JCTree tree) { String expect = code.replace("\n", NL); String found = tree.toString(); if (!expect.equals(found)) { mismatches.add("Expected: " + expect + NL + "Obtained: " + found); } else { matches.add("Passed: " + expect); } }
Example 9
Source File: TypeAnnotationsPretty.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
void checkMatch(String code, JCTree tree) { String expect = code.replace("\n", NL); String found = tree.toString(); if (!expect.equals(found)) { mismatches.add("Expected: " + expect + NL + "Obtained: " + found); } else { matches.add("Passed: " + expect); } }
Example 10
Source File: TreeAnalyzer.java From meghanada-server with GNU General Public License v3.0 | 5 votes |
private static void parseUnionVariable( JCTree.JCVariableDecl vd, int preferredPos, Source src, JCTree typeTree, String vName, Range nameRange, JCTree.JCTypeUnion union) { for (JCTree.JCExpression expression : union.getTypeAlternatives()) { String type = expression.toString(); Variable variable = new Variable(vName, preferredPos, nameRange); type = src.getImportedClassFQCN(type, type); if (vd.getTag().equals(JCTree.Tag.VARDEF)) { variable.isDef = true; } String typeSym = typeTree.toString(); boolean markUnUse = requireImport(src, typeSym, type); log.trace("typeSym:{} type:{} markUnuse:{}", typeSym, type, markUnUse); if (nonNull(type)) { variable.fqcn = TreeAnalyzer.markFQCN(src, type, markUnUse); src.getCurrentScope() .ifPresent( scope -> { scope.addVariable(variable); addSymbolIndex(src, scope, variable); }); } } }
Example 11
Source File: TypeAnnotationsPretty.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
void checkMatch(String code, JCTree tree) { String expect = code.replace("\n", NL); String found = tree.toString(); if (!expect.equals(found)) { mismatches.add("Expected: " + expect + NL + "Obtained: " + found); } else { matches.add("Passed: " + expect); } }
Example 12
Source File: JavacImportList.java From EasyMPermission with MIT License | 4 votes |
private String topLevelName(JCTree tree) { while (tree instanceof JCFieldAccess) tree = ((JCFieldAccess) tree).selected; return tree.toString(); }
Example 13
Source File: JavacHandlerUtil.java From EasyMPermission with MIT License | 3 votes |
/** * Checks if the given TypeReference node is likely to be a reference to the provided class. * * @param type An actual type. This method checks if {@code typeNode} is likely to be a reference to this type. * @param node A Lombok AST node. Any node in the appropriate compilation unit will do (used to get access to import statements). * @param typeNode A type reference to check. */ public static boolean typeMatches(Class<?> type, JavacNode node, JCTree typeNode) { String typeName = typeNode.toString(); TypeResolver resolver = new TypeResolver(node.getImportList()); return resolver.typeMatches(node, type.getName(), typeName); }