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


Java Kind类代码示例

本文整理汇总了Java中javax.tools.JavaFileObject.Kind的典型用法代码示例。如果您正苦于以下问题:Java Kind类的具体用法?Java Kind怎么用?Java Kind使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Kind类属于javax.tools.JavaFileObject包,在下文中一共展示了Kind类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: list

import javax.tools.JavaFileObject.Kind; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER)
public Iterable<JavaFileObject> list(Location location,
                                     String packageName,
                                     Set<Kind> kinds,
                                     boolean recurse) throws IOException {
    // TODO: Do this lazily by returning an iterable with a filtering Iterator
    // Acquire the list of files.
    Iterable<JavaFileObject> files = super.list(location, packageName, kinds, recurse);
    if (visibleSources.isEmpty()) {
        return locWrapMany(files, location);
    }
    // Now filter!
    ListBuffer<JavaFileObject> filteredFiles = new ListBuffer<>();
    for (JavaFileObject f : files) {
        URI uri = f.toUri();
        String t = uri.toString();
        if (t.startsWith("jar:")
            || t.endsWith(".class")
            || visibleSources.contains(uri)) {
            filteredFiles.add(f);
        }
    }

    return locWrapMany(filteredFiles, location);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:SmartFileManager.java

示例2: getJavaFileForInput

import javax.tools.JavaFileObject.Kind; //导入依赖的package包/类
@Override
public JavaFileObject getJavaFileForInput(Location l, String className, Kind kind) {
    if (kind == JavaFileObject.Kind.CLASS) {
        int dot = className.lastIndexOf('.');
        String dir = dot == -1 ? "" : FileObjects.convertPackage2Folder(className.substring(0, dot));
        javax.tools.FileObject fo = tx.readFileObject(l, dir, className.substring(dot + 1));
        if (fo != null) {
            return (JavaFileObject)fo;
        }
    }
    if (!ModuleLocation.isInstance(l)) {
        //File in output
        return super.getJavaFileForInput(l, className, kind);
    } else {
        //File in module
        return getJavaFileForInputImpl(
                ModuleLocation.WithExcludes.cast(l).getModuleEntries(),
                className,
                kind
        );
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:OutputFileManager.java

示例3: list

import javax.tools.JavaFileObject.Kind; //导入依赖的package包/类
@Override
public Iterable<JavaFileObject> list(Location location,
        String packageName, Set<Kind> kinds, boolean recurse)
        throws IOException {
    // validatePackageName(packageName);
    nullCheck(packageName);
    nullCheck(kinds);

    Iterable<? extends Path> paths = getLocation(location);
    if (paths == null)
        return List.nil();
    ListBuffer<JavaFileObject> results = new ListBuffer<JavaFileObject>();

    for (Path path : paths)
        list(path, packageName, kinds, recurse, results);

    return results.toList();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:JavacPathFileManager.java

示例4: getJavaFileForInput

import javax.tools.JavaFileObject.Kind; //导入依赖的package包/类
@Override
public JavaFileObject getJavaFileForInput(Location location,
                                          String className,
                                          Kind kind)
    throws IOException
{
    JavaFileObject file = super.getJavaFileForInput(location, className, kind);
    if (file == null || visibleSources.isEmpty()) {
        return file;
    }

    if (visibleSources.contains(file.toUri())) {
        return file;
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:SmartFileManager.java

示例5: getJavaFileForOutput

import javax.tools.JavaFileObject.Kind; //导入依赖的package包/类
@Override
public JavaFileObject getJavaFileForOutput(Location location,
                                           String className,
                                           Kind kind,
                                           FileObject sibling)
    throws IOException
{
    JavaFileObject file = super.getJavaFileForOutput(location, className, kind, sibling);
    if (file == null) return file;
    int dp = className.lastIndexOf('.');
    String pkg_name = "";
    if (dp != -1) {
        pkg_name = className.substring(0, dp);
    }
    // When modules are in use, then the mod_name might be something like "jdk_base"
    String mod_name = "";
    addArtifact(mod_name+":"+pkg_name, file.toUri());
    return file;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:SmartFileManager.java

示例6: getJavaFileForOutput

import javax.tools.JavaFileObject.Kind; //导入依赖的package包/类
@Override
public JavaFileObject getJavaFileForOutput(
		final Location location,
		final String className,
		final Kind kind,
		final FileObject sibling)
		throws IOException {
	
	final URI uri = createUri(location, className, kind);
	
	if (!files.containsKey(uri)) {
		files.put(uri, new InMemoryJavaFileObject(uri));
	}
	
	return files.get(uri);
}
 
开发者ID:MatthewTamlin,项目名称:Avatar,代码行数:17,代码来源:InMemoryJavaFileManager.java

示例7: findSingleModule

import javax.tools.JavaFileObject.Kind; //导入依赖的package包/类
public ModuleSymbol findSingleModule() {
    try {
        JavaFileObject src_fo = getModuleInfoFromLocation(StandardLocation.SOURCE_PATH, Kind.SOURCE);
        JavaFileObject class_fo = getModuleInfoFromLocation(StandardLocation.CLASS_OUTPUT, Kind.CLASS);
        JavaFileObject fo = (src_fo == null) ? class_fo
                : (class_fo == null) ? src_fo
                        : classFinder.preferredFileObject(src_fo, class_fo);

        ModuleSymbol msym;
        if (fo == null) {
            msym = syms.unnamedModule;
        } else {
            msym = readModule(fo);
        }

        if (msym.patchLocation == null) {
            msym.classLocation = StandardLocation.CLASS_OUTPUT;
        } else {
            msym.patchOutputLocation = StandardLocation.CLASS_OUTPUT;
        }
        return msym;

    } catch (IOException e) {
        throw new Error(e); // FIXME
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ModuleFinder.java

示例8: list

import javax.tools.JavaFileObject.Kind; //导入依赖的package包/类
@Override
public Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse) throws IOException {
    if (location != StandardLocation.PLATFORM_CLASS_PATH || !kinds.contains(Kind.CLASS))
        return Collections.emptyList();

    if (!packageName.isEmpty())
        packageName += ".";

    List<JavaFileObject> result = new ArrayList<>();

    for (Entry<String, JavaFileObject> e : className2File.entrySet()) {
        String currentPackage = e.getKey().substring(0, e.getKey().lastIndexOf(".") + 1);
        if (recurse ? currentPackage.startsWith(packageName) : packageName.equals(currentPackage))
            result.add(e.getValue());
    }

    return result;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:ElementStructureTest.java

示例9: visitTopLevel

import javax.tools.JavaFileObject.Kind; //导入依赖的package包/类
public void visitTopLevel(JCCompilationUnit node) {
    if (node.packge != null) {
        if (node.packge.package_info != null) {
            node.packge.package_info.reset();
        }
        node.packge.reset();
    }
    boolean isModuleInfo = node.sourcefile.isNameCompatible("module-info", Kind.SOURCE);
    if (isModuleInfo) {
        node.modle.reset();
        node.modle.completer = sym -> modules.enter(List.of(node), node.modle.module_info);
        node.modle.module_info.reset();
        node.modle.module_info.members_field = WriteableScope.create(node.modle.module_info);
    }
    node.packge = null;
    topLevel = node;
    try {
        super.visitTopLevel(node);
    } finally {
        topLevel = null;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:JavacProcessingEnvironment.java

示例10: testRejects

import javax.tools.JavaFileObject.Kind; //导入依赖的package包/类
@Test
public void testRejects(Path outerBase) throws Exception {
    doRunTest(outerBase, (base, fm) -> {
        assertRefused(() -> fm.getClassLoader(StandardLocation.MODULE_SOURCE_PATH));
        assertRefused(() -> fm.getFileForInput(StandardLocation.MODULE_SOURCE_PATH, "", ""));
        assertRefused(() -> fm.getFileForOutput(StandardLocation.MODULE_SOURCE_PATH, "", "", null));
        assertRefused(() -> fm.getJavaFileForInput(StandardLocation.MODULE_SOURCE_PATH, "", Kind.SOURCE));
        assertRefused(() -> fm.getJavaFileForOutput(StandardLocation.MODULE_SOURCE_PATH, "", Kind.SOURCE, null));
        assertRefused(() -> fm.getLocationForModule(StandardLocation.SOURCE_PATH, "test"));
        JavaFileObject out = fm.getJavaFileForInput(StandardLocation.CLASS_OUTPUT, "test.Test", Kind.CLASS);
        assertRefused(() -> fm.inferBinaryName(StandardLocation.MODULE_PATH, out));
        assertRefused(() -> fm.inferModuleName(StandardLocation.MODULE_SOURCE_PATH));
        assertRefused(() -> fm.list(StandardLocation.MODULE_SOURCE_PATH, "test", EnumSet.allOf(Kind.class), false));
        assertRefused(() -> fm.listLocationsForModules(StandardLocation.SOURCE_PATH));
    });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:ModuleAndPackageLocations.java

示例11: list

import javax.tools.JavaFileObject.Kind; //导入依赖的package包/类
@Override
public Iterable<JavaFileObject> list(Location l, String packageName, Set<Kind> kinds, boolean recursive) {
    final Iterable<JavaFileObject> sr;
    if (!ModuleLocation.isInstance(l)) {
        //List output
        sr =  super.list(l, packageName, kinds, recursive);
    } else {
        //List module
        final ModuleLocation.WithExcludes ml = ModuleLocation.WithExcludes.cast(l);
        sr = listImpl(l, ml.getModuleEntries(), packageName, kinds, recursive);
    }
    return tx.filter(l, packageName, sr);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:OutputFileManager.java

示例12: list

import javax.tools.JavaFileObject.Kind; //导入依赖的package包/类
@Override
public Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds,
        boolean recurse) throws IOException {
    List<JavaFileObject> result = new ArrayList<>();
    for (JavaFileObject jfo : super.list(location, packageName, kinds, recurse)) {
        result.add(new OnlyOneReadJavaFileObject(jfo));
    }
    return result;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:BaseClassesNotReRead.java

示例13: getJavaFileForOutput

import javax.tools.JavaFileObject.Kind; //导入依赖的package包/类
@Override
public JavaFileObject getJavaFileForOutput (Location l, String className, JavaFileObject.Kind kind, javax.tools.FileObject sibling)
    throws IOException, UnsupportedOperationException, IllegalArgumentException {
    URL aptRoot = getAptRoot(sibling);
    if (ModuleLocation.isInstance(l)) {
        ModuleLocation mloc = ModuleLocation.cast(l);
        l = mloc.getBaseLocation();
        if (aptRoot == null) {
            final Iterator<? extends URL> it = mloc.getModuleRoots().iterator();
            aptRoot = it.hasNext() ? it.next() : null;
        } else if (!mloc.getModuleRoots().contains(aptRoot)) {
            throw new UnsupportedOperationException("ModuleLocation's APT root differs from the sibling's APT root");
        }
    }
    final Location location = l;
    if (StandardLocation.SOURCE_OUTPUT != location) {
        throw new UnsupportedOperationException("Only apt output is supported."); // NOI18N
    }
    if (aptRoot == null) {
        throw new UnsupportedOperationException(noAptRootDebug(sibling));
    }
    final String nameStr = className.replace('.', File.separatorChar) + kind.extension;    //NOI18N
    //Always on master fs -> file is save.
    return Optional.ofNullable(URLMapper.findFileObject(aptRoot))
            .map(fo -> {
                File f = FileUtil.toFile(fo);
                return fileTx.createFileObject(location, new File(f, nameStr), f, null, null);
            }).get();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:AptSourceFileManager.java

示例14: generateSource

import javax.tools.JavaFileObject.Kind; //导入依赖的package包/类
private void generateSource(String name, String code) {
    Filer filer = processingEnv.getFiler();
    try (Writer out = filer.createSourceFile(name).openWriter()) {
        out.write(code);
        out.close();
    } catch (IOException e) {
        processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, e.toString());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:BaseClassesNotReRead.java

示例15: testBadFileManager

import javax.tools.JavaFileObject.Kind; //导入依赖的package包/类
/**
 * Verify that exceptions from a bad file manager are thrown as expected.
 */
@Test
public void testBadFileManager() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    StandardJavaFileManager fm = new TestFileManager() {
        @Override
        public Iterable<JavaFileObject> list(Location location,
                String packageName,
                Set<Kind> kinds,
                boolean recurse)
                throws IOException {
            throw new UnexpectedError();
        }
    };
    fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(getOutDir()));
    Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
    try {
        t.call();
        error("call completed without exception");
    } catch (RuntimeException e) {
        Throwable c = e.getCause();
        if (c.getClass() == UnexpectedError.class)
            System.err.println("exception caught as expected: " + c);
        else
            throw e;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:GetTask_FileManagerTest.java


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