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


Java StandardLocation.SOURCE_OUTPUT属性代码示例

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


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

示例1: buildUri

/**
 * Builds url for a given location, class or internal name
 *
 * @param location java file manager location
 * @param name     name
 * @return URI
 */
public static URI buildUri(JavaFileManager.Location location, String name) {
    String extension = "";
    String template = location.getName().toLowerCase().replace("_", "") + ":///%s%s";
    if (location == StandardLocation.CLASS_OUTPUT) {
        extension = JavaFileObject.Kind.CLASS.extension;
        template = CLASS_CODE_URI_TEMPLATE;
    } else if (location == StandardLocation.SOURCE_OUTPUT) {
        extension = JavaFileObject.Kind.SOURCE.extension;
        template = SOURCE_CODE_URI_TEMPLATE;
    }
    int dotLastPosition = name.lastIndexOf('.');
    if (dotLastPosition != -1) {
        name = name.replace('.', '/');
    }
    return buildUri(String.format(template, name, extension));
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:23,代码来源:URIUtil.java

示例2: 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

示例3: getFileForOutput

@Override
public javax.tools.FileObject getFileForOutput(Location l, String pkgName, String relativeName, javax.tools.FileObject sibling)
    throws IOException, UnsupportedOperationException, IllegalArgumentException {
    URL aptRoot = getAptRoot(sibling);
    if (ModuleLocation.isInstance(l)) {
        ModuleLocation mloc = ModuleLocation.cast(l);
        l = mloc.getBaseLocation();
        if (aptRoot == null) {
            final Iterator<? extends URL> it = mloc.getModuleRoots().iterator();
            aptRoot = it.hasNext() ? it.next() : null;
        } else if (!mloc.getModuleRoots().contains(aptRoot)) {
            throw new UnsupportedOperationException("ModuleLocation's APT root differs from the sibling's APT root");
        }
    }
    final Location location = l;
    if (StandardLocation.SOURCE_OUTPUT != location) {
        throw new UnsupportedOperationException("Only apt output is supported."); // NOI18N
    }
    if (aptRoot == null) {
        throw new UnsupportedOperationException(noAptRootDebug(sibling));
    }
    final String nameStr = pkgName.length() == 0 ?
        relativeName :
        pkgName.replace('.', File.separatorChar) + File.separatorChar + relativeName;    //NOI18N
    //Always on master fs -> file is save.
    return Optional.ofNullable(URLMapper.findFileObject(aptRoot))
            .map(fo -> {
                File f = FileUtil.toFile(fo);
                return fileTx.createFileObject(location, new File(f, nameStr), f, null, null);
            }).get();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:AptSourceFileManager.java

示例4: getJavaFileForOutput

@Override
public JavaFileObject getJavaFileForOutput (Location l, String className, JavaFileObject.Kind kind, javax.tools.FileObject sibling)
    throws IOException, UnsupportedOperationException, IllegalArgumentException {
    URL aptRoot = getAptRoot(sibling);
    if (ModuleLocation.isInstance(l)) {
        ModuleLocation mloc = ModuleLocation.cast(l);
        l = mloc.getBaseLocation();
        if (aptRoot == null) {
            final Iterator<? extends URL> it = mloc.getModuleRoots().iterator();
            aptRoot = it.hasNext() ? it.next() : null;
        } else if (!mloc.getModuleRoots().contains(aptRoot)) {
            throw new UnsupportedOperationException("ModuleLocation's APT root differs from the sibling's APT root");
        }
    }
    final Location location = l;
    if (StandardLocation.SOURCE_OUTPUT != location) {
        throw new UnsupportedOperationException("Only apt output is supported."); // NOI18N
    }
    if (aptRoot == null) {
        throw new UnsupportedOperationException(noAptRootDebug(sibling));
    }
    final String nameStr = className.replace('.', File.separatorChar) + kind.extension;    //NOI18N
    //Always on master fs -> file is save.
    return Optional.ofNullable(URLMapper.findFileObject(aptRoot))
            .map(fo -> {
                File f = FileUtil.toFile(fo);
                return fileTx.createFileObject(location, new File(f, nameStr), f, null, null);
            }).get();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:AptSourceFileManager.java

示例5: listLocationsForModules

@Override
public Iterable<Set<Location>> listLocationsForModules(Location location) throws IOException {
    if (location != StandardLocation.SOURCE_OUTPUT) {
        throw new UnsupportedOperationException("Only apt output is supported."); // NOI18N
    }
    if (cachedModuleLocations == null) {
        if (moduleSourceFileManager != null) {
            final Set<URL> entriesUrl = new HashSet<>();
            sourceRoots.entries().forEach((e) -> entriesUrl.add(e.getURL()));
            cachedModuleLocations = moduleSourceFileManager.sourceModuleLocations().stream()
                    .map((ml) -> {
                        ModuleLocation oml = ModuleLocation.create(
                                StandardLocation.SOURCE_OUTPUT,
                                ml.getModuleRoots().stream()
                                        .map((src) -> {
                                            try {
                                                return BaseUtilities.toURI(JavaIndex.getAptFolder(src, false)).toURL();
                                            } catch (IOException ioe) {
                                                Exceptions.printStackTrace(ioe);
                                                return null;
                                            }
                                        })
                                        .filter((cacheEntry) -> cacheEntry != null && entriesUrl.contains(cacheEntry))
                                        .collect(Collectors.toSet()),
                                ml.getModuleName());
                        return oml.getModuleRoots().isEmpty() ? null : Collections.singleton((Location)oml);
                    })
                    .filter(locations -> locations != null)
                    .collect(Collectors.toList());
        } else {
            cachedModuleLocations = Collections.emptySet();
        }
    }
    return cachedModuleLocations;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:AptSourceFileManager.java

示例6: 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

示例7: getModuleLocation

/**
 * Determine the location for the module on the module source path
 * or source output directory which contains a given CompilationUnit.
 * If the source output directory is unset, the class output directory
 * will be checked instead.
 * {@code null} is returned if no such module can be found.
 * @param tree the compilation unit tree
 * @return the location for the enclosing module
 * @throws IOException if there is a problem while searching for the module.
 */
private Location getModuleLocation(JCCompilationUnit tree) throws IOException {
    JavaFileObject fo = tree.sourcefile;

    Location loc =
            fileManager.getLocationForModule(StandardLocation.MODULE_SOURCE_PATH, fo);
    if (loc == null) {
        Location sourceOutput = fileManager.hasLocation(StandardLocation.SOURCE_OUTPUT) ?
                StandardLocation.SOURCE_OUTPUT : StandardLocation.CLASS_OUTPUT;
        loc =
            fileManager.getLocationForModule(sourceOutput, fo);
    }
    return loc;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:Modules.java

示例8: mark

@SuppressWarnings("unchecked")
@NonNull
private <T extends javax.tools.FileObject> T mark(
        @NonNull final T result,
        @NonNull JavaFileManager.Location l) throws MalformedURLException {
    if (ModuleLocation.isInstance(l)) {
        l = ModuleLocation.cast(l).getBaseLocation();
    }
    boolean valid = true;
    ProcessorGenerated.Type type = null;
    if (l == StandardLocation.CLASS_OUTPUT) {
        type = ProcessorGenerated.Type.RESOURCE;
    } else if (l == StandardLocation.SOURCE_OUTPUT) {
        type = ProcessorGenerated.Type.SOURCE;
    }
    if (cfg.getSiblings().getProvider().hasSibling() &&
        cfg.getSiblings().getProvider().isInSourceRoot()) {
        if (type == ProcessorGenerated.Type.SOURCE) {
            cfg.getProcessorGeneratedFiles().register(
                cfg.getSiblings().getProvider().getSibling(),
                result,
                type);
        } else if (type == ProcessorGenerated.Type.RESOURCE) {
            try {
                result.openInputStream().close();
            } catch (IOException ioe) {
                //Marking only created files
                cfg.getProcessorGeneratedFiles().register(
                    cfg.getSiblings().getProvider().getSibling(),
                    result,
                    type);
            }
        }
        if (!FileObjects.isValidFileName(result)) {
            LOG.log(
                Level.WARNING,
                "Cannot write Annotation Processor generated file: {0} ({1})",   //NOI18N
                new Object[] {
                    result.getName(),
                    result.toUri()
                });
            valid = false;
        }
    }
    return valid && (cfg.getProcessorGeneratedFiles().canWrite() || !cfg.getSiblings().getProvider().hasSibling()) ?
            result :
            (T) FileObjects.nullWriteFileObject((InferableJavaFileObject)result);    //safe - NullFileObject subclass of both JFO and FO.
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:48,代码来源:ProxyFileManager.java


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