当前位置: 首页>>代码示例>>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;未经允许,请勿转载。