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


Java JavaFileObject.Kind方法代码示例

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


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

示例1: listModuleContent

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
@NonNull
private Iterable<JavaFileObject> listModuleContent(
        @NonNull final ModLoc modLoc,
        @NonNull final String packageName,
        @NonNull final Set<JavaFileObject.Kind> kinds) throws IOException {
    final CachingArchiveProvider cap = CachingArchiveProvider.getDefault();
    final Collection<JavaFileObject> res = new ArrayList<>();
    if (javaBaseModInfo != null && "java.base".equals(modLoc.getModuleName()) && packageName.isEmpty()) {
        final JavaFileObject jfo = new MemJFO("module-info");
        try(OutputStream out = jfo.openOutputStream()) {
            final byte[] data = javaBaseModInfo.get();
            out.write(data, 0, data.length);
        }
        res.add(jfo);
    }
    for (URL url : modLoc.getRoots()) {
        final Archive ca = cap.getArchive(url, false);
        if (ca != null) {
            StreamSupport.stream(
                    ca.getFiles(FileObjects.convertPackage2Folder(packageName), null, kinds, null, false).spliterator(),
                    false)
                    .forEach(res::add);
        }
    }
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ModuleNamesTest.java

示例2: getJavaFileForInput

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
/**
 */
public JavaFileObject getJavaFileForInput( Location location,
                                           String className,
                                           JavaFileObject.Kind kind )
  throws IOException
{
  return fileManager.getJavaFileForInput( location, className, kind );
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:10,代码来源:JavacFileManagerBridge.java

示例3: getJavaFileForInput

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
public JavaFileObject getJavaFileForInput(Location location,
                                          String className,
                                          JavaFileObject.Kind kind)
        throws IOException {
    nullCheck(location);
    // validateClassName(className);
    nullCheck(className);
    nullCheck(kind);
    if (!sourceOrClass.contains(kind))
        throw new IllegalArgumentException("Invalid kind: " + kind);
    return getFileForInput(location, RelativeFile.forClass(className, kind));
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:13,代码来源:JavacFileManager.java

示例4: getFileForOutput

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
public JavaFileObject getFileForOutput(String classname,
                                       JavaFileObject.Kind kind,
                                       JavaFileObject sibling)
    throws IOException
{
    return getJavaFileForOutput(CLASS_OUTPUT, classname, kind, sibling);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:JavacFileManager.java

示例5: listDirectory

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
/**
 * Insert all files in subdirectory subdirectory of directory directory
 * which match fileKinds into resultList
 */
private void listDirectory(File directory,
                           RelativeDirectory subdirectory,
                           Set<JavaFileObject.Kind> fileKinds,
                           boolean recurse,
                           ListBuffer<JavaFileObject> resultList) {
    File d = subdirectory.getFile(directory);
    if (!caseMapCheck(d, subdirectory))
        return;

    File[] files = d.listFiles();
    if (files == null)
        return;

    if (sortFiles != null)
        Arrays.sort(files, sortFiles);

    for (File f : files) {
        String fname = f.getName();
        if (f.isDirectory()) {
            if (recurse && SourceVersion.isIdentifier(fname)) {
                listDirectory(directory,
                        new RelativeDirectory(subdirectory, fname),
                        fileKinds,
                        recurse,
                        resultList);
            }
        } else {
            if (isValidFile(fname, fileKinds)) {
                JavaFileObject fe =
                        new RegularFileObject(this, fname, new File(d, fname));
                resultList.append(fe);
            }
        }
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:40,代码来源:JavacFileManager.java

示例6: list

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
/**
 * Insert all files in a subdirectory of the platform image
 * which match fileKinds into resultList.
 */
@Override
public void list(Path userPath,
                 RelativeDirectory subdirectory,
                 Set<JavaFileObject.Kind> fileKinds,
                 boolean recurse,
                 ListBuffer<JavaFileObject> resultList) throws IOException {
    try {
        JRTIndex.Entry e = getJRTIndex().getEntry(subdirectory);
        if (symbolFileEnabled && e.ctSym.hidden)
            return;
        for (Path file: e.files.values()) {
            if (fileKinds.contains(getKind(file))) {
                JavaFileObject fe
                        = PathFileObject.forJRTPath(JavacFileManager.this, file);
                resultList.append(fe);
            }
        }

        if (recurse) {
            for (RelativeDirectory rd: e.subdirs) {
                list(userPath, rd, fileKinds, recurse, resultList);
            }
        }
    } catch (IOException ex) {
        ex.printStackTrace(System.err);
        log.error(Errors.ErrorReadingFile(userPath, getMessage(ex)));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:JavacFileManager.java

示例7: getJavaFileForOutput

import javax.tools.JavaFileObject; //导入方法依赖的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

示例8: getJavaFileForOutput

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
@Override
public JavaFileObject getJavaFileForOutput(Location location, String className, JavaFileObject.Kind kind, javax.tools.FileObject sibling) throws IOException {
    assertLocation(location, true);
    final String[] ncs = FileObjects.getPackageAndName(className);
    return new MemOutFileObject(
            ncs[0],
            String.format("%s%s", ncs[1], kind.extension));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:JavaSourceUtilImpl.java

示例9: isNameCompatible

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
@Override
public boolean isNameCompatible(String cn, JavaFileObject.Kind kind) {
    cn.getClass();
    // null check
    if (kind == Kind.OTHER && getKind() != kind) {
        return false;
    }
    String n = cn + kind.extension;
    if (name.equals(n)) {
        return true;
    }
    if (isMacOS && Normalizer.isNormalized(name, Normalizer.Form.NFD)
        && Normalizer.isNormalized(n, Normalizer.Form.NFC)) {
        // On Mac OS X it is quite possible to file name and class
        // name normalized in a different way - in that case we have to normalize file name
        // to the Normal Form Compised (NFC)
        String normName = Normalizer.normalize(name, Normalizer.Form.NFC);
        if (normName.equals(n)) {
            this.name = normName;
            return true;
        }
    }

        if (name.equalsIgnoreCase(n)) {
        try {
            // allow for Windows
            return file.getCanonicalFile().getName().equals(n);
        } catch (IOException e) {
        }
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:RegularFileObject.java

示例10: getJavaFileForOutput

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
@Override @DefinedBy(Api.COMPILER)
public JavaFileObject getJavaFileForOutput(Location location,
                                           String className,
                                           JavaFileObject.Kind kind,
                                           FileObject sibling)
    throws IOException
{
    checkOutputLocation(location);
    // validateClassName(className);
    nullCheck(className);
    nullCheck(kind);
    if (!sourceOrClass.contains(kind))
        throw new IllegalArgumentException("Invalid kind: " + kind);
    return getFileForOutput(location, RelativeFile.forClass(className, kind), sibling);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:JavacFileManager.java

示例11: getJavaFileForInput

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
@Override
public JavaFileObject getJavaFileForInput(Location location,
                                          String className,
                                          JavaFileObject.Kind kind)
throws IOException {
    if (location == StandardLocation.SOURCE_PATH &&
        kind == JavaFileObject.Kind.SOURCE &&
        TEST_CLASS_NAME.equals(className)) {
        return new SourceFileObject(className, testSource);
    }
    return super.getJavaFileForInput(location, className, kind);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:PublicMethodsTest.java

示例12: getJavaFileForInput

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
@Override
public JavaFileObject getJavaFileForInput(Location location, String className, JavaFileObject.Kind kind) throws IOException {
    assertLocation(location, false);
    return readDelegate.getJavaFileForInput(location, className, kind);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:JavaSourceUtilImpl.java

示例13: getKind

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
@Override
public JavaFileObject.Kind getKind() {
    return this.kind;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:FileObjects.java

示例14: getPackageFileKinds

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
/**
 * specifies types of files to be read when filling in a package symbol
 */
protected EnumSet<JavaFileObject.Kind> getPackageFileKinds() {
    return EnumSet.of(JavaFileObject.Kind.CLASS, JavaFileObject.Kind.SOURCE);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:7,代码来源:ClassReader.java

示例15: isPkgInfo

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
private boolean isPkgInfo(JavaFileObject fo, JavaFileObject.Kind kind) {
    return fo.isNameCompatible("package-info", kind);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:4,代码来源:JavacProcessingEnvironment.java


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