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


Java Kind.SOURCE屬性代碼示例

本文整理匯總了Java中javax.tools.JavaFileObject.Kind.SOURCE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Kind.SOURCE屬性的具體用法?Java Kind.SOURCE怎麽用?Java Kind.SOURCE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.tools.JavaFileObject.Kind的用法示例。


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

示例1: compileDependencyClass

@BeforeClass
public static void compileDependencyClass() throws IOException, ClassNotFoundException {
  JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
  Assume.assumeNotNull(javaCompiler);

  classes = temporaryFolder.newFolder("classes");;

  StandardJavaFileManager fileManager = javaCompiler.getStandardFileManager(null, Locale.ROOT, UTF_8);
  fileManager.setLocation(StandardLocation.CLASS_OUTPUT, ImmutableList.of(classes));

  SimpleJavaFileObject compilationUnit = new SimpleJavaFileObject(URI.create("FooTest.java"), Kind.SOURCE) {
    String fooTestSource = Resources.toString(Resources.getResource("com/dremio/exec/compile/FooTest.java"), UTF_8);
    @Override
    public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
      return fooTestSource;
    }
  };

  CompilationTask task = javaCompiler.getTask(null, fileManager, null, Collections.<String>emptyList(), null, ImmutableList.of(compilationUnit));
  assertTrue(task.call());
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:21,代碼來源:TestClassCompilers.java

示例2: getKind

