本文整理汇总了Java中com.sun.tools.javac.comp.Resolve.MethodResolutionDiagHelper.DiagnosticRewriter类的典型用法代码示例。如果您正苦于以下问题:Java DiagnosticRewriter类的具体用法?Java DiagnosticRewriter怎么用?Java DiagnosticRewriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DiagnosticRewriter类属于com.sun.tools.javac.comp.Resolve.MethodResolutionDiagHelper包,在下文中一共展示了DiagnosticRewriter类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDiagnostic
import com.sun.tools.javac.comp.Resolve.MethodResolutionDiagHelper.DiagnosticRewriter; //导入依赖的package包/类
@Override
JCDiagnostic getDiagnostic(JCDiagnostic.DiagnosticType dkind,
DiagnosticPosition pos,
Symbol location,
Type site,
Name name,
List<Type> argtypes,
List<Type> typeargtypes) {
if (name == names.error)
return null;
if (syms.operatorNames.contains(name)) {
boolean isUnaryOp = argtypes.size() == 1;
String key = argtypes.size() == 1 ?
"operator.cant.be.applied" :
"operator.cant.be.applied.1";
Type first = argtypes.head;
Type second = !isUnaryOp ? argtypes.tail.head : null;
return diags.create(dkind, log.currentSource(), pos,
key, name, first, second);
}
else {
Pair<Symbol, JCDiagnostic> c = errCandidate();
if (compactMethodDiags) {
for (Map.Entry<Template, DiagnosticRewriter> _entry :
MethodResolutionDiagHelper.rewriters.entrySet()) {
if (_entry.getKey().matches(c.snd)) {
JCDiagnostic simpleDiag =
_entry.getValue().rewriteDiagnostic(diags, pos,
log.currentSource(), dkind, c.snd);
simpleDiag.setFlag(DiagnosticFlag.COMPRESSED);
return simpleDiag;
}
}
}
Symbol ws = c.fst.asMemberOf(site, types);
return diags.create(dkind, log.currentSource(), pos,
"cant.apply.symbol",
kindName(ws),
ws.name == names.init ? ws.owner.name : ws.name,
methodArguments(ws.type.getParameterTypes()),
methodArguments(argtypes),
kindName(ws.owner),
ws.owner.type,
c.snd);
}
}