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


Java DiagnosticFlag类代码示例

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


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

示例1: importAll

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; //导入依赖的package包/类
/** Import all classes of a class or package on demand.
 *  @param pos           Position to be used for error reporting.
 *  @param tsym          The class or package the members of which are imported.
 *  @param toScope   The (import) scope in which imported classes
 *               are entered.
 */
private void importAll(int pos,
                       final TypeSymbol tsym,
                       Env<AttrContext> env) {
    // Check that packages imported from exist (JLS ???).
    if (tsym.kind == PCK && tsym.members().elems == null && !tsym.exists()) {
        // If we can't find java.lang, exit immediately.
        if (((PackageSymbol)tsym).fullname.equals(names.java_lang)) {
            JCDiagnostic msg = diags.fragment("fatal.err.no.java.lang");
            throw new FatalError(msg);
        } else {
            log.error(DiagnosticFlag.RESOLVE_ERROR, pos, "doesnt.exist", tsym);
        }
    }
    env.toplevel.starImportScope.importAll(tsym.members());
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:22,代码来源:MemberEnter.java

示例2: importAll

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; //导入依赖的package包/类
/** Import all classes of a class or package on demand.
 *  @param pos           Position to be used for error reporting.
 *  @param tsym          The class or package the members of which are imported.
 *  @param env           The env in which the imported classes will be entered.
 */
private void importAll(int pos,
                       final TypeSymbol tsym,
                       Env<AttrContext> env) {
    // Check that packages imported from exist (JLS ???).
    if (tsym.kind == PCK && tsym.members().elems == null && !tsym.exists()) {
        // If we can't find java.lang, exit immediately.
        if (((PackageSymbol)tsym).fullname.equals(names.java_lang)) {
            JCDiagnostic msg = diags.fragment("fatal.err.no.java.lang");
            throw new FatalError(msg);
        } else {
            log.error(DiagnosticFlag.RESOLVE_ERROR, pos, "doesnt.exist", tsym);
        }
    }
    env.toplevel.starImportScope.importAll(tsym.members());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:MemberEnter.java

示例3: checkDiamond

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; //导入依赖的package包/类
/** Check that usage of diamond operator is correct (i.e. diamond should not
 * be used with non-generic classes or in anonymous class creation expressions)
 */
Type checkDiamond(JCNewClass tree, Type t) {
    if (!TreeInfo.isDiamond(tree) ||
            t.isErroneous()) {
        return checkClassType(tree.clazz.pos(), t, true);
    } else {
        if (tree.def != null && !allowDiamondWithAnonymousClassCreation) {
            log.error(DiagnosticFlag.SOURCE_LEVEL, tree.clazz.pos(),
                    Errors.CantApplyDiamond1(t, Fragments.DiamondAndAnonClassNotSupportedInSource(source.name)));
        }
        if (t.tsym.type.getTypeArguments().isEmpty()) {
            log.error(tree.clazz.pos(),
                      Errors.CantApplyDiamond1(t,
                                               Fragments.DiamondNonGeneric(t)));
            return types.createErrorType(t);
        } else if (tree.typeargs != null &&
                tree.typeargs.nonEmpty()) {
            log.error(tree.clazz.pos(),
                      Errors.CantApplyDiamond1(t,
                                               Fragments.DiamondAndExplicitParams(t)));
            return types.createErrorType(t);
        } else {
            return t;
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:Check.java

示例4: checkImportedPackagesObservable

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; //导入依赖的package包/类
public void checkImportedPackagesObservable(final JCCompilationUnit toplevel) {
    OUTER: for (JCImport imp : toplevel.getImports()) {
        if (!imp.staticImport && TreeInfo.name(imp.qualid) == names.asterisk) {
            TypeSymbol tsym = ((JCFieldAccess)imp.qualid).selected.type.tsym;
            if (toplevel.modle.visiblePackages != null) {
                //TODO - unclear: selects like javax.* will get resolved from the current module
                //(as javax is not an exported package from any module). And as javax in the current
                //module typically does not contain any classes or subpackages, we need to go through
                //the visible packages to find a sub-package:
                for (PackageSymbol known : toplevel.modle.visiblePackages.values()) {
                    if (Convert.packagePart(known.fullname) == tsym.flatName())
                        continue OUTER;
                }
            }
            if (tsym.kind == PCK && tsym.members().isEmpty() && !tsym.exists()) {
                log.error(DiagnosticFlag.RESOLVE_ERROR, imp.pos, Errors.DoesntExist(tsym));
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:Check.java

示例5: checkImportedPackagesObservable

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; //导入依赖的package包/类
public void checkImportedPackagesObservable(final JCCompilationUnit toplevel) {
    OUTER: for (JCImport imp : toplevel.getImports()) {
        if (!imp.staticImport && TreeInfo.name(imp.qualid) == names.asterisk) {
            TypeSymbol tsym = ((JCFieldAccess)imp.qualid).selected.type.tsym;
            if (toplevel.modle.visiblePackages != null) {
                //TODO - unclear: selects like javax.* will get resolved from the current module
                //(as javax is not an exported package from any module). And as javax in the current
                //module typically does not contain any classes or subpackages, we need to go through
                //the visible packages to find a sub-package:
                for (PackageSymbol known : toplevel.modle.visiblePackages.values()) {
                    if (Convert.packagePart(known.fullname) == tsym.flatName())
                        continue OUTER;
                }
            }
            if (tsym.kind == PCK && tsym.members().isEmpty() && !tsym.exists()) {
                log.error(DiagnosticFlag.RESOLVE_ERROR, imp.pos, "doesnt.exist", tsym);
            }
        }
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:21,代码来源:Check.java

示例6: isSyntaxError

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; //导入依赖的package包/类
public static boolean isSyntaxError(Diagnostic<?> d) {
    JCDiagnostic jcd = getJCDiagnostic(d);
    if (jcd == null) {
        return false;
    }
    return jcd.isFlagSet(DiagnosticFlag.SYNTAX);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:Hacks.java

示例7: logResolveError

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; //导入依赖的package包/类
private void logResolveError(ResolveError error,
        DiagnosticPosition pos,
        Symbol location,
        Type site,
        Name name,
        List<Type> argtypes,
        List<Type> typeargtypes) {
    JCDiagnostic d = error.getDiagnostic(DiagnosticType.ERROR,
            pos, location, site, name, argtypes, typeargtypes);
    if (d != null) {
        d.setFlag(DiagnosticFlag.RESOLVE_ERROR);
        log.report(d);
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:15,代码来源:Resolve.java

示例8: logResolveError

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; //导入依赖的package包/类
private void logResolveError(ResolveError error,
        DiagnosticPosition pos,
        Symbol location,
        Type site,
        Name name,
        List<Type> argtypes,
        List<Type> typeargtypes) {
    JCDiagnostic d = error.getDiagnostic(JCDiagnostic.DiagnosticType.ERROR,
            pos, location, site, name, argtypes, typeargtypes);
    if (d != null) {
        d.setFlag(DiagnosticFlag.RESOLVE_ERROR);
        log.report(d);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:Resolve.java

示例9: printMessage

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; //导入依赖的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

示例10: report

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; //导入依赖的package包/类
@Override
public void report(JCDiagnostic diag) {
    if (!diag.isFlagSet(JCDiagnostic.DiagnosticFlag.NON_DEFERRABLE) &&
        (filter == null || filter.accepts(diag))) {
        deferred.add(diag);
    } else {
        prev.report(diag);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:Log.java

示例11: rewrite

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; //导入依赖的package包/类
/**
 * Main entry point for diagnostic rewriting - given a diagnostic, see if any templates matches it,
 * and rewrite it accordingly.
 */
static JCDiagnostic rewrite(JCDiagnostic.Factory diags, DiagnosticPosition pos, DiagnosticSource source,
                            DiagnosticType dkind, JCDiagnostic d) {
    for (Map.Entry<Template, DiagnosticRewriter> _entry : rewriters.entrySet()) {
        if (_entry.getKey().matches(d)) {
            JCDiagnostic simpleDiag =
                    _entry.getValue().rewriteDiagnostic(diags, pos, source, dkind, d);
            simpleDiag.setFlag(DiagnosticFlag.COMPRESSED);
            return simpleDiag;
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:Resolve.java

示例12: importNamedStatic

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; //导入依赖的package包/类
/** Import statics types of a given name.  Non-types are handled in Attr.
 *  @param imp           The import that is being handled.
 *  @param tsym          The class from which the name is imported.
 *  @param name          The (simple) name being imported.
 *  @param env           The environment containing the named import
 *                  scope to add to.
 */
private void importNamedStatic(final JCImport imp,
                               final TypeSymbol tsym,
                               final Name name,
                               final Env<AttrContext> env) {
    if (tsym.kind != TYP) {
        log.error(DiagnosticFlag.RECOVERABLE, imp.pos(), Errors.StaticImpOnlyClassesAndInterfaces);
        return;
    }

    final NamedImportScope toScope = env.toplevel.namedImportScope;
    final Scope originMembers = tsym.members();

    imp.importScope = toScope.importByName(types, originMembers, name, staticImportFilter, imp, cfHandler);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:TypeEnter.java

示例13: printMessage

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; //导入依赖的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

示例14: report

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; //导入依赖的package包/类
public void report(JCDiagnostic diag) {
    if (!diag.isFlagSet(JCDiagnostic.DiagnosticFlag.NON_DEFERRABLE) &&
        (filter == null || filter.accepts(diag))) {
        deferred.add(diag);
    } else {
        prev.report(diag);
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:9,代码来源:Log.java

示例15: importNamedStatic

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; //导入依赖的package包/类
/** Import statics types of a given name.  Non-types are handled in Attr.
 *  @param imp           The import that is being handled.
 *  @param tsym          The class from which the name is imported.
 *  @param name          The (simple) name being imported.
 *  @param env           The environment containing the named import
 *                  scope to add to.
 */
private void importNamedStatic(final JCImport imp,
                               final TypeSymbol tsym,
                               final Name name,
                               final Env<AttrContext> env) {
    if (tsym.kind != TYP) {
        log.error(DiagnosticFlag.RECOVERABLE, imp.pos(), "static.imp.only.classes.and.interfaces");
        return;
    }

    final NamedImportScope toScope = env.toplevel.namedImportScope;
    final Scope originMembers = tsym.members();

    imp.importScope = toScope.importByName(types, originMembers, name, staticImportFilter, imp, cfHandler);
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:22,代码来源:TypeEnter.java


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