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


Java StandardLocation.SOURCE_PATH属性代码示例

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


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

示例1: getFileForOutput

@Override
public javax.tools.FileObject getFileForOutput(final Location l, final String pkgName, final String relativeName, final javax.tools.FileObject sibling)
    throws IOException, UnsupportedOperationException, IllegalArgumentException {
    if (StandardLocation.SOURCE_PATH != l) {
        throw new UnsupportedOperationException("Only StandardLocation.SOURCE_PATH is supported."); // NOI18N
    }
    final String rp = FileObjects.resolveRelativePath (pkgName, relativeName);
    final FileObject[] fileRootPair = findFile(rp);
    if (fileRootPair == null) {
        final FileObject[] roots = this.sourceRoots.getRoots();
        if (roots.length == 0) {
            throw new UnsupportedOperationException("No source path");  //NOI18N
        }
        final File rootFile = FileUtil.toFile(roots[0]);
        if (rootFile == null) {
            throw new UnsupportedOperationException("No source path");  //NOI18N
        }
        return FileObjects.sourceFileObject(
            BaseUtilities.toURI(new File(rootFile,FileObjects.convertFolder2Package(rp, File.separatorChar))).toURL(),
            roots[0]);
    } else {
        return FileObjects.sourceFileObject(fileRootPair[0], fileRootPair[1]); //Todo: wrap to protect from write
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:SourceFileManager.java

示例2: searchSubPackages

/**
 * Recursively search all directories in path for subdirectory name.
 * Add all packages found in such a directory to packages list.
 */
private Map<String,List<JavaFileObject>> searchSubPackages(
        List<String> subPackages,
        ListBuffer<String> packages,
        List<String> excludedPackages)
        throws IOException {
    Map<String,List<JavaFileObject>> packageFiles =
            new HashMap<String,List<JavaFileObject>>();

    Map<String,Boolean> includedPackages = new HashMap<String,Boolean>();
    includedPackages.put("", true);
    for (String p: excludedPackages)
        includedPackages.put(p, false);

    StandardLocation path = docenv.fileManager.hasLocation(StandardLocation.SOURCE_PATH)
            ? StandardLocation.SOURCE_PATH : StandardLocation.CLASS_PATH;

    searchSubPackages(subPackages,
            includedPackages,
            packages, packageFiles,
            path,
            EnumSet.of(JavaFileObject.Kind.SOURCE));

    return packageFiles;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:JavadocTool.java

示例3: initHandlers

void initHandlers() {
    handlersForLocation = new HashMap<Location, LocationHandler>();
    handlersForOption = new EnumMap<Option, LocationHandler>(Option.class);

    LocationHandler[] handlers = {
        new BootClassPathLocationHandler(),
        new ClassPathLocationHandler(),
        new SimpleLocationHandler(StandardLocation.SOURCE_PATH, Option.SOURCEPATH),
        new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_PATH, Option.PROCESSORPATH),
        new OutputLocationHandler((StandardLocation.CLASS_OUTPUT), Option.D),
        new OutputLocationHandler((StandardLocation.SOURCE_OUTPUT), Option.S),
        new OutputLocationHandler((StandardLocation.NATIVE_HEADER_OUTPUT), Option.H)
    };

    for (LocationHandler h: handlers) {
        handlersForLocation.put(h.location, h);
        for (Option o: h.options)
            handlersForOption.put(o, h);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:Locations.java

示例4: list

@Override
Iterable<DocFile> list(Location location, DocPath path) {
    if (location != StandardLocation.SOURCE_PATH)
        throw new IllegalArgumentException();

    Set<DocFile> files = new LinkedHashSet<DocFile>();
    if (fileManager.hasLocation(location)) {
        for (Path f: fileManager.getLocation(location)) {
            if (Files.isDirectory(f)) {
                f = f.resolve(path.getPath());
                if (Files.exists(f))
                    files.add(new StandardDocFile(f));
            }
        }
    }
    return files;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:PathDocFileFactory.java

示例5: list

@Override
Iterable<DocFile> list(Location location, DocPath path) {
    Location l = ((location == StandardLocation.SOURCE_PATH)
            && !fileManager.hasLocation(StandardLocation.SOURCE_PATH))
            ? StandardLocation.CLASS_PATH
            : location;

    Set<DocFile> files = new LinkedHashSet<>();
    for (Path f: fileManager.getLocationAsPaths(l)) {
        if (Files.isDirectory(f)) {
            f = f.resolve(path.getPath());
            if (Files.exists(f))
                files.add(new StandardDocFile(f));
        }
    }
    return files;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:StandardDocFileFactory.java

示例6: testBasic

@Test
public void testBasic(Path base) throws IOException {
    try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
        Location[] locns = {
            StandardLocation.SOURCE_PATH,
            StandardLocation.CLASS_PATH,
            StandardLocation.PLATFORM_CLASS_PATH,
        };
        // set a value
        Path out = Files.createDirectories(base.resolve("out"));
        for (Location locn : locns) {
            checkException("unsupported for location",
                    IllegalArgumentException.class,
                    "location is not an output location or a module-oriented location: " + locn,
                    () -> fm.setLocationForModule(locn, "m", List.of(out)));
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:SetLocationForModule.java

示例7: inferBinaryName

public String inferBinaryName(Location location, JavaFileObject file) {
    if (location == StandardLocation.SOURCE_PATH) {
        if (file instanceof InferableJavaFileObject) {
            return ((InferableJavaFileObject)file).inferBinaryName();
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:MemoryFileManager.java

示例8: getLocation

@Override
public Iterable<? extends File> getLocation(Location location) {
    org.openide.filesystems.FileObject[] roots;
    ClassPath cp = null;
    if (location == StandardLocation.SOURCE_PATH) {
        cp = cpInfo.getClassPath(ClasspathInfo.PathKind.SOURCE);
    } else if (location == StandardLocation.CLASS_PATH) {
        cp = cpInfo.getClassPath(ClasspathInfo.PathKind.COMPILE);
    } else if (location == StandardLocation.PLATFORM_CLASS_PATH) {
        cp = cpInfo.getClassPath(ClasspathInfo.PathKind.BOOT);
    }
    if (cp == null) {
        return null;
    }
    roots = cp.getRoots();
    if (roots == null || roots.length == 0) {
        return null;
    }
    List<File> res = new ArrayList<>(roots.length);
    for (org.openide.filesystems.FileObject f : roots) {
        File x = FileUtil.toFile(f);
        if (x != null) {
            res.add(x);
        }
    }
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:SwitchingJavaFileManger.java

示例9: initHandlers

void initHandlers() {
    handlersForLocation = new HashMap<>();
    handlersForOption = new EnumMap<>(Option.class);

    BasicLocationHandler[] handlers = {
        new BootClassPathLocationHandler(),
        new ClassPathLocationHandler(),
        new SimpleLocationHandler(StandardLocation.SOURCE_PATH, Option.SOURCE_PATH),
        new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_PATH, Option.PROCESSOR_PATH),
        new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_MODULE_PATH, Option.PROCESSOR_MODULE_PATH),
        new OutputLocationHandler(StandardLocation.CLASS_OUTPUT, Option.D),
        new OutputLocationHandler(StandardLocation.SOURCE_OUTPUT, Option.S),
        new OutputLocationHandler(StandardLocation.NATIVE_HEADER_OUTPUT, Option.H),
        new ModuleSourcePathLocationHandler(),
        new PatchModulesLocationHandler(),
        new ModulePathLocationHandler(StandardLocation.UPGRADE_MODULE_PATH, Option.UPGRADE_MODULE_PATH),
        new ModulePathLocationHandler(StandardLocation.MODULE_PATH, Option.MODULE_PATH),
        new SystemModulesLocationHandler(),
    };

    for (BasicLocationHandler h : handlers) {
        handlersForLocation.put(h.location, h);
        for (Option o : h.options) {
            handlersForOption.put(o, h);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:Locations.java

示例10: collectPubApisOfDependencies

private void collectPubApisOfDependencies(Context context,
                                          Collection<JavaFileObject> explicitJFOs) {
    PubAPIs pubApis = PubAPIs.instance(context);
    for (CompletionNode cDepNode : getDependencyNodes(context, explicitJFOs, false)) {
        ClassSymbol cs = cDepNode.getClassSymbol().outermostClass();
        Location loc = getLocationOf(cs);
        // We're completely ignorant of PLATFORM_CLASS_PATH classes
        if (loc == StandardLocation.CLASS_PATH || loc == StandardLocation.SOURCE_PATH)
            pubApis.visitPubapi(cs);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:NewDependencyCollector.java

示例11: getJavaFileForInput

@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,代码行数:12,代码来源:PublicMethodsTest.java

示例12: hasLocation

public boolean hasLocation(Location location) {
    return location == StandardLocation.SOURCE_PATH;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:3,代码来源:MemoryFileManager.java

示例13: containingPackage

/**
 * Return the package that this class is contained in.
 */
@Override
public PackageDoc containingPackage() {
    PackageDocImpl p = env.getPackageDoc(tsym.packge());
    if (p.setDocPath == false) {
        FileObject docPath;
        try {
            Location location = env.fileManager.hasLocation(StandardLocation.SOURCE_PATH)
                ? StandardLocation.SOURCE_PATH : StandardLocation.CLASS_PATH;

            docPath = env.fileManager.getFileForInput(
                    location, p.qualifiedName(), "package.html");
        } catch (IOException e) {
            docPath = null;
        }

        if (docPath == null) {
            // fall back on older semantics of looking in same directory as
            // source file for this class
            SourcePosition po = position();
            if (env.fileManager instanceof StandardJavaFileManager &&
                    po instanceof SourcePositionImpl) {
                URI uri = ((SourcePositionImpl) po).filename.toUri();
                if ("file".equals(uri.getScheme())) {
                    File f = new File(uri);
                    File dir = f.getParentFile();
                    if (dir != null) {
                        File pf = new File(dir, "package.html");
                        if (pf.exists()) {
                            StandardJavaFileManager sfm = (StandardJavaFileManager) env.fileManager;
                            docPath = sfm.getJavaFileObjects(pf).iterator().next();
                        }
                    }

                }
            }
        }

        p.setDocPath(docPath);
    }
    return p;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:44,代码来源:ClassDocImpl.java

示例14: isSymbolRelevant

public boolean isSymbolRelevant(boolean cp, ClassSymbol cs) {
    Location csLoc = getLocationOf(cs);
    Location relevantLocation = cp ? StandardLocation.CLASS_PATH : StandardLocation.SOURCE_PATH;
    return csLoc == relevantLocation;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:NewDependencyCollector.java

示例15: defaultLocation

private Location defaultLocation() {
    JavaFileManager fm = configuration.docEnv.getJavaFileManager();
    return fm.hasLocation(StandardLocation.SOURCE_PATH)
            ? StandardLocation.SOURCE_PATH
            : StandardLocation.CLASS_PATH;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:Utils.java


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