本文整理汇总了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
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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)));
}
}
}
示例7: inferBinaryName
public String inferBinaryName(Location location, JavaFileObject file) {
if (location == StandardLocation.SOURCE_PATH) {
if (file instanceof InferableJavaFileObject) {
return ((InferableJavaFileObject)file).inferBinaryName();
}
}
return null;
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
示例12: hasLocation
public boolean hasLocation(Location location) {
return location == StandardLocation.SOURCE_PATH;
}
示例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;
}
示例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;
}
示例15: defaultLocation
private Location defaultLocation() {
JavaFileManager fm = configuration.docEnv.getJavaFileManager();
return fm.hasLocation(StandardLocation.SOURCE_PATH)
? StandardLocation.SOURCE_PATH
: StandardLocation.CLASS_PATH;
}