本文整理汇总了Java中com.sun.tools.javac.api.ClientCodeWrapper类的典型用法代码示例。如果您正苦于以下问题:Java ClientCodeWrapper类的具体用法?Java ClientCodeWrapper怎么用?Java ClientCodeWrapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClientCodeWrapper类属于com.sun.tools.javac.api包,在下文中一共展示了ClientCodeWrapper类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: position
import com.sun.tools.javac.api.ClientCodeWrapper; //导入依赖的package包/类
private static Range position(javax.tools.Diagnostic<? extends JavaFileObject> error) {
if (error instanceof ClientCodeWrapper.DiagnosticSourceUnwrapper)
error = ((ClientCodeWrapper.DiagnosticSourceUnwrapper) error).d;
JCDiagnostic diagnostic = (JCDiagnostic) error;
DiagnosticSource source = diagnostic.getDiagnosticSource();
long start = error.getStartPosition(), end = error.getEndPosition();
if (end == start) end = start + 1;
return new Range(
new Position(
source.getLineNumber((int) start) - 1,
source.getColumnNumber((int) start, true) - 1),
new Position(
source.getLineNumber((int) end) - 1,
source.getColumnNumber((int) end, true) - 1));
}
示例2: report
import com.sun.tools.javac.api.ClientCodeWrapper; //导入依赖的package包/类
public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
try {
if (diagnostic.getKind() == Diagnostic.Kind.ERROR &&
diagnostic.getCode().equals("compiler.err.ref.ambiguous")) {
ambiguityFound = true;
} else if (diagnostic.getKind() == Diagnostic.Kind.NOTE &&
diagnostic.getCode()
.equals("compiler.note.verbose.resolve.multi")) {
ClientCodeWrapper.DiagnosticSourceUnwrapper dsu =
(ClientCodeWrapper.DiagnosticSourceUnwrapper)diagnostic;
JCDiagnostic.MultilineDiagnostic mdiag =
(JCDiagnostic.MultilineDiagnostic)dsu.d;
int mostSpecificIndex = (Integer)mdiag.getArgs()[2];
mostSpecificSig =
((JCDiagnostic)mdiag.getSubdiagnostics()
.get(mostSpecificIndex)).getArgs()[1].toString();
}
} catch (RuntimeException t) {
t.printStackTrace();
throw t;
}
}
示例3: mostSpecificSignature
import com.sun.tools.javac.api.ClientCodeWrapper; //导入依赖的package包/类
String mostSpecificSignature(Result<Iterable<? extends Element>> result) {
List<Diagnostic<? extends JavaFileObject>> rsDiag =
result.diagnosticsForKey("compiler.note.verbose.resolve.multi");
if (rsDiag.nonEmpty()) {
ClientCodeWrapper.DiagnosticSourceUnwrapper dsu =
(ClientCodeWrapper.DiagnosticSourceUnwrapper)rsDiag.head;
JCDiagnostic.MultilineDiagnostic mdiag =
(JCDiagnostic.MultilineDiagnostic)dsu.d;
int mostSpecificIndex = (Integer)mdiag.getArgs()[2];
return mdiag.getSubdiagnostics().get(mostSpecificIndex).getArgs()[1].toString();
} else {
return null;
}
}
示例4: check
import com.sun.tools.javac.api.ClientCodeWrapper; //导入依赖的package包/类
void check(Result<?> res) {
DiagnosticKind diag = null;
boolean altMetafactory = false;
for (DiagnosticKind dk : DiagnosticKind.values()) {
List<Diagnostic<? extends JavaFileObject>> jcDiag = res.diagnosticsForKey(dk.code);
if (jcDiag.nonEmpty()) {
diag = dk;
ClientCodeWrapper.DiagnosticSourceUnwrapper dsu =
(ClientCodeWrapper.DiagnosticSourceUnwrapper)jcDiag.head;
altMetafactory = (Boolean)dsu.d.getArgs()[0];
break;
}
}
if (diag == null) {
fail("No diagnostic found; " + res.compilationInfo());
}
boolean error = diag.lambda !=
(ek == ExprKind.LAMBDA);
error |= diag.bridge !=
(ek == ExprKind.MREF2);
error |= altMetafactory !=
(tk == TargetKind.SERIALIZABLE);
if (error) {
fail("Bad stat diagnostic found for source\n" +
"lambda = " + diag.lambda + "\n" +
"bridge = " + diag.bridge + "\n" +
"altMF = " + altMetafactory + "\n" +
res.compilationInfo());
}
}
示例5: unwrap
import com.sun.tools.javac.api.ClientCodeWrapper; //导入依赖的package包/类
private JCDiagnostic unwrap(Diagnostic<? extends JavaFileObject> diagnostic) {
if (diagnostic instanceof JCDiagnostic)
return (JCDiagnostic) diagnostic;
if (diagnostic instanceof ClientCodeWrapper.DiagnosticSourceUnwrapper)
return ((ClientCodeWrapper.DiagnosticSourceUnwrapper)diagnostic).d;
throw new IllegalArgumentException();
}
示例6: report
import com.sun.tools.javac.api.ClientCodeWrapper; //导入依赖的package包/类
public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
try {
if (diagnostic.getKind() == Diagnostic.Kind.NOTE) {
switch (diagnostic.getCode()) {
case "compiler.note.lambda.stat":
lambda = true;
break;
case "compiler.note.mref.stat":
lambda = false;
bridge = false;
break;
case "compiler.note.mref.stat.1":
lambda = false;
bridge = true;
break;
default:
throw new AssertionError("unexpected note: " + diagnostic.getCode());
}
ClientCodeWrapper.DiagnosticSourceUnwrapper dsu =
(ClientCodeWrapper.DiagnosticSourceUnwrapper)diagnostic;
altMetafactory = (Boolean)dsu.d.getArgs()[0];
}
} catch (RuntimeException t) {
t.printStackTrace();
throw t;
}
}
示例7: getTask
import com.sun.tools.javac.api.ClientCodeWrapper; //导入依赖的package包/类
public DocumentationTask getTask(
Writer out,
JavaFileManager fileManager,
DiagnosticListener<? super JavaFileObject> diagnosticListener,
Class<?> docletClass,
Iterable<String> options,
Iterable<? extends JavaFileObject> compilationUnits,
Context context) {
try {
ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);
if (options != null) {
for (String option : options)
option.getClass(); // null check
}
if (compilationUnits != null) {
compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check
for (JavaFileObject cu : compilationUnits) {
if (cu.getKind() != JavaFileObject.Kind.SOURCE) {
final String kindMsg = "All compilation units must be of SOURCE kind";
throw new IllegalArgumentException(kindMsg);
}
}
}
if (diagnosticListener != null)
context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));
if (out == null)
context.put(Log.outKey, new PrintWriter(System.err, true));
else if (out instanceof PrintWriter)
context.put(Log.outKey, ((PrintWriter) out));
else
context.put(Log.outKey, new PrintWriter(out, true));
if (fileManager == null)
fileManager = getStandardFileManager(diagnosticListener, null, null);
fileManager = ccw.wrap(fileManager);
context.put(JavaFileManager.class, fileManager);
return new JavadocTaskImpl(context, docletClass, options, compilationUnits);
} catch (ClientCodeException ex) {
throw new RuntimeException(ex.getCause());
}
}
示例8: getTask
import com.sun.tools.javac.api.ClientCodeWrapper; //导入依赖的package包/类
public DocumentationTask getTask(
Writer out,
JavaFileManager fileManager,
DiagnosticListener<? super JavaFileObject> diagnosticListener,
Class<?> docletClass,
Iterable<String> options,
Iterable<? extends JavaFileObject> compilationUnits,
Context context) {
try {
ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);
if (options != null) {
for (String option : options)
Objects.requireNonNull(option);
}
if (compilationUnits != null) {
compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check
for (JavaFileObject cu : compilationUnits) {
if (cu.getKind() != JavaFileObject.Kind.SOURCE) {
final String kindMsg = "All compilation units must be of SOURCE kind";
throw new IllegalArgumentException(kindMsg);
}
}
}
if (diagnosticListener != null)
context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));
if (out == null)
context.put(Log.errKey, new PrintWriter(System.err, true));
else if (out instanceof PrintWriter)
context.put(Log.errKey, ((PrintWriter) out));
else
context.put(Log.errKey, new PrintWriter(out, true));
if (fileManager == null) {
fileManager = getStandardFileManager(diagnosticListener, null, null);
if (fileManager instanceof BaseFileManager) {
((BaseFileManager) fileManager).autoClose = true;
}
}
fileManager = ccw.wrap(fileManager);
context.put(JavaFileManager.class, fileManager);
return new JavadocTaskImpl(context, docletClass, options, compilationUnits);
} catch (ClientCodeException ex) {
throw new RuntimeException(ex.getCause());
}
}
示例9: getTask
import com.sun.tools.javac.api.ClientCodeWrapper; //导入依赖的package包/类
public DocumentationTask getTask(
Writer out,
JavaFileManager fileManager,
DiagnosticListener<? super JavaFileObject> diagnosticListener,
Class<?> docletClass,
Iterable<String> options,
Iterable<? extends JavaFileObject> compilationUnits,
Context context) {
try {
ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);
if (options != null) {
for (String option : options)
Objects.requireNonNull(option);
}
if (compilationUnits != null) {
compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check
for (JavaFileObject cu : compilationUnits) {
if (cu.getKind() != JavaFileObject.Kind.SOURCE) {
final String kindMsg = "All compilation units must be of SOURCE kind";
throw new IllegalArgumentException(kindMsg);
}
}
}
if (diagnosticListener != null)
context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));
if (out == null)
context.put(Log.outKey, new PrintWriter(System.err, true));
else if (out instanceof PrintWriter)
context.put(Log.outKey, ((PrintWriter) out));
else
context.put(Log.outKey, new PrintWriter(out, true));
if (fileManager == null) {
fileManager = getStandardFileManager(diagnosticListener, null, null);
if (fileManager instanceof BaseFileManager) {
((BaseFileManager) fileManager).autoClose = true;
}
}
fileManager = ccw.wrap(fileManager);
context.put(JavaFileManager.class, fileManager);
return new JavadocTaskImpl(context, docletClass, options, compilationUnits);
} catch (ClientCodeException ex) {
throw new RuntimeException(ex.getCause());
}
}