Java Code Examples for com.sun.tools.javac.tree.JCTree#pos()

The following examples show how to use com.sun.tools.javac.tree.JCTree#pos() . 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: StringConcat.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private JCDiagnostic.DiagnosticPosition newStringBuilder(JCTree tree) {
    JCDiagnostic.DiagnosticPosition pos = tree.pos();
    gen.getCode().emitop2(new_, gen.makeRef(pos, syms.stringBuilderType));
    gen.getCode().emitop0(dup);
    gen.callMethod(pos, syms.stringBuilderType, names.init, List.nil(), false);
    return pos;
}
 
Example 2
Source File: DeferredAttr.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void scan(JCTree tree) {
    if (tree != null &&
            tree.pos() == pos) {
        found = true;
    }
    super.scan(tree);
}
 
Example 3
Source File: StringConcat.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private JCDiagnostic.DiagnosticPosition newStringBuilder(JCTree tree) {
    JCDiagnostic.DiagnosticPosition pos = tree.pos();
    gen.getCode().emitop2(new_, gen.makeRef(pos, syms.stringBuilderType));
    gen.getCode().emitop0(dup);
    gen.callMethod(pos, syms.stringBuilderType, names.init, List.nil(), false);
    return pos;
}
 
Example 4
Source File: JavacAST.java    From EasyMPermission with MIT License 5 votes vote down vote up
/** Supply either a position or a node (in that case, position of the node is used) */
void printMessage(Diagnostic.Kind kind, String message, JavacNode node, DiagnosticPosition pos, boolean attemptToRemoveErrorsInRange) {
	JavaFileObject oldSource = null;
	JavaFileObject newSource = null;
	JCTree astObject = node == null ? null : node.get();
	JCCompilationUnit top = (JCCompilationUnit) top().get();
	newSource = top.sourcefile;
	if (newSource != null) {
		oldSource = log.useSource(newSource);
		if (pos == null) pos = astObject.pos();
	}
	if (pos != null && attemptToRemoveErrorsInRange) {
		removeFromDeferredDiagnostics(pos.getStartPosition(), node.getEndPosition(pos));
	}
	try {
		switch (kind) {
		case ERROR:
			increaseErrorCount(messager);
			boolean prev = log.multipleErrors;
			log.multipleErrors = true;
			try {
				log.error(pos, "proc.messager", message);
			} finally {
				log.multipleErrors = prev;
			}
			break;
		default:
		case WARNING:
			log.warning(pos, "proc.messager", message);
			break;
		}
	} finally {
		if (oldSource != null) log.useSource(oldSource);
	}
}