當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。