当前位置: 首页>>代码示例>>Java>>正文


Java JCDiagnostic.DiagnosticPosition方法代码示例

本文整理汇总了Java中com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition方法的典型用法代码示例。如果您正苦于以下问题:Java JCDiagnostic.DiagnosticPosition方法的具体用法?Java JCDiagnostic.DiagnosticPosition怎么用?Java JCDiagnostic.DiagnosticPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.tools.javac.util.JCDiagnostic的用法示例。


在下文中一共展示了JCDiagnostic.DiagnosticPosition方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: lambdaParamIsExplicitlyTyped

import com.sun.tools.javac.util.JCDiagnostic; //导入方法依赖的package包/类
/**
 * determines whether a lambda parameter has an explicit type declaration
 *
 * @param lambdaParameter the parameter
 * @return true if there is a type declaration, false otherwise
 */
public static boolean lambdaParamIsExplicitlyTyped(VariableTree lambdaParameter) {
  // kind of a hack; the "preferred position" seems to be the position
  // of the variable name.  if this differs from the start position, it
  // means there is an explicit type declaration
  JCDiagnostic.DiagnosticPosition diagnosticPosition =
      (JCDiagnostic.DiagnosticPosition) lambdaParameter;
  return diagnosticPosition.getStartPosition() != diagnosticPosition.getPreferredPosition();
}
 
开发者ID:uber,项目名称:NullAway,代码行数:15,代码来源:NullabilityUtil.java

示例2: printMessage

import com.sun.tools.javac.util.JCDiagnostic; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:JavacTrees.java

示例3: printMessage

import com.sun.tools.javac.util.JCDiagnostic; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:JavacTrees.java

示例4: visitIf

import com.sun.tools.javac.util.JCDiagnostic; //导入方法依赖的package包/类
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");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:TestLog.java

示例5: resolveMethod

import com.sun.tools.javac.util.JCDiagnostic; //导入方法依赖的package包/类
private static Symbol.MethodSymbol resolveMethod( JCDiagnostic.DiagnosticPosition pos, Context ctx, JCTree.JCCompilationUnit compUnit, Name name, Type qual, List<Type> args )
{
  Resolve rs = Resolve.instance( ctx );
  AttrContext attrContext = new AttrContext();
  Env<AttrContext> env = new AttrContextEnv( pos.getTree(), attrContext );
  env.toplevel = compUnit;
  return rs.resolveInternalMethod( pos, env, qual, name, args, null );
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:9,代码来源:ExtensionTransformer.java

示例6: printMessage

import com.sun.tools.javac.util.JCDiagnostic; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:36,代码来源:JavacTrees.java

示例7: reportSyntaxError

import com.sun.tools.javac.util.JCDiagnostic; //导入方法依赖的package包/类
/**
 * Report a syntax error using the given DiagnosticPosition object and
 * arguments, unless one was already reported at the same position.
 */
private void reportSyntaxError(JCDiagnostic.DiagnosticPosition diagPos, String key, Object... args) {
    int pos = diagPos.getPreferredPosition();
    if (pos > S.errPos() || pos == Position.NOPOS) {
        if (S.token() == EOF) {
            error(diagPos, "premature.eof");
        } else {
            error(diagPos, key, args);
        }
    }
    S.errPos(pos);
    if (S.pos() == errorPos)
        S.nextToken(); // guarantee progress
    errorPos = S.pos();
}
 
开发者ID:sebastianoe,项目名称:s4j,代码行数:19,代码来源:JavacParser.java

示例8: printMessage

import com.sun.tools.javac.util.JCDiagnostic; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:50,代码来源:JavacTrees.java

示例9: pos

import com.sun.tools.javac.util.JCDiagnostic; //导入方法依赖的package包/类
public JCDiagnostic.DiagnosticPosition pos(DCDocComment dc) {
    return new SimpleDiagnosticPosition(dc.comment.getSourcePos(pos));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:DCTree.java

示例10: Opt

import com.sun.tools.javac.util.JCDiagnostic; //导入方法依赖的package包/类
public Opt() {
  JCDiagnostic.DiagnosticPosition pos = null;
  List<String> list = new ArrayList<>();
  list.forEach(wrapIOConsumer(s -> {}));
}
 
开发者ID:mopemope,项目名称:meghanada-server,代码行数:6,代码来源:Opt.java

示例11: printMessage

import com.sun.tools.javac.util.JCDiagnostic; //导入方法依赖的package包/类
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;
            log.multipleErrors = true;
            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);
    }
}
 
开发者ID:wmdietl,项目名称:jsr308-langtools,代码行数:42,代码来源:JavacTrees.java

示例12: printMessage

import com.sun.tools.javac.util.JCDiagnostic; //导入方法依赖的package包/类
/**
 * 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,
        com.sun.source.tree.Tree t,
        com.sun.source.tree.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);
    }
}
 
开发者ID:aducode,项目名称:openjdk-source-code-learn,代码行数:50,代码来源:JavacTrees.java


注:本文中的com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。