Java Code Examples for com.sun.source.tree.Tree#toString()
The following examples show how to use
com.sun.source.tree.Tree#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: MethodArgumentsScanner.java From netbeans with Apache License 2.0 | 6 votes |
private final MethodArgument[] composeArguments(List<? extends Tree> args, List<? extends Tree> argTypes) { int n = args.size(); MethodArgument[] arguments = new MethodArgument[n]; for (int i = 0; i < n; i++) { Tree var = args.get(i); long startOffset = positions.getStartPosition(tree, var); long endOffset = positions.getEndPosition(tree, var); if (startOffset == Diagnostic.NOPOS || endOffset == Diagnostic.NOPOS) { return new MethodArgument[] {}; } arguments[i] = new MethodArgument(var.toString(), (argTypes.size() > i) ? argTypes.get(i).toString() : "", positionDelegate.createPosition( (int) startOffset, (int) lineMap.getLineNumber(startOffset), (int) lineMap.getColumnNumber(startOffset)), positionDelegate.createPosition( (int) endOffset, (int) lineMap.getLineNumber(endOffset), (int) lineMap.getColumnNumber(endOffset))); } return arguments; }
Example 2
Source File: IsSigMethodCriterion.java From annotation-tools with MIT License | 6 votes |
private boolean matchTypeParam(String goalType, Tree type, Map<String, String> typeToClassMap, Context context) { String simpleType = type.toString(); boolean haveMatch = matchSimpleType(goalType, simpleType, context); if (!haveMatch) { if (!typeToClassMap.isEmpty()) { for (Map.Entry<String, String> p : typeToClassMap.entrySet()) { simpleType = simpleType.replaceAll("\\b" + p.getKey() + "\\b", p.getValue()); haveMatch = matchSimpleType(goalType, simpleType, context); if (!haveMatch) { Criteria.dbug.debug("matchTypeParams() => false:%n"); Criteria.dbug.debug(" type = %s%n", type); Criteria.dbug.debug(" simpleType = %s%n", simpleType); Criteria.dbug.debug(" goalType = %s%n", goalType); } } } } return haveMatch; }
Example 3
Source File: JavacModuleParser.java From pro with GNU General Public License v3.0 | 5 votes |
private static String qualifiedString(Tree tree) { switch (tree.getKind()) { case IDENTIFIER: return ((IdentifierTree) tree).getName().toString(); case MEMBER_SELECT: var select = (MemberSelectTree) tree; return qualifiedString(select.getExpression()) + '.' + select.getIdentifier().toString(); default: throw new AssertionError(tree.toString()); } }
Example 4
Source File: Main.java From annotation-tools with MIT License | 5 votes |
/** Return the first 80 characters of the tree's printed representation, on one line. * * @param node a tree to format with truncation * @return the first 80 characters of the tree's printed representation, on one line */ public static String treeToString(Tree node) { String asString = node.toString(); String oneLine = first80(asString); if (oneLine.endsWith(" ")) { oneLine = oneLine.substring(0, oneLine.length() - 1); } // return "\"" + oneLine + "\""; return oneLine; }
Example 5
Source File: JVMNames.java From annotation-tools with MIT License | 5 votes |
@SuppressWarnings("signature") // com.sun.source.tree.Tree is not yet annotated private static void treeToJVMLString(Tree typeTree, StringBuilder builder) { // FIXME: not robust in presence of comments switch (typeTree.getKind()) { case ARRAY_TYPE: builder.append('['); treeToJVMLString(((ArrayTypeTree) typeTree).getType(), builder); break; default: String str = typeTree.toString(); builder.append("void".equals(str) ? "V" : Signatures.binaryNameToFieldDescriptor(typeTree.toString())); break; } }
Example 6
Source File: TreeConverter.java From j2objc with Apache License 2.0 | 5 votes |
private String getTreeSource(Tree node) { try { CharSequence source = unit.getSourceFile().getCharContent(true); return source .subSequence( (int) sourcePositions.getStartPosition(unit, node), (int) sourcePositions.getEndPosition(unit, node)) .toString(); } catch (IOException e) { return node.toString(); } }
Example 7
Source File: MemberInfo.java From netbeans with Apache License 2.0 | 4 votes |
public static <T extends TypeMirror> MemberInfo<TypeMirrorHandle<T>> create(T el, Tree t, CompilationInfo c) { MemberInfo<TypeMirrorHandle<T>> mi = new MemberInfo<TypeMirrorHandle<T>>(TypeMirrorHandle.create(el), t.toString(), "implements " + t.toString(), ElementIcons.getElementIcon(ElementKind.INTERFACE, null)); // NOI18N mi.group = Group.IMPLEMENTS; return mi; }
Example 8
Source File: Translator.java From groovy-cps with Apache License 2.0 | 4 votes |
@Override protected JType defaultAction(Tree node, Void __) { throw new UnsupportedOperationException(node.toString()); }