private int getStartPos(JCTree tree) { return tree.pos().getStartPosition(); }
/** Find the position for reporting an error about a symbol, where * that symbol is defined somewhere in the given tree. */ public static DiagnosticPosition diagnosticPositionFor(final Symbol sym, final JCTree tree) { JCTree decl = declarationFor(sym, tree); return ((decl != null) ? decl : tree).pos(); }
/** Annotation types are restricted to primitives, String, an * enum, an annotation, Class, Class<?>, Class<? extends * Anything>, arrays of the preceding. */ void validateAnnotationType(JCTree restype) { // restype may be null if an error occurred, so don't bother validating it if (restype != null) { validateAnnotationType(restype.pos(), restype.type); } }
/** The tree simulating a T.class expression. * @param clazz The tree identifying type T. */ private JCExpression classOf(JCTree clazz) { return classOfType(clazz.type, clazz.pos()); }
/** The tree simulating a T.class expression. * @param clazz The tree identifying type T. */ private JCExpression classOf(JCTree clazz) { return classOfType(clazz.type, clazz.pos()); }
/** Find the position for reporting an error about a symbol, where * that symbol is defined somewhere in the given tree. */ public static DiagnosticPosition diagnosticPositionFor(final Symbol sym, final JCTree tree) { JCTree decl = declarationFor(sym, tree); return ((decl != null) ? decl : tree).pos(); }
/** Annotation types are restricted to primitives, String, an * enum, an annotation, Class, Class<?>, Class<? extends * Anything>, arrays of the preceding. */ void validateAnnotationType(JCTree restype) { // restype may be null if an error occurred, so don't bother validating it if (restype != null) { validateAnnotationType(restype.pos(), restype.type); } }
/** Visitor method: Validate a type expression, if it is not null, catching * and reporting any completion failures. */ void validate(JCTree tree) { try { if (tree != null) tree.accept(validator); } catch (CompletionFailure ex) { completionError(tree.pos(), ex); } }
/** Analyze a definition. */ void scanDef(JCTree tree) { scanStat(tree); if (tree != null && tree.tag == JCTree.BLOCK && !alive) { log.error(tree.pos(), "initializer.must.be.able.to.complete.normally"); } }
/** Analyze a statement. Check that statement is reachable. */ void scanStat(JCTree tree) { if (!alive && tree != null) { log.error(tree.pos(), "unreachable.stmt"); if (tree.tag != JCTree.SKIP) alive = true; } scan(tree); }
/** * Attribute an env for either a top level tree or class declaration. */ public void attrib(Env<AttrContext> env) { if (env.tree.hasTag(TOPLEVEL)) attribTopLevel(env); else attribClass(env.tree.pos(), env.enclClass.sym); }
/** Analyze a definition. */ void scanDef(JCTree tree) { scanStat(tree); if (tree != null && tree.getTag() == JCTree.BLOCK && !alive) { log.error(tree.pos(), "initializer.must.be.able.to.complete.normally"); } }
/** Check that a qualified name is in canonical form (for import decls). */ public void checkCanonical(JCTree tree) { if (!isCanonical(tree)) log.error(tree.pos(), "import.requires.canonical", TreeInfo.symbol(tree)); } // where
public void printMessage(Diagnostic.Kind kind, CharSequence msg, com.sun.source.doctree.DocTree t, com.sun.source.doctree.DocCommentTree c, com.sun.source.tree.CompilationUnitTree root) { printMessage(kind, msg, ((DCTree) t).pos((DCDocComment) c), root); }
private JCTree convert(JCTree tree, Type pt) { if (tree.type == pt) return tree; JCTree result = make_at(tree.pos()).TypeCast(make.Type(pt), (JCExpression)tree); result.type = (tree.type.constValue() != null) ? cfolder.coerce(tree.type, pt) : pt; return result; }
/** Record that exception is potentially thrown and check that it * is caught. */ void markThrown(JCTree tree, Type exc) { if (!chk.isUnchecked(tree.pos(), exc)) { if (!chk.isHandled(exc, caught)) pendingExits.append(new PendingExit(tree, exc)); thrown = chk.incl(exc, thrown); } }
/** Record that exception is potentially thrown and check that it * is caught. */ void markThrown(JCTree tree, Type exc) { if (!chk.isUnchecked(tree.pos(), exc)) { if (!chk.isHandled(exc, caught)) { pendingExits.append(new FlowPendingExit(tree, exc)); } thrown = chk.incl(exc, thrown); } }
/** If tree is either a simple name or of the form this.name or * C.this.name, and tree represents a trackable variable, * record an initialization of the variable. */ void letInit(JCTree tree) { tree = TreeInfo.skipParens(tree); if (tree.getTag() == JCTree.IDENT || tree.getTag() == JCTree.SELECT) { Symbol sym = TreeInfo.symbol(tree); letInit(tree.pos(), (VarSymbol)sym); } }
private JCTree convert(JCTree tree, Type pt) { if (tree.type == pt || tree.type.hasTag(BOT)) return tree; JCTree result = make_at(tree.pos()).TypeCast(make.Type(pt), (JCExpression)tree); result.type = (tree.type.constValue() != null) ? cfolder.coerce(tree.type, pt) : pt; return result; }
public void visitTypeTest(JCInstanceOf tree) { Type exprtype = chk.checkNullOrRefType( tree.expr.pos(), attribExpr(tree.expr, env)); Type clazztype = chk.checkReifiableReferenceType( tree.clazz.pos(), attribType(tree.clazz, env)); chk.checkCastable(tree.expr.pos(), exprtype, clazztype); result = check(tree, syms.booleanType, VAL, pkind, pt); }