本文整理汇总了Java中com.sun.tools.javac.util.JCDiagnostic.getArgs方法的典型用法代码示例。如果您正苦于以下问题:Java JCDiagnostic.getArgs方法的具体用法?Java JCDiagnostic.getArgs怎么用?Java JCDiagnostic.getArgs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.util.JCDiagnostic
的用法示例。
在下文中一共展示了JCDiagnostic.getArgs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNestedDiagnostics
import com.sun.tools.javac.util.JCDiagnostic; //导入方法依赖的package包/类
private static void getNestedDiagnostics(Diagnostic<?> d, List<Diagnostic> diags) {
JCDiagnostic jcd = getJCDiagnostic(d);
if (jcd == null) {
return;
}
Object[] args = jcd.getArgs();
if (args == null || args.length == 0) {
return;
}
for (Object o : args) {
if (o instanceof Diagnostic) {
diags.add((Diagnostic)o);
getNestedDiagnostics((Diagnostic)o, diags);
break;
}
}
}
示例2: getDiagnosticParam
import com.sun.tools.javac.util.JCDiagnostic; //导入方法依赖的package包/类
/**
* Extracts diagnostic params from a diagnostic. Gets under hood of Javac
* Diagnostic objects and extracts parameters which are otherwise just used
* to produce a message. <b>Keep in mind that the positions and types of parameters
* may change in each nbjavac update!</b>
* @param d diagnostic
* @param index parameter index to extract
* @return parameter value, null if index is out of range
*/
public static Object getDiagnosticParam(Diagnostic<?> d, int index) {
JCDiagnostic jcd = getJCDiagnostic(d);
if (jcd == null) {
return null;
}
Object[] args = jcd.getArgs();
if (args == null || args.length <= index) {
return null;
}
return args[index];
}
示例3: getSig
import com.sun.tools.javac.util.JCDiagnostic; //导入方法依赖的package包/类
MethodType getSig(Diagnostic<? extends JavaFileObject> diagnostic) {
JCDiagnostic details = (JCDiagnostic)asJCDiagnostic(diagnostic).getArgs()[2];
if (details == null) {
return null;
} else if (details instanceof JCDiagnostic) {
return details.getCode().equals("compiler.misc.full.inst.sig") ?
(MethodType)details.getArgs()[0] : null;
} else {
throw new AssertionError("Bad diagnostic arg: " + details);
}
}
示例4: scanForKeys
import com.sun.tools.javac.util.JCDiagnostic; //导入方法依赖的package包/类
/**
* Scan a diagnostic for resource keys. This will not detect additional
* sub diagnostics that might be generated by a rich diagnostic formatter.
*/
private static void scanForKeys(JCDiagnostic d, Set<String> keys) {
keys.add(d.getCode());
for (Object o: d.getArgs()) {
if (o instanceof JCDiagnostic) {
scanForKeys((JCDiagnostic) o, keys);
}
}
for (JCDiagnostic sd: d.getSubdiagnostics())
scanForKeys(sd, keys);
}