本文整理汇总了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());
}
示例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());
}
示例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;
}
}
}
示例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));
}
}
}
}
示例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);
}
}
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}