public static Kind getKind(String name) {
    if (name.endsWith(Kind.CLASS.extension))
        return Kind.CLASS;
    else if (name.endsWith(Kind.SOURCE.extension))
        return Kind.SOURCE;
    else if (name.endsWith(Kind.HTML.extension))
        return Kind.HTML;
    else
        return Kind.OTHER;
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:10,代碼來源:BaseFileManager.java

示例3: visitExports

@Override
public void visitExports(JCExports tree) {
    Iterable<Symbol> packageContent = tree.directive.packge.members().getSymbols();
    List<JavaFileObject> filesToCheck = List.nil();
    boolean packageNotEmpty = false;
    for (Symbol sym : packageContent) {
        if (sym.kind != Kinds.Kind.TYP)
            continue;
        ClassSymbol csym = (ClassSymbol) sym;
        if (sym.completer.isTerminal() ||
            csym.classfile.getKind() == Kind.CLASS) {
            packageNotEmpty = true;
            filesToCheck = List.nil();
            break;
        }
        if (csym.classfile.getKind() == Kind.SOURCE) {
            filesToCheck = filesToCheck.prepend(csym.classfile);
        }
    }
    for (JavaFileObject jfo : filesToCheck) {
        if (findPackageInFile.findPackageNameOf(jfo) == tree.directive.packge.fullname) {
            packageNotEmpty = true;
            break;
        }
    }
    if (!packageNotEmpty) {
        log.error(tree.qualid.pos(), Errors.PackageEmptyOrNotFound(tree.directive.packge));
    }
    msym.directives = msym.directives.prepend(tree.directive);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:30,代碼來源:Modules.java

示例4: verifyLambdaScopeCorrect

private static void verifyLambdaScopeCorrect(final String packageClause) throws Exception {
    JavacTool tool = JavacTool.create();
    JavaFileObject source = new SimpleJavaFileObject(URI.create("mem://Test.java"), Kind.SOURCE) {
        @Override public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
            return packageClause + SOURCE_CODE;
        }
        @Override public boolean isNameCompatible(String simpleName, Kind kind) {
            return !"module-info".equals(simpleName);
        }
    };
    Iterable<? extends JavaFileObject> fos = Collections.singletonList(source);
    JavacTask task = tool.getTask(null, null, null, new ArrayList<String>(), null, fos);
    final Types types = JavacTypes.instance(((JavacTaskImpl) task).getContext());
    final Trees trees = Trees.instance(task);
    CompilationUnitTree cu = task.parse().iterator().next();

    task.analyze();

    new TreePathScanner<Void, Void>() {
        @Override public Void visitMemberSelect(MemberSelectTree node, Void p) {
            if (node.getIdentifier().contentEquals("correct")) {
                TypeMirror xType = trees.getTypeMirror(new TreePath(getCurrentPath(), node.getExpression()));
                Scope scope = trees.getScope(getCurrentPath());
                for (Element l : scope.getLocalElements()) {
                    if (!l.getSimpleName().contentEquals("x")) continue;
                    if (!types.isSameType(xType, l.asType())) {
                        throw new IllegalStateException("Incorrect variable type in scope: " + l.asType() + "; should be: " + xType);
                    }
                }
            }
            return super.visitMemberSelect(node, p);
        }
    }.scan(cu, null);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:34,代碼來源:ScopeTest.java

示例5: JavaFileObjectImpl

public JavaFileObjectImpl(final String baseName, final CharSequence source){
    super(ClassUtils.toURI(baseName + ClassUtils.JAVA_EXTENSION), Kind.SOURCE);
    this.source = source;
}
 
開發者ID:dachengxi,項目名稱:EatDubbo,代碼行數:4,代碼來源:JdkCompiler.java

示例6: apply

@Override
public boolean apply(Kind input) {
  return input != Kind.SOURCE;
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:4,代碼來源:DrillJavaFileManager.java

示例7: JavaMemoryFileObject

JavaMemoryFileObject(String name, String code) {
  super(URI.create("string:///" + name.replace('.','/') + Kind.SOURCE.extension), Kind.SOURCE);
  this.code = code;
}
 
開發者ID:arodchen,項目名稱:MaxSim,代碼行數:4,代碼來源:SortMethodsTest.java

示例8: Source

Source(String name, String content) {
    super(name, Kind.SOURCE);
    this.content = content;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:4,代碼來源:MemoryClassLoader.java

示例9: list

Iterable<JavaFileObject> list(Location location,
                              PackageSymbol p,
                              String packageName,
                              Set<Kind> kinds) throws IOException {
    Iterable<JavaFileObject> listed = fileManager.list(location,
                                                       packageName,
                                                       EnumSet.allOf(Kind.class),
                                                       false);
    return () -> new Iterator<JavaFileObject>() {
        private final Iterator<JavaFileObject> original = listed.iterator();
        private JavaFileObject next;
        @Override
        public boolean hasNext() {
            if (next == null) {
                while (original.hasNext()) {
                    JavaFileObject fo = original.next();

                    if (fo.getKind() != Kind.CLASS &&
                        fo.getKind() != Kind.SOURCE &&
                        !isSigFile(currentLoc, fo)) {
                        p.flags_field |= Flags.HAS_RESOURCE;
                    }

                    if (kinds.contains(fo.getKind())) {
                        next = fo;
                        break;
                    }
                }
            }
            return next != null;
        }

        @Override
        public JavaFileObject next() {
            if (!hasNext())
                throw new NoSuchElementException();
            JavaFileObject result = next;
            next = null;
            return result;
        }

    };
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:43,代碼來源:ClassFinder.java

示例10: getFileKind

public Kind getFileKind(TypeElement te) {
    JavaFileObject jfo = ((ClassSymbol)te).outermostClass().classfile;
    return jfo == null ? Kind.SOURCE : jfo.getKind();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:4,代碼來源:ToolEnvironment.java

示例11: TestFO

public TestFO(URI uri, String content) {
    super(uri, Kind.SOURCE);
    this.content = content;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:4,代碼來源:Processor.java

示例12: JavaSourceFromString

/**
 * Constructs a new JavaSourceFromString.
 * @param name the name of the compilation unit represented by this file object
 * @param code the source code for the compilation unit represented by this file object
 */
JavaSourceFromString(String name, String code) {
    super(uriFromString("mfm:///" + name.replace('.','/') + Kind.SOURCE.extension),
          Kind.SOURCE);
    this.code = code;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:MemoryFileManager.java

示例13: MemoryJavaFileObject

public MemoryJavaFileObject(String className, CharSequence sourceCode) {
    super(URI.create("string:///" + className.replace('.','/') + Kind.SOURCE.extension), Kind.SOURCE);
    this.className = className;
    this.sourceCode = sourceCode;
    this.byteCode = new ByteArrayOutputStream();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:6,代碼來源:InMemoryJavaCompiler.java


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