Java Code Examples for javax.tools.JavaFileManager.Location#isOutputLocation()

The following examples show how to use javax.tools.JavaFileManager.Location#isOutputLocation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: T6397104.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
void test(boolean hasLocation, File siblingFile, String relName, String expectedPath)
    throws Exception
{
    System.err.format("test: hasLocation:%s, siblingFile:%s, relName:%s, expectedPath:%s%n",
            hasLocation, siblingFile, relName, expectedPath);
    try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
        if (hasLocation) {
            for (Location location : StandardLocation.values()) {
                System.err.format("  location:%s, moduleLocn:%b%n",
                    location, location.isModuleOrientedLocation());
                if (!location.isOutputLocation()) {
                    continue;
                }
                fm.setLocation(location, Arrays.asList(new File(".")));
                test(fm, location, siblingFile, relName, expectedPath);
            }
        } else {
            test(fm, CLASS_OUTPUT, siblingFile, relName, expectedPath);
        }
    }
}
 
Example 2
Source File: Locations.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
void setLocation(Location location, Iterable<? extends File> files) throws IOException {
    LocationHandler h = getHandler(location);
    if (h == null) {
        if (location.isOutputLocation())
            h = new OutputLocationHandler(location);
        else
            h = new SimpleLocationHandler(location);
        handlersForLocation.put(location, h);
    }
    h.setLocation(files);
}
 
Example 3
Source File: Locations.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
void setLocation(Location location, Iterable<? extends File> files) throws IOException {
    LocationHandler h = getHandler(location);
    if (h == null) {
        if (location.isOutputLocation())
            h = new OutputLocationHandler(location);
        else
            h = new SimpleLocationHandler(location);
        handlersForLocation.put(location, h);
    }
    h.setLocation(files);
}
 
Example 4
Source File: Locations.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
void setLocation(Location location, Iterable<? extends File> files) throws IOException {
    LocationHandler h = getHandler(location);
    if (h == null) {
        if (location.isOutputLocation())
            h = new OutputLocationHandler(location);
        else
            h = new SimpleLocationHandler(location);
        handlersForLocation.put(location, h);
    }
    h.setLocation(files);
}
 
Example 5
Source File: Locations.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
void setLocationForModule(Location location, String moduleName,
        Iterable<? extends Path> files) throws IOException {
    LocationHandler h = getHandler(location);
    if (h == null) {
        if (location.isOutputLocation()) {
            h = new OutputLocationHandler(location);
        } else {
            h = new ModulePathLocationHandler(location);
        }
        handlersForLocation.put(location, h);
    }
    h.setPathsForModule(moduleName, files);
}
 
Example 6
Source File: Locations.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
void setLocation(Location location, Iterable<? extends Path> files) throws IOException {
    LocationHandler h = getHandler(location);
    if (h == null) {
        if (location.isOutputLocation()) {
            h = new OutputLocationHandler(location);
        } else {
            h = new SimpleLocationHandler(location);
        }
        handlersForLocation.put(location, h);
    }
    h.setPaths(files);
}
 
Example 7
Source File: Locations.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
Path getOutputLocation(Location location) {
    if (!location.isOutputLocation()) {
        throw new IllegalArgumentException();
    }
    LocationHandler h = getHandler(location);
    return ((OutputLocationHandler) h).outputDir;
}
 
Example 8
Source File: JavacFiler.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public FileObject getResource(Location location,
                              CharSequence pkg,
                              CharSequence relativeName) throws IOException {
    String strPkg = pkg.toString();
    if (strPkg.length() > 0)
        checkName(strPkg);

    // TODO: Only support reading resources in selected output
    // locations?  Only allow reading of non-source, non-class
    // files from the supported input locations?

    // In the following, getFileForInput is the "obvious" method
    // to use, but it does not have the "obvious" semantics for
    // SOURCE_OUTPUT and CLASS_OUTPUT. Conversely, getFileForOutput
    // does not have the correct semantics for any "path" location
    // with more than one component. So, for now, we use a hybrid
    // invocation.
    FileObject fileObject;
    if (location.isOutputLocation()) {
        fileObject = fileManager.getFileForOutput(location,
                pkg.toString(),
                relativeName.toString(),
                null);
    } else {
        fileObject = fileManager.getFileForInput(location,
                pkg.toString(),
                relativeName.toString());
    }
    if (fileObject == null) {
        String name = (pkg.length() == 0)
                ? relativeName.toString() : (pkg + "/" + relativeName);
        throw new FileNotFoundException(name);
    }

    // If the path was already opened for writing, throw an exception.
    checkFileReopening(fileObject, false);
    return new FilerInputFileObject(fileObject);
}
 
