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


Java ClientCodeWrapper类代码示例

本文整理汇总了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));
}
 
开发者ID:georgewfraser,项目名称:vscode-javac,代码行数:19,代码来源:Lints.java

示例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;
    }
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:23,代码来源:StructuralMostSpecificTest.java

示例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;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:StructuralMostSpecificTest.java

示例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());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:TestLambdaToMethodStats.java

示例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();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:TestSuppression.java

示例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;
    }
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:28,代码来源:TestLambdaToMethodStats.java

示例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());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:47,代码来源:JavadocTool.java

示例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());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:51,代码来源:JavadocTool.java

示例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());
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:51,代码来源:JavadocTool.java


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