Java Code Examples for com.sun.tools.javac.util.JCDiagnostic#DiagnosticPosition

The following examples show how to use com.sun.tools.javac.util.JCDiagnostic#DiagnosticPosition . 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: TestLog.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void visitIf(JCTree.JCIf tree) {
    JCDiagnostic.DiagnosticPosition nil = null;
    // generate dummy messages to exercise the log API
    log.error("not.stmt");
    log.error(tree.pos, "not.stmt");
    log.error(tree.pos(), "not.stmt");
    log.error(nil, "not.stmt");

    log.warning("div.zero");
    log.warning(tree.pos, "div.zero");
    log.warning(tree.pos(), "div.zero");
    log.warning(nil, "div.zero");
}
 
Example 2
Source File: JavacTrees.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void printMessage(Diagnostic.Kind kind, CharSequence msg,
        JCDiagnostic.DiagnosticPosition pos,
        com.sun.source.tree.CompilationUnitTree root) {
    JavaFileObject oldSource = null;
    JavaFileObject newSource = null;

    newSource = root.getSourceFile();
    if (newSource == null) {
        pos = null;
    } else {
        oldSource = log.useSource(newSource);
    }

    try {
        switch (kind) {
        case ERROR:
            log.error(DiagnosticFlag.MULTIPLE, pos, Errors.ProcMessager(msg.toString()));
            break;

        case WARNING:
            log.warning(pos, Warnings.ProcMessager(msg.toString()));
            break;

        case MANDATORY_WARNING:
            log.mandatoryWarning(pos, Warnings.ProcMessager(msg.toString()));
            break;

        default:
            log.note(pos, Notes.ProcMessager(msg.toString()));
        }
    } finally {
        if (oldSource != null)
            log.useSource(oldSource);
    }
}
 
Example 3
Source File: Annotate.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public AnnotationContext(Env<AttrContext> env,
                         Map<Symbol.TypeSymbol, ListBuffer<T>> annotated,
                         Map<T, JCDiagnostic.DiagnosticPosition> pos,
                         boolean isTypeCompound) {
    Assert.checkNonNull(env);
    Assert.checkNonNull(annotated);
    Assert.checkNonNull(pos);

    this.env = env;
    this.annotated = annotated;
    this.pos = pos;
    this.isTypeCompound = isTypeCompound;
}
 
Example 4
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 5
Source File: TestLog.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void visitIf(JCTree.JCIf tree) {
    JCDiagnostic.DiagnosticPosition nil = null;
    // generate dummy messages to exercise the log API
    log.error("not.stmt");
    log.error(tree.pos, "not.stmt");
    log.error(tree.pos(), "not.stmt");
    log.error(nil, "not.stmt");

    log.warning("div.zero");
    log.warning(tree.pos, "div.zero");
    log.warning(tree.pos(), "div.zero");
    log.warning(nil, "div.zero");
}
 
Example 6
Source File: JavacTrees.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void printMessage(Diagnostic.Kind kind, CharSequence msg,
        JCDiagnostic.DiagnosticPosition pos,
        com.sun.source.tree.CompilationUnitTree root) {
    JavaFileObject oldSource = null;
    JavaFileObject newSource = null;

    newSource = root.getSourceFile();
    if (newSource == null) {
        pos = null;
    } else {
        oldSource = log.useSource(newSource);
    }

    try {
        switch (kind) {
        case ERROR:
            boolean prev = log.multipleErrors;
            try {
                log.error(pos, "proc.messager", msg.toString());
            } finally {
                log.multipleErrors = prev;
            }
            break;

        case WARNING:
            log.warning(pos, "proc.messager", msg.toString());
            break;

        case MANDATORY_WARNING:
            log.mandatoryWarning(pos, "proc.messager", msg.toString());
            break;

        default:
            log.note(pos, "proc.messager", msg.toString());
        }
    } finally {
        if (oldSource != null)
            log.useSource(oldSource);
    }
}
 
Example 7
Source File: TestLog.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void visitIf(JCTree.JCIf tree) {
    JCDiagnostic.DiagnosticPosition nil = null;
    // generate dummy messages to exercise the log API
    log.error("not.stmt");
    log.error(tree.pos, "not.stmt");
    log.error(tree.pos(), "not.stmt");
    log.error(nil, "not.stmt");

    log.warning("div.zero");
    log.warning(tree.pos, "div.zero");
    log.warning(tree.pos(), "div.zero");
    log.warning(nil, "div.zero");
}
 
Example 8
Source File: JavacTrees.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void printMessage(Diagnostic.Kind kind, CharSequence msg,
        JCDiagnostic.DiagnosticPosition pos,
        com.sun.source.tree.CompilationUnitTree root) {
    JavaFileObject oldSource = null;
    JavaFileObject newSource = null;

    newSource = root.getSourceFile();
    if (newSource == null) {
        pos = null;
    } else {
        oldSource = log.useSource(newSource);
    }

    try {
        switch (kind) {
        case ERROR:
            log.error(DiagnosticFlag.MULTIPLE, pos, "proc.messager", msg.toString());
            break;

        case WARNING:
            log.warning(pos, "proc.messager", msg.toString());
            break;

        case MANDATORY_WARNING:
            log.mandatoryWarning(pos, "proc.messager", msg.toString());
            break;

        default:
            log.note(pos, "proc.messager", msg.toString());
        }
    } finally {
        if (oldSource != null)
            log.useSource(oldSource);
    }
}
 
