Java Code Examples for com.sun.source.tree.Tree.Kind#ERRONEOUS
The following examples show how to use
com.sun.source.tree.Tree.Kind#ERRONEOUS .
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: LoggerStringConcat.java From netbeans with Apache License 2.0 | 6 votes |
private static ErrorDescription compute(HintContext ctx, String methodName) { TreePath message = ctx.getVariables().get("$message"); List<List<TreePath>> sorted = Utilities.splitStringConcatenationToElements(ctx.getInfo(), message); if (sorted.size() <= 1) { return null; } //check for erroneous trees: for (List<TreePath> tps : sorted) for (TreePath tp : tps) if (tp.getLeaf().getKind() == Kind.ERRONEOUS) return null; FixImpl fix = new FixImpl(NbBundle.getMessage(LoggerStringConcat.class, "MSG_LoggerStringConcat_fix"), methodName, TreePathHandle.create(ctx.getPath(), ctx.getInfo()), TreePathHandle.create(message, ctx.getInfo())); return ErrorDescriptionFactory.forTree(ctx, message, NbBundle.getMessage(LoggerStringConcat.class, "MSG_LoggerStringConcat"), fix.toEditorFix()); }
Example 2
Source File: Braces.java From netbeans with Apache License 2.0 | 5 votes |
private static boolean isErroneousExpression(StatementTree statement) { if ( statement instanceof ExpressionStatementTree ) { if ( ((ExpressionStatementTree)statement).getExpression().getKind() == Kind.ERRONEOUS ) { return true; } } return false; }
Example 3
Source File: SourceCodeAnalysisImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private boolean isEmptyArgumentsContext(List<? extends ExpressionTree> arguments) { if (arguments.size() == 1) { Tree firstArgument = arguments.get(0); return firstArgument.getKind() == Kind.ERRONEOUS; } return false; }
Example 4
Source File: Utilities.java From netbeans with Apache License 2.0 | 4 votes |
private static boolean isErrorTree(Tree t) { return t.getKind() == Kind.ERRONEOUS || (t.getKind() == Kind.IDENTIFIER && ((IdentifierTree) t).getName().contentEquals("<error>")); //TODO: <error>... }
Example 5
Source File: DeclarationForInstanceOf.java From netbeans with Apache License 2.0 | 4 votes |
List<ErrorDescription> run(CompilationInfo info, TreePath treePath, int offset) { TreePath ifPath = treePath; while (ifPath != null) { Kind lk = ifPath.getLeaf().getKind(); if (lk == Kind.IF) { break; } if (lk == Kind.METHOD || TreeUtilities.CLASS_TREE_KINDS.contains(lk)) { return null; } ifPath = ifPath.getParentPath(); } if (ifPath == null) { return null; } InstanceOfTree leaf = (InstanceOfTree) treePath.getLeaf(); if (leaf.getType() == null || leaf.getType().getKind() == Kind.ERRONEOUS) { return null; } TypeMirror castTo = info.getTrees().getTypeMirror(new TreePath(treePath, leaf.getType())); TreePath expression = new TreePath(treePath, leaf.getExpression()); TypeMirror expressionType = info.getTrees().getTypeMirror(expression); if (!(Utilities.isValidType(castTo) && Utilities.isValidType(expressionType)) || !info.getTypeUtilities().isCastable(expressionType, castTo)) { return null; } List<Fix> fix = Collections.<Fix>singletonList(new FixImpl(info.getJavaSource(), TreePathHandle.create(ifPath, info), TreePathHandle.create(expression, info), TypeMirrorHandle.create(castTo), Utilities.getName(castTo))); String displayName = NbBundle.getMessage(DeclarationForInstanceOf.class, "ERR_DeclarationForInstanceof"); ErrorDescription err = ErrorDescriptionFactory.createErrorDescription(Severity.HINT, displayName, fix, info.getFileObject(), offset, offset); return Collections.singletonList(err); }