當前位置: 首頁>>代碼示例>>Java>>正文


Java QualifiedNames類代碼示例

本文整理匯總了Java中jdk.jshell.SourceCodeAnalysis.QualifiedNames的典型用法代碼示例。如果您正苦於以下問題:Java QualifiedNames類的具體用法?Java QualifiedNames怎麽用?Java QualifiedNames使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


QualifiedNames類屬於jdk.jshell.SourceCodeAnalysis包,在下文中一共展示了QualifiedNames類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: assertInferredFQNs

import jdk.jshell.SourceCodeAnalysis.QualifiedNames; //導入依賴的package包/類
public void assertInferredFQNs(String code, int simpleNameLen, boolean resolvable, String... fqns) {
    waitIndexingFinished();

    QualifiedNames candidates = getAnalysis().listQualifiedNames(code, code.length());

    assertEquals(candidates.getNames(), Arrays.asList(fqns), "Input: " + code + ", candidates=" + candidates.getNames());
    assertEquals(candidates.getSimpleNameLength(), simpleNameLen, "Input: " + code + ", simpleNameLen=" + candidates.getSimpleNameLength());
    assertEquals(candidates.isResolvable(), resolvable, "Input: " + code + ", resolvable=" + candidates.isResolvable());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:KullaTesting.java

示例2: compute

import jdk.jshell.SourceCodeAnalysis.QualifiedNames; //導入依賴的package包/類
@Override
public FixResult compute(JShellTool repl, String code, int cursor) {
    QualifiedNames res = repl.analysis.listQualifiedNames(code, cursor);
    List<Fix> fixes = new ArrayList<>();
    for (String fqn : res.getNames()) {
        fixes.add(new Fix() {
            @Override
            public String displayName() {
                return "import: " + fqn;
            }
            @Override
            public void perform(ConsoleReader in) throws IOException {
                repl.state.eval("import " + fqn + ";");
                in.println("Imported: " + fqn);
                in.redrawLine();
            }
        });
    }
    if (res.isResolvable()) {
        return new FixResult(Collections.emptyList(),
                repl.messageFormat("jshell.console.resolvable"));
    } else {
        String error = "";
        if (fixes.isEmpty()) {
            error = repl.messageFormat("jshell.console.no.candidate");
        }
        if (!res.isUpToDate()) {
            error += repl.messageFormat("jshell.console.incomplete");
        }
        return new FixResult(fixes, error);
    }
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:33,代碼來源:ConsoleIOContext.java

示例3: compute

import jdk.jshell.SourceCodeAnalysis.QualifiedNames; //導入依賴的package包/類
@Override
public FixResult compute(TryJShellTool repl, String code, int cursor) {
    QualifiedNames res = repl.analysis.listQualifiedNames(code, cursor);
    List<Fix> fixes = new ArrayList<>();
    for (String fqn : res.getNames()) {
        fixes.add(new Fix() {
            @Override
            public String displayName() {
                return "import: " + fqn;
            }
            @Override
            public void perform(ConsoleReader in) throws IOException {
                repl.state.eval("import " + fqn + ";");
                in.println("Imported: " + fqn);
                in.redrawLine();
            }
        });
    }
    if (res.isResolvable()) {
        return new FixResult(Collections.emptyList(),
                "\nThe identifier is resolvable in this context.");
    } else {
        String error = "";
        if (fixes.isEmpty()) {
            error = "\nNo candidate fully qualified names found to import.";
        }
        if (!res.isUpToDate()) {
            error += "\nResults may be incomplete; try again later for complete results.";
        }
        return new FixResult(fixes, error);
    }
}
 
開發者ID:kawasima,項目名稱:try-artifact,代碼行數:33,代碼來源:ConsoleIOContext.java

示例4: testSuspendIndexing

import jdk.jshell.SourceCodeAnalysis.QualifiedNames; //導入依賴的package包/類
@Test(enabled = false) //JDK-8150860
public void testSuspendIndexing() throws Exception {
    compiler.compile(outDir, "package test; public class FQNTest { }");
    String jarName = "test.jar";
    compiler.jar(outDir, jarName, "test/FQNTest.class");
    Path continueMarkFile = outDir.resolve("continuemark").toAbsolutePath();
    Files.createDirectories(continueMarkFile.getParent());
    try (Writer w = Files.newBufferedWriter(continueMarkFile)) {}

    Path runMarkFile = outDir.resolve("runmark").toAbsolutePath();
    Files.deleteIfExists(runMarkFile);

    getState().sourceCodeAnalysis();

    new Thread() {
        @Override public void run() {
            assertEval("{new java.io.FileOutputStream(\"" + runMarkFile.toAbsolutePath().toString() + "\").close();" +
                       " while (java.nio.file.Files.exists(java.nio.file.Paths.get(\"" + continueMarkFile.toString() + "\"))) Thread.sleep(100); }");
        }
    }.start();

    while (!Files.exists(runMarkFile))
        Thread.sleep(100);

    addToClasspath(compiler.getPath(outDir).resolve(jarName));

    String code = "FQNTest";

    QualifiedNames candidates = getAnalysis().listQualifiedNames(code, code.length());

    assertEquals(candidates.getNames(), Arrays.asList(), "Input: " + code + ", candidates=" + candidates.getNames());
    assertEquals(candidates.isUpToDate(), false, "Input: " + code + ", up-to-date=" + candidates.isUpToDate());

    Files.delete(continueMarkFile);

    waitIndexingFinished();

    candidates = getAnalysis().listQualifiedNames(code, code.length());

    assertEquals(candidates.getNames(), Arrays.asList("test.FQNTest"), "Input: " + code + ", candidates=" + candidates.getNames());
    assertEquals(true, candidates.isUpToDate(), "Input: " + code + ", up-to-date=" + candidates.isUpToDate());
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:43,代碼來源:ComputeFQNsTest.java


注:本文中的jdk.jshell.SourceCodeAnalysis.QualifiedNames類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。