本文整理汇总了Java中javax.tools.StandardLocation.CLASS_PATH属性的典型用法代码示例。如果您正苦于以下问题:Java StandardLocation.CLASS_PATH属性的具体用法?Java StandardLocation.CLASS_PATH怎么用?Java StandardLocation.CLASS_PATH使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.tools.StandardLocation
的用法示例。
在下文中一共展示了StandardLocation.CLASS_PATH属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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)));
}
}
}
示例4: 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;
}
示例5: fillIn
/** Load directory of package into members scope.
*/
private void fillIn(PackageSymbol p) throws IOException {
if (p.members_field == null)
p.members_field = WriteableScope.create(p);
ModuleSymbol msym = p.modle;
Assert.checkNonNull(msym, p::toString);
msym.complete();
if (msym == syms.noModule) {
preferCurrent = false;
if (userPathsFirst) {
scanUserPaths(p, true);
preferCurrent = true;
scanPlatformPath(p);
} else {
scanPlatformPath(p);
scanUserPaths(p, true);
}
} else if (msym.classLocation == StandardLocation.CLASS_PATH) {
scanUserPaths(p, msym.sourceLocation == StandardLocation.SOURCE_PATH);
} else {
scanModulePaths(p, msym);
}
}
示例6: 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);
}
}
示例7: hasLocation
@Override
public boolean hasLocation(Location location) {
return location == StandardLocation.CLASS_PATH || location == StandardLocation.PLATFORM_CLASS_PATH;
}
示例8: 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;
}
示例9: ClassPathLocationHandler
ClassPathLocationHandler() {
super(StandardLocation.CLASS_PATH,
Option.CLASSPATH, Option.CP);
}
示例10: ClassPathLocationHandler
ClassPathLocationHandler() {
super(StandardLocation.CLASS_PATH, Option.CLASS_PATH);
}
示例11: isSymbolRelevant
public boolean isSymbolRelevant(boolean cp, ClassSymbol cs) {
Location csLoc = getLocationOf(cs);
Location relevantLocation = cp ? StandardLocation.CLASS_PATH : StandardLocation.SOURCE_PATH;
return csLoc == relevantLocation;
}
示例12: defaultLocation
private Location defaultLocation() {
JavaFileManager fm = configuration.docEnv.getJavaFileManager();
return fm.hasLocation(StandardLocation.SOURCE_PATH)
? StandardLocation.SOURCE_PATH
: StandardLocation.CLASS_PATH;
}