本文整理汇总了Java中javax.tools.StandardLocation.MODULE_SOURCE_PATH属性的典型用法代码示例。如果您正苦于以下问题:Java StandardLocation.MODULE_SOURCE_PATH属性的具体用法?Java StandardLocation.MODULE_SOURCE_PATH怎么用?Java StandardLocation.MODULE_SOURCE_PATH使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.tools.StandardLocation
的用法示例。
在下文中一共展示了StandardLocation.MODULE_SOURCE_PATH属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLocationForModule
@Override
@CheckForNull
public Location getLocationForModule(Location location, JavaFileObject jfo) throws IOException {
if (location != StandardLocation.MODULE_SOURCE_PATH) {
throw new IllegalStateException(String.format("Unsupported location: %s", location));
}
final FileObject fo = URLMapper.findFileObject(jfo.toUri().toURL());
if (fo != null) {
for (ModuleLocation.WithExcludes moduleLocation : sourceModuleLocationsRemovedPatches()) {
for (ClassPath.Entry moduleEntry : moduleLocation.getModuleEntries()) {
final FileObject root = moduleEntry.getRoot();
if (root != null && FileUtil.isParentOf(root, fo)) {
return moduleLocation;
}
}
}
}
return null;
}
示例2: getLocation
private Location getLocation(String packageName) throws IOException {
if (location == StandardLocation.MODULE_SOURCE_PATH) {
// TODO: handle invalid results
Name pack = names.fromString(packageName);
for (ModuleSymbol msym : modules.allModules()) {
PackageSymbol p = syms.getPackage(msym, pack);
if (p != null && !p.members().isEmpty()) {
return fm.getLocationForModule(location, msym.name.toString());
}
}
return null;
} else {
return location;
}
}
示例3: listLocationsForModules
@Override
@NonNull
public Iterable<Set<Location>> listLocationsForModules(@NonNull final Location location) throws IOException {
if (location != StandardLocation.MODULE_SOURCE_PATH) {
throw new IllegalStateException(String.format("Unsupported location: %s", location));
}
return sourceModuleLocationsRemovedPatches().stream().map(
loc -> Collections.singleton((Location)loc)
).collect(Collectors.toSet());
}
示例4: testModuleSourcePath
@Test
public void testModuleSourcePath(Path base) throws IOException {
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
Location locn = StandardLocation.MODULE_SOURCE_PATH;
Path src1 = Files.createDirectories(base.resolve("src1"));
Path src1_m = src1.resolve("m");
tb.writeJavaFiles(src1_m, "module m { }");
// fm.setLocationFromPaths(locn, List.of(src1));
fm.handleOption("--module-source-path", List.of(src1.toString()).iterator());
Location m = fm.getLocationForModule(locn, "m");
checkEqual("default setting",
fm.getLocationAsPaths(m), src1.resolve("m"));
Path override1 = Files.createDirectories(base.resolve("override1"));
tb.writeJavaFiles(override1, "module m { }");
fm.setLocationForModule(locn, "m", List.of(override1));
checkEqual("override setting 1",
fm.getLocationAsPaths(m), override1);
Path override2 = Files.createDirectories(base.resolve("override2"));
tb.writeJavaFiles(override2, "module m { }");
fm.setLocationFromPaths(m, List.of(override2));
checkEqual("override setting 2",
fm.getLocationAsPaths(m), override2);
Path src2 = Files.createDirectories(base.resolve("src2"));
Path src2_m = src2.resolve("m");
tb.writeJavaFiles(src2_m, "module m { }");
// fm.setLocationFromPaths(locn, List.of(src2));
fm.handleOption("--module-source-path", List.of(src2.toString()).iterator());
checkEqual("updated setting",
fm.getLocationAsPaths(m), src2.resolve("m"));
}
}
示例5: hasLocation
@Override
public boolean hasLocation(Location location) {
return location == StandardLocation.MODULE_SOURCE_PATH;
}
示例6: scanModulePath
private List<ModuleSymbol> scanModulePath(ModuleSymbol toFind) {
ListBuffer<ModuleSymbol> results = new ListBuffer<>();
Map<Name, Location> namesInSet = new HashMap<>();
boolean multiModuleMode = fileManager.hasLocation(StandardLocation.MODULE_SOURCE_PATH);
while (moduleLocationIterator.hasNext()) {
Set<Location> locns = (moduleLocationIterator.next());
namesInSet.clear();
for (Location l: locns) {
try {
Name n = names.fromString(fileManager.inferModuleName(l));
if (namesInSet.put(n, l) == null) {
ModuleSymbol msym = syms.enterModule(n);
if (msym.sourceLocation != null || msym.classLocation != null) {
// module has already been found, so ignore this instance
continue;
}
if (fileManager.hasLocation(StandardLocation.PATCH_MODULE_PATH) &&
msym.patchLocation == null) {
msym.patchLocation =
fileManager.getLocationForModule(StandardLocation.PATCH_MODULE_PATH,
msym.name.toString());
if (msym.patchLocation != null &&
multiModuleMode &&
fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) {
msym.patchOutputLocation =
fileManager.getLocationForModule(StandardLocation.CLASS_OUTPUT,
msym.name.toString());
}
}
if (moduleLocationIterator.outer == StandardLocation.MODULE_SOURCE_PATH) {
msym.sourceLocation = l;
if (fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) {
msym.classLocation =
fileManager.getLocationForModule(StandardLocation.CLASS_OUTPUT,
msym.name.toString());
}
} else {
msym.classLocation = l;
}
if (moduleLocationIterator.outer == StandardLocation.SYSTEM_MODULES ||
moduleLocationIterator.outer == StandardLocation.UPGRADE_MODULE_PATH) {
msym.flags_field |= Flags.SYSTEM_MODULE;
}
if (toFind == null ||
(toFind == msym && (msym.sourceLocation != null || msym.classLocation != null))) {
// Note: cannot return msym directly, because we must finish
// processing this set first
results.add(msym);
}
} else {
log.error(Errors.DuplicateModuleOnPath(
getDescription(moduleLocationIterator.outer), n));
}
} catch (IOException e) {
// skip location for now? log error?
}
}
if (toFind != null && results.nonEmpty())
return results.toList();
}
return results.toList();
}
示例7: ModuleSourcePathLocationHandler
ModuleSourcePathLocationHandler() {
super(StandardLocation.MODULE_SOURCE_PATH,
Option.MODULE_SOURCE_PATH);
}