Example 9
Source File: ExtensionTransformer.java    From manifold with Apache License 2.0 5 votes vote down vote up
private Symbol.VarSymbol resolveField( JCDiagnostic.DiagnosticPosition pos, Context ctx, Name name, Type qual )
{
  Resolve rs = Resolve.instance( ctx );
  AttrContext attrContext = new AttrContext();
  Env<AttrContext> env = new AttrContextEnv( pos.getTree(), attrContext );
  env.toplevel = (JCTree.JCCompilationUnit)_tp.getCompilationUnit();
  return rs.resolveInternalField( pos, env, qual, name );
}
 
Example 10
Source File: TestLog.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void visitIf(JCTree.JCIf tree) {
    JCDiagnostic.DiagnosticPosition nil = null;
    // generate dummy messages to exercise the log API
    log.error("not.stmt");
    log.error(tree.pos, "not.stmt");
    log.error(tree.pos(), "not.stmt");
    log.error(nil, "not.stmt");

    log.warning("div.zero");
    log.warning(tree.pos, "div.zero");
    log.warning(tree.pos(), "div.zero");
    log.warning(nil, "div.zero");
}
 
Example 11
Source File: JavacTrees.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void printMessage(Diagnostic.Kind kind, CharSequence msg,
        JCDiagnostic.DiagnosticPosition pos,
        com.sun.source.tree.CompilationUnitTree root) {
    JavaFileObject oldSource = null;
    JavaFileObject newSource = null;

    newSource = root.getSourceFile();
    if (newSource == null) {
        pos = null;
    } else {
        oldSource = log.useSource(newSource);
    }

    try {
        switch (kind) {
        case ERROR:
            boolean prev = log.multipleErrors;
            try {
                log.error(pos, "proc.messager", msg.toString());
            } finally {
                log.multipleErrors = prev;
            }
            break;

        case WARNING:
            log.warning(pos, "proc.messager", msg.toString());
            break;

        case MANDATORY_WARNING:
            log.mandatoryWarning(pos, "proc.messager", msg.toString());
            break;

        default:
            log.note(pos, "proc.messager", msg.toString());
        }
    } finally {
        if (oldSource != null)
            log.useSource(oldSource);
    }
}
 
Example 12
Source File: DCTree.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public JCDiagnostic.DiagnosticPosition pos(DCDocComment dc) {
    return new SimpleDiagnosticPosition(dc.comment.getSourcePos(pos));
}
 
Example 13
Source File: JavacTrees.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Prints a message of the specified kind at the location of the
 * tree within the provided compilation unit
 *
 * @param kind the kind of message
 * @param msg  the message, or an empty string if none
 * @param t    the tree to use as a position hint
 * @param root the compilation unit that contains tree
 */
public void printMessage(Diagnostic.Kind kind, CharSequence msg,
        Tree t,
        CompilationUnitTree root) {
    JavaFileObject oldSource = null;
    JavaFileObject newSource = null;
    JCDiagnostic.DiagnosticPosition pos = null;

    newSource = root.getSourceFile();
    if (newSource != null) {
        oldSource = log.useSource(newSource);
        pos = ((JCTree) t).pos();
    }

    try {
        switch (kind) {
        case ERROR:
            boolean prev = log.multipleErrors;
            try {
                log.error(pos, "proc.messager", msg.toString());
            } finally {
                log.multipleErrors = prev;
            }
            break;

        case WARNING:
            log.warning(pos, "proc.messager", msg.toString());
            break;

        case MANDATORY_WARNING:
            log.mandatoryWarning(pos, "proc.messager", msg.toString());
            break;

        default:
            log.note(pos, "proc.messager", msg.toString());
        }
    } finally {
        if (oldSource != null)
            log.useSource(oldSource);
    }
}
 
Example 14
Source File: DCTree.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public JCDiagnostic.DiagnosticPosition pos(DCDocComment dc) {
    return new SimpleDiagnosticPosition(dc.comment.getSourcePos(pos));
}
 
Example 15
Source File: DCTree.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public JCDiagnostic.DiagnosticPosition pos(DCDocComment dc) {
    return new SimpleDiagnosticPosition(dc.comment.getSourcePos(pos));
}
 
Example 16
Source File: DCTree.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public JCDiagnostic.DiagnosticPosition pos(DCDocComment dc) {
    return new SimpleDiagnosticPosition(dc.comment.getSourcePos(pos));
}
 
Example 17
Source File: ExtensionTransformer.java    From manifold with Apache License 2.0 4 votes vote down vote up
private Symbol.MethodSymbol resolveMethod( JCDiagnostic.DiagnosticPosition pos, Name name, Type qual, List<Type> args )
{
  return resolveMethod( pos, _tp.getContext(), (JCTree.JCCompilationUnit)_tp.getCompilationUnit(), name, qual, args );
}
 
Example 18
Source File: DCTree.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public JCDiagnostic.DiagnosticPosition pos(DCDocComment dc) {
    return new SimpleDiagnosticPosition(dc.comment.getSourcePos(pos));
}
 
Example 19
Source File: IDynamicJdk.java    From manifold with Apache License 2.0 votes vote down vote up
void logError( Log logger, JCDiagnostic.DiagnosticPosition pos, String key, Object... message ); 
Example 20
Source File: StringConcat.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License votes vote down vote up
protected abstract void emit(List<JCTree> args, Type type, JCDiagnostic.DiagnosticPosition pos);