Example 9
Source File: Locations.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
void setLocation(Location location, Iterable<? extends File> files) throws IOException {
    LocationHandler h = getHandler(location);
    if (h == null) {
        if (location.isOutputLocation())
            h = new OutputLocationHandler(location);
        else
            h = new SimpleLocationHandler(location);
        handlersForLocation.put(location, h);
    }
    h.setLocation(files);
}
 
Example 10
Source File: Locations.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
void setLocationForModule(Location location, String moduleName,
        Iterable<? extends File> files) throws IOException {
    LocationHandler h = getHandler(location);
    if (h == null) {
        if (location.isOutputLocation()) {
            h = new OutputLocationHandler(location);
        } else {
            h = new ModuleFileLocationHandler(location);
        }
        handlersForLocation.put(location, h);
    }
    h.setFilesForModule(moduleName, files);
}
 
Example 11
Source File: Locations.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
File getOutputLocation(Location location) {
    if (!location.isOutputLocation()) {
        throw new IllegalArgumentException();
    }
    LocationHandler h = getHandler(location);
    return ((OutputLocationHandler) h).outputDir;
}
 
Example 12
Source File: JavacFiler.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public FileObject getResource(Location location,
                              CharSequence pkg,
                              CharSequence relativeName) throws IOException {
    String strPkg = pkg.toString();
    if (strPkg.length() > 0)
        checkName(strPkg);

    // TODO: Only support reading resources in selected output
    // locations?  Only allow reading of non-source, non-class
    // files from the supported input locations?

    // In the following, getFileForInput is the "obvious" method
    // to use, but it does not have the "obvious" semantics for
    // SOURCE_OUTPUT and CLASS_OUTPUT. Conversely, getFileForOutput
    // does not have the correct semantics for any "path" location
    // with more than one component. So, for now, we use a hybrid
    // invocation.
    FileObject fileObject;
    if (location.isOutputLocation()) {
        fileObject = fileManager.getFileForOutput(location,
                pkg.toString(),
                relativeName.toString(),
                null);
    } else {
        fileObject = fileManager.getFileForInput(location,
                pkg.toString(),
                relativeName.toString());
    }
    if (fileObject == null) {
        String name = (pkg.length() == 0)
                ? relativeName.toString() : (pkg + "/" + relativeName);
        throw new FileNotFoundException(name);
    }

    // If the path was already opened for writing, throw an exception.
    checkFileReopening(fileObject, false);
    return new FilerInputFileObject(fileObject);
}
 
Example 13
Source File: Locations.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
void setLocation(Location location, Iterable<? extends File> files) throws IOException {
    LocationHandler h = getHandler(location);
    if (h == null) {
        if (location.isOutputLocation())
            h = new OutputLocationHandler(location);
        else
            h = new SimpleLocationHandler(location);
        handlersForLocation.put(location, h);
    }
    h.setLocation(files);
}
 
Example 14
Source File: Locations.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
File getOutputLocation(Location location) {
    if (!location.isOutputLocation())
        throw new IllegalArgumentException();
    LocationHandler h = getHandler(location);
    return ((OutputLocationHandler) h).outputDir;
}
 
Example 15
Source File: Locations.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
File getOutputLocation(Location location) {
    if (!location.isOutputLocation())
        throw new IllegalArgumentException();
    LocationHandler h = getHandler(location);
    return ((OutputLocationHandler) h).outputDir;
}
 
Example 16
Source File: Locations.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
File getOutputLocation(Location location) {
    if (!location.isOutputLocation())
        throw new IllegalArgumentException();
    LocationHandler h = getHandler(location);
    return ((OutputLocationHandler) h).outputDir;
}
 
Example 17
Source File: Locations.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
File getOutputLocation(Location location) {
    if (!location.isOutputLocation())
        throw new IllegalArgumentException();
    LocationHandler h = getHandler(location);
    return ((OutputLocationHandler) h).outputDir;
}
 
Example 18
Source File: ModuleAndPackageLocations.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private static String toString(Location l) {
    return l.getName().replaceAll("\\[([0-9])\\.[0-9]:", "[$1.X,") + ":" +
           l.isModuleOrientedLocation() + ":" + l.isOutputLocation();
}
 
Example 19
Source File: Locations.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
File getOutputLocation(Location location) {
    if (!location.isOutputLocation())
        throw new IllegalArgumentException();
    LocationHandler h = getHandler(location);
    return ((OutputLocationHandler) h).outputDir;
}
 
Example 20
Source File: Locations.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
File getOutputLocation(Location location) {
    if (!location.isOutputLocation())
        throw new IllegalArgumentException();
    LocationHandler h = getHandler(location);
    return ((OutputLocationHandler) h).outputDir;
}