本文整理汇总了Java中org.netbeans.api.java.classpath.ClassPath类的典型用法代码示例。如果您正苦于以下问题:Java ClassPath类的具体用法?Java ClassPath怎么用?Java ClassPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClassPath类属于org.netbeans.api.java.classpath包,在下文中一共展示了ClassPath类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getFlags
import org.netbeans.api.java.classpath.ClassPath; //导入依赖的package包/类
@Override
@NonNull
public Set<ClassPath.Flag> getFlags() {
Set<ClassPath.Flag> res;
synchronized (this) {
res = flagsCache;
}
if (res == null) {
res = getActiveClassPath().getFlags();
assert res != null;
synchronized (this) {
if (flagsCache == null) {
flagsCache = res;
} else {
res = flagsCache;
}
}
}
return res;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:MuxClassPathImplementation.java
示例2: testAddToPreprocessorPath
import org.netbeans.api.java.classpath.ClassPath; //导入依赖的package包/类
public void testAddToPreprocessorPath() throws Exception {
assertNotNull("Project not created!",prj); //NOI18N
final FileObject libRoot = prj.getProjectDirectory().createFolder("mylib");
assertNotNull("Library not created!",libRoot); //NOI18N
assertNotNull("No src folder in the proj dir!",src); //NOI18N
SourceGroup srcGrp = null;
for (SourceGroup sg : ProjectUtils.getSources(prj).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)) {
FileObject root = sg.getRootFolder();
if (root == src) {
srcGrp = sg;
break;
}
}
assertNotNull("No sources group found!",srcGrp); //NOI18N
final ClassPath cp = ClassPath.getClassPath(srcGrp.getRootFolder(), JavaClassPathConstants.PROCESSOR_PATH);
assertFalse(Arrays.asList(cp.getRoots()).contains(libRoot));
ProjectClassPathModifier.addRoots(
new URI[] {libRoot.toURI()},
srcGrp.getRootFolder(),
JavaClassPathConstants.PROCESSOR_PATH);
assertTrue("No lib on processor path!", Arrays.asList(cp.getRoots()).contains(libRoot)); //NOI18N
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:J2SEProjectClassPathModifierTest.java
示例3: pathToString
import org.netbeans.api.java.classpath.ClassPath; //导入依赖的package包/类
@NonNull
private static String pathToString(@NonNull final ClassPath path) {
final StringBuilder cpBuilder = new StringBuilder();
for (ClassPath.Entry entry : path.entries()) {
final URL u = entry.getURL();
boolean folder = "file".equals(u.getProtocol());
File f = FileUtil.archiveOrDirForURL(u);
if (f != null) {
if (cpBuilder.length() > 0) {
cpBuilder.append(File.pathSeparatorChar);
}
cpBuilder.append(f.getAbsolutePath());
if (folder) {
cpBuilder.append(File.separatorChar);
}
}
}
return cpBuilder.toString();
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ProjectRunnerImpl.java
示例4: testTypeMirrorHandle
import org.netbeans.api.java.classpath.ClassPath; //导入依赖的package包/类
public void testTypeMirrorHandle() throws Exception {
prepareTest();
writeIntoFile(testSource, "package test; public class Test<T> {}");
ClassPath empty = ClassPathSupport.createClassPath(new URL[0]);
JavaSource js = JavaSource.create(ClasspathInfo.create(ClassPathSupport.createClassPath(SourceUtilsTestUtil.getBootClassPath().toArray(new URL[0])), empty, empty), testSource);
js.runUserActionTask(new Task<CompilationController>() {
public void run(CompilationController info) throws Exception {
info.toPhase(Phase.RESOLVED);
testCase(info, "java.util.Map");
testCase(info, "java.util.Map<java.lang.Object, java.util.List>");
testCase(info, "java.util.Map<java.lang.Object, java.util.List<java.lang.String>>");
testCase(info, "int[]");
// testCaseEnum(info); IZ #111876.
}
}, true);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:TypeMirrorHandleTest.java
示例5: getPanel
import org.netbeans.api.java.classpath.ClassPath; //导入依赖的package包/类
@Override
public CustomRefactoringPanel getPanel(ChangeListener parent) {
if (panel == null) {
String pkgName = null;
if (targetFolder != null) {
ClassPath cp = ClassPath.getClassPath(targetFolder, ClassPath.SOURCE);
if (cp != null) {
pkgName = cp.getResourceName(targetFolder, '.', false);
}
}
panel = new MoveClassPanel (parent,
pkgName != null ? pkgName : getDOPackageName(javaObjects.iterator().next().getParent()),
getString("LBL_MoveClassesHeadline"),
getString("LBL_MoveWithoutReferences"),
targetFolder != null ? targetFolder : javaObjects.iterator().next(),
disable, getNodes()
);
}
return panel;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:MoveClassesUI.java
示例6: createResources
import org.netbeans.api.java.classpath.ClassPath; //导入依赖的package包/类
@Override
protected List<PathResourceImplementation> createResources() {
ArrayList<PathResourceImplementation> result = new ArrayList<> ();
boolean[] includeJDK = { true };
boolean[] includeFX = { false };
result.addAll(ecpImpl.getResources(includeJDK, includeFX));
lastHintValue = project.getAuxProps().get(Constants.HINT_JDK_PLATFORM, true);
if (includeJDK[0]) {
JavaPlatform pat = findActivePlatform();
boolean hasFx = false;
for (ClassPath.Entry entry : pat.getBootstrapLibraries().entries()) {
if (entry.getURL().getPath().endsWith("/jfxrt.jar!/")) {
hasFx = true;
}
result.add(ClassPathSupport.createResource(entry.getURL()));
}
if (includeFX[0] && !hasFx) {
PathResourceImplementation fxcp = createFxCPImpl(pat);
if (fxcp != null) {
result.add(fxcp);
}
}
result.addAll(nbPlatformJavaFxCp(project, pat));
}
return result;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:BootClassPathImpl.java
示例7: getFiles
import org.netbeans.api.java.classpath.ClassPath; //导入依赖的package包/类
@Override
@NonNull
public Iterable<JavaFileObject> getFiles(
@NonNull String folderName,
@NullAllowed final ClassPath.Entry entry,
@NullAllowed final Set<JavaFileObject.Kind> kinds,
@NullAllowed final JavaFileFilterImplementation filter,
final boolean recursive) throws IOException {
if (separator != FileObjects.NBFS_SEPARATOR_CHAR) {
folderName = folderName.replace(FileObjects.NBFS_SEPARATOR_CHAR, separator);
}
final Path target = root.resolve(folderName);
final List<JavaFileObject> res = new ArrayList<>();
try (final Stream<Path> s = recursive ? Files.walk(target, FileVisitOption.FOLLOW_LINKS) : Files.list(target)) {
s.filter((p)->{
return (kinds == null || kinds.contains(FileObjects.getKind(FileObjects.getExtension(p.getFileName().toString()))))
&& Files.isRegularFile(p);
})
.forEach((p)->{res.add(FileObjects.pathFileObject(p, root, rootURI, null));});
}
return Collections.unmodifiableCollection(res);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:PathArchive.java
示例8: remove
import org.netbeans.api.java.classpath.ClassPath; //导入依赖的package包/类
boolean remove() {
final ClassPathModifier cpm = project.getLookup().lookup(ClassPathModifier.class);
boolean success = false;
if (cpm != null) {
try {
cpm.removeAntArtifacts(
new AntArtifact[]{onArt},
new URI[] {onLoc},
root,
ClassPath.COMPILE);
success = true;
} catch (IOException | UnsupportedOperationException ex) {
LOG.log(
Level.INFO,
"Cannot fix dependencies in project: {0}", //NOI18N
ProjectUtils.getInformation(project).getDisplayName());
}
}
return success;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ProjectOperations.java
示例9: testAPIIsSelfContained
import org.netbeans.api.java.classpath.ClassPath; //导入依赖的package包/类
public void testAPIIsSelfContained() throws Exception {
FileObject root = makeScratchDir(this);
final ClassPath bootPath = ClassPathSupport.createClassPath(SourceUtilsTestUtil.getBootClassPath().toArray(new URL[0]));//ClassPath.getClassPath(source, ClassPath.BOOT);
final ClassPath compilePath = ClassPathSupport.createClassPath(prepareClasspath());
final ClassPath srcPath = ClassPathSupport.createClassPath(new URL[0]);
JavaSource js = JavaSource.create(ClasspathInfo.create(bootPath, compilePath, srcPath)/*, source*/);
js.runUserActionTask(new Task<CompilationController>() {
public void run(CompilationController copy) throws Exception {
PackageElement apiPackage = copy.getElements().getPackageElement("org.netbeans.api.java.source");
verifySelfContainedAPI(apiPackage);
apiPackage = copy.getElements().getPackageElement("org.netbeans.api.java.source.support");
verifySelfContainedAPI(apiPackage);
}
},true);
assertTrue(violations.toString(), violations.isEmpty());
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:APIIsSelfContainedTest.java
示例10: setUp
import org.netbeans.api.java.classpath.ClassPath; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
ClassPathProvider cpp = new ClassPathProvider() {
@Override
public ClassPath findClassPath(FileObject file, String type) {
if (type.equals(ClassPath.SOURCE)) {
return ClassPathSupport.createClassPath(new FileObject[]{FileUtil.toFileObject(getDataDir())});
}
if (type.equals(ClassPath.COMPILE)) {
return ClassPathSupport.createClassPath(new FileObject[0]);
}
if (type.equals(ClassPath.BOOT)) {
return createClassPath(System.getProperty("sun.boot.class.path"));
}
return null;
}
};
SharedClassObject loader = JavaDataLoader.findObject(JavaDataLoader.class, true);
SourceUtilsTestUtil.prepareTest(new String[]{"org/netbeans/modules/java/source/resources/layer.xml","org/netbeans/modules/java/source/base/layer.xml"}, new Object[]{loader/*, cpp*/});
JEditorPane.registerEditorKitForContentType("text/x-java", "org.netbeans.modules.editor.java.JavaKit");
File cacheFolder = new File(getWorkDir(), "var/cache/index");
cacheFolder.mkdirs();
IndexUtil.setCacheFolder(cacheFolder);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:FormatingTest.java
示例11: getProjectClassPath
import org.netbeans.api.java.classpath.ClassPath; //导入依赖的package包/类
/**
* Returns the project classpath including project build paths.
* Can be used to set classpath for custom classloader.
*
* @param project the current project.
* @return List of java.net.URL objects representing each entry on the classpath.
*/
public static List<URL> getProjectClassPath(Project project) {
List<URL> projectClassPathEntries = new ArrayList<URL>();
for (SourceGroup sourceGroup : getSourceGroups(project)) {
if (sourceGroup == null) {
continue;
}
ClassPath cp = ClassPath.getClassPath(sourceGroup.getRootFolder(), ClassPath.COMPILE);
for (ClassPath.Entry cpEntry : cp.entries()) {
projectClassPathEntries.add(cpEntry.getURL());
}
}
return projectClassPathEntries;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:HibernateUtil.java
示例12: computeHints
import org.netbeans.api.java.classpath.ClassPath; //导入依赖的package包/类
@Override
public Collection<? extends HintDescription> computeHints(final ClassPath cp, AtomicBoolean cancel) {
final AtomicReference<Collection<? extends FileObject>> foundFiles = new AtomicReference<>();
Task task = ASYNCHRONOUS.post(new Runnable() {
@Override public void run() {
foundFiles.set(findFiles(cp));
}
});
while ((cancel == null || !cancel.get()) && !task.isFinished()) {
try {
task.waitFinished(1);
} catch (InterruptedException ex) {
LOG.log(Level.FINE, null, ex);
}
}
Collection<? extends FileObject> files = foundFiles.get();
if (files == null || (cancel != null && cancel.get())) return null;
return join(readHints(files));
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:DeclarativeHintRegistry.java
示例13: testOraculumLibrarySourceWithoutRootWithSourcePath
import org.netbeans.api.java.classpath.ClassPath; //导入依赖的package包/类
public void testOraculumLibrarySourceWithoutRootWithSourcePath() {
Lookup.getDefault().lookup(CPP.class).add(
root1,
ClassPath.SOURCE,
ClassPathSupport.createClassPath(root1));
final ClasspathInfo cpInfo = new ClasspathInfo.Builder(ClassPath.EMPTY).build();
final JavacParser parser = new JavacParser(Collections.emptyList(), true);
final JavacTaskImpl impl = JavacParser.createJavacTask(
javaFile1,
null,
cpInfo,
parser,
null,
false);
assertNotNull(impl);
final Options opts = Options.instance(impl.getContext());
assertNotNull(opts);
assertEquals("Test", opts.get("-XD-Xmodule:")); //NOI18N
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ModuleOraculumTest.java
示例14: testWrongClassPathWhileParsingClassFile
import org.netbeans.api.java.classpath.ClassPath; //导入依赖的package包/类
public void testWrongClassPathWhileParsingClassFile() throws Exception {
final FileObject wd = FileUtil.toFileObject(getWorkDir());
final ClassPath boot = createBootPath();
final ClassPath compile = ClassPathSupport.createClassPath(FileUtil.createFolder(wd, "libka"));
final ClasspathInfo cpInfo = ClasspathInfo.create(boot, compile, null);
final FileObject jlObject = boot.findResource("java/lang/Object.class");
assertNotNull(jlObject);
final JavaSource js = JavaSource.create(cpInfo, jlObject);
assertNotNull(js);
js.runUserActionTask(
new Task<CompilationController>(){
@Override
public void run(CompilationController control) throws Exception {
final ClasspathInfo cpInfoInTask = control.getClasspathInfo();
assertNotNull(cpInfoInTask);
assertEquals(compile.entries(), cpInfoInTask.getClassPath(ClasspathInfo.PathKind.COMPILE).entries());
}
},true);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:JavaSourceTest.java
示例15: findClassPath
import org.netbeans.api.java.classpath.ClassPath; //导入依赖的package包/类
@Override
public ClassPath findClassPath(
FileObject file,
String type) {
for (FileObject srcRoot : srcPath.getRoots()) {
if (srcRoot.equals(file) || FileUtil.isParentOf(srcRoot, file)) {
if (type == ClassPath.SOURCE) {
return srcPath;
} else if (type == ClassPath.BOOT) {
return bootPath;
} else if (type == ClassPath.COMPILE) {
return compilePath;
}
}
}
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:JavaOperationsImplTest.java
示例16: find
import org.netbeans.api.java.classpath.ClassPath; //导入依赖的package包/类
@Override
public FileObject find(String filename) {
if (filename == null) {
return null;
}
ClassPath cp;
synchronized (LOCK) {
if (classpath == null) {
classpath = getProjectClasspath(project);
}
cp = classpath;
}
FileObject toRet = cp.findResource(filename);
if (toRet == null) {
LOG.log(Level.FINE, "#221053: Cannot find FileObject for {0}", filename);
}
return toRet;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:MavenFileLocator.java
示例17: Builder
import org.netbeans.api.java.classpath.ClassPath; //导入依赖的package包/类
private Builder(
@NonNull final Project project,
@NonNull final UpdateHelper updateHelper,
@NonNull final PropertyEvaluator evaluator,
@NonNull final SourceRoots sourceRoots,
@NonNull final SourceRoots testSourceRoots,
@NonNull final Function<String,ClassPath> projectClassPaths) {
Parameters.notNull("project", project); //NOI18N
Parameters.notNull("updateHelper", updateHelper); //NOI18N
Parameters.notNull("evaluator", evaluator); //NOI18N
Parameters.notNull("sourceRoots", sourceRoots); //NOI18N
Parameters.notNull("testSourceRoots", testSourceRoots); //NOI18N
Parameters.notNull("projectClassPaths", projectClassPaths); //NOI18N
this.project = project;
this.updateHelper = updateHelper;
this.evaluator = evaluator;
this.sourceRoots = sourceRoots;
this.testRoots = testSourceRoots;
this.actions = new ArrayList<>();
this.jpp = createJavaPlatformProvider(ProjectProperties.PLATFORM_ACTIVE);
this.mfs = ActionProviderSupport.ModifiedFilesSupport.newInstance(project, updateHelper, evaluator);
this.classpaths = projectClassPaths;
final Function<Boolean,String> pmcp = (validate) -> ActionProviderSupport.getProjectMainClass(project, evaluator, sourceRoots, classpaths, validate);
final Supplier<Boolean> mcc = () -> ActionProviderSupport.showCustomizer(project, updateHelper, evaluator, sourceRoots, classpaths);
this.mainClassServices = new Object[] {pmcp, mcc};
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:JavaActionProvider.java
示例18: testModuleInfoBasedCp_UserModules_in_NamedModule_AddMods
import org.netbeans.api.java.classpath.ClassPath; //导入依赖的package包/类
public void testModuleInfoBasedCp_UserModules_in_NamedModule_AddMods() throws IOException {
if (systemModules == null) {
System.out.println("No jdk 9 home configured."); //NOI18N
return;
}
assertNotNull(src);
final ClassPath userModules = org.netbeans.spi.java.classpath.support.ClassPathSupport.createClassPath(automaticModuleRoot);
final ClassPath legacyCp = org.netbeans.spi.java.classpath.support.ClassPathSupport.createClassPath(jarFileRoot);
createModuleInfo(src, "Modle", "java.logging"); //NOI18N
final MockCompilerOptions opts = MockCompilerOptions.getInstance();
assertNotNull("No MockCompilerOptions in Lookup", opts);
opts.forRoot(src.getRoots()[0])
.apply("--add-modules") //NOI18N
.apply(SourceUtils.getModuleName(automaticModuleRoot.toURL()));
final ClassPath cp = ClassPathFactory.createClassPath(ModuleClassPaths.createModuleInfoBasedPath(
userModules,
src,
systemModules,
userModules,
legacyCp,
null));
final Collection<URL> resURLs = collectEntries(cp);
//Modules from declared dependencies - nothing
final Collection<URL> expectedURLs = new ArrayList<>();
assertEquals(expectedURLs, resURLs);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ModuleClassPathsTest.java
示例19: getRuntimeClasspath
import org.netbeans.api.java.classpath.ClassPath; //导入依赖的package包/类
private ClassPath getRuntimeClasspath(int type) {
final int ftype = type == TYPE_WEB ? TYPE_SRC : type;
return computeIfAbsent(RUNTIME_PATH + ftype,
() -> createModuleInfoSelector(
// if there is a main module-info
() -> createModuleInfoBasedPath(
getJava8RunTimeClassPath(ftype), // base
getSourcepath(ftype), // source
getModuleBootPath(), // system modules
getJava8RunTimeClassPath(ftype), // user modules
ftype == TYPE_SRC ? // legacy
getJava8RunTimeClassPath(TYPE_SRC) :
createTestClassPathSelector(() -> getJava8RunTimeClassPath(TYPE_TESTSRC), () -> getTestScopedRuntimeClasspath(), "TestsRuntimeLegacyClasspath"),
null),
// if there is no module-info
() -> getJava8RunTimeClassPath(ftype),
"RuntimeClasspath"));
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ClassPathProviderImpl.java
示例20: testAddRemoveRoot
import org.netbeans.api.java.classpath.ClassPath; //导入依赖的package包/类
public void testAddRemoveRoot () throws Exception {
final FileObject rootFolder = this.scratch.createFolder("Root");
final FileObject jarFile = TestFileUtils.writeZipFile(scratch, "archive.jar", "Test.properties:");
final FileObject jarRoot = FileUtil.getArchiveRoot(jarFile);
ProjectClassPathModifier.addRoots (new URL[] {rootFolder.toURL()}, this.src, ClassPath.COMPILE);
String cp = this.eval.getProperty("javac.classpath");
assertNotNull (cp);
String[] cpRoots = PropertyUtils.tokenizePath (cp);
assertNotNull (cpRoots);
assertEquals(1,cpRoots.length);
assertEquals(rootFolder,this.helper.resolveFileObject(cpRoots[0]));
ProjectClassPathModifier.removeRoots (new URL[] {rootFolder.toURL()},this.src, ClassPath.COMPILE);
cp = this.eval.getProperty("javac.classpath");
assertNotNull (cp);
cpRoots = PropertyUtils.tokenizePath (cp);
assertNotNull (cpRoots);
assertEquals(0,cpRoots.length);
ProjectClassPathModifier.addRoots(new URL[] {jarRoot.toURL()},this.test,ClassPath.EXECUTE);
cp = this.eval.getProperty("run.test.classpath");
assertNotNull (cp);
cpRoots = PropertyUtils.tokenizePath (cp);
assertNotNull (cpRoots);
assertEquals(5,cpRoots.length);
assertEquals(this.helper.resolveFileObject(cpRoots[4]),jarFile);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:J2SEProjectClassPathModifierTest.java
注:本文中的org.netbeans.api.java.classpath.ClassPath类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论