org.netbeans.api.java.classpath.ClassPath.contains()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中org.netbeans.api.java.classpath.ClassPath.contains()方法的一些代码示例,展示了ClassPath.contains()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClassPath.contains()方法的具体详情如下:
包路径:org.netbeans.api.java.classpath.ClassPath
类名称:ClassPath
方法名:contains

ClassPath.contains介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-project

public static ClassPath findProjectIncludePath(FileObject file) {
  PROJECT_INCLUDES_LOCK.readLock().lock();
  try {
    for (ClassPath classPath : PROJECT_INCLUDES) {
      if (classPath.contains(file)) {
        return classPath;
      }
    }
  } finally {
    PROJECT_INCLUDES_LOCK.readLock().unlock();
  }
  return null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-makeproject

@Override
public ClassPath findClassPath(FileObject file, String type) {
  if (MakeProjectPaths.SOURCES.equals(type)) {
    PROJECT_LOCK.readLock().lock();
    try {
      for (ClassPath spc : PROJECT_CPS) {
        boolean accept = false;
        if (spc.contains(file)) {
          Project owner = FileOwnerQuery.getOwner(file);
          if (owner instanceof MakeProject) {
            accept = true;
          }
        }
        if (accept) {
          LOG.log(Level.FINE, "findClassPath({0}, {1}) -> {2} from {3}", new Object[] {file, type, spc, MakeProjectClassPathProvider.class});
          return spc;
        }
      }
    } finally {
      PROJECT_LOCK.readLock().unlock();
    }
  }
  LOG.log(Level.FINE, "findClassPath({0}, {1}) -> null", new Object[] {file, type});
  return null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-project

private static FileType getFileTypeFromIncludeClassPath(FileObject file) {
  // now, check include path of opened projects
  ClassPath classPath = IncludePathClassPathProvider.findProjectIncludePath(file);
  if (classPath != null && classPath.contains(file)) {
    // internal?
    if (org.netbeans.modules.php.project.util.PhpProjectUtils.isInternalFile(file)) {
      return FileType.INTERNAL;
    }
    // include
    return FileType.INCLUDE;
  }
  return null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-editor-global-format

private static void addRecursivelly(FileObject top, List<FileObject> into, Set<String> sourceIds, ClassPath sourceCP, SourceGroup sg, AtomicBoolean cancel) {
  List<FileObject> todo = new LinkedList<FileObject>();
  Iterator<String> sIDIter = sourceIds.iterator();
  
  while (sourceCP == null && sIDIter.hasNext()) {
    if (cancel.get()) return;
    sourceCP = ClassPath.getClassPath(top, sIDIter.next());
  }
  todo.add(top);
  while (!todo.isEmpty()) {
    if (cancel.get()) return;
    
    FileObject current = todo.remove(0);
    if (!VisibilityQuery.getDefault().isVisible(current)) continue;
    if (sourceCP != null && !sourceCP.contains(current)) continue;
    if (sg != null && !sg.contains(current)) continue;
    if (current.isData()) {
      into.add(current);
    }
    todo.addAll(Arrays.asList(current.getChildren()));
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-j2ee-clientproject

public void run(CompilationController c) throws Exception {
  TypeElement te = c.getElements().getTypeElement(mainClassName);
   if (te != null) {
    synchronized (MainClassUpdater.this) {
      current = SourceUtils.getFile(te, cpInfo);
      listener = WeakListeners.create(FileChangeListener.class, MainClassUpdater.this, current);
      if (current != null && sourcePath.contains(current)) {
        current.addFileChangeListener(listener);
      }
    }
  }                            
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-project-jsf

/**
 * Check if a project has an root reference to the named root qualified by the type parameter.
 * @param project Target project
 * @param rootFile file object of the root
 * @param type Determines whether the root is to be referenced from the design-time classpath or deploy
 * time classpath
 * @return Returns true if the root is already referenced by the project, false otherwise
 */
public static boolean hasRootReference(Project project, URL rootFile, String type) {
  FileObject obj = URLMapper.findFileObject(rootFile);
  if (obj == null) {
    return false;
  }
  // XXX NetBeans API not finished yet
  type = ClassPath.COMPILE;
  ClassPath cp = ClassPath.getClassPath(getSourceRoot(project), type);
  return cp.contains(obj);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-project-jsf

/**
 * Check if a project has a library reference to the named library qualified by the type parameter.
 * @param project Target project
 * @param library Library object
 * @param type Determines whether the library is to be referenced from the design-time classpath or deploy
 * time classpath
 * @return Returns true if the library is already referenced by the project, false otherwise
 */
public static boolean hasLibraryReference(Project project, Library library, String type) {
  List lst = library.getContent("classpath");
  if (lst.isEmpty()) {
    return false;
  }
  URL url = (URL) lst.get(0);
  FileObject obj = URLMapper.findFileObject(url);
  if (obj == null) {
    return false;
  }
  // XXX NetBeans API not finished yet
  type = ClassPath.COMPILE;
  ClassPath cp = ClassPath.getClassPath(getSourceRoot(project), type);
  if (cp == null) {
    return false;
  }
  return cp.contains(obj);
}

代码示例来源:origin: dcaoyuan/nbscala

public String getSourceLevel(org.openide.filesystems.FileObject javaFile) {
  try {
  } catch (Exception e) {}
  ScalaPlatform[] platforms = ScalaPlatformManager.getDefault().getInstalledPlatforms ();
  for (int i=0; i< platforms.length; i++) {
    if (J2SEPlatformImpl.PLATFORM_J2SE.equalsIgnoreCase(platforms[i].getSpecification().getName()) && platforms[i].getSourceFolders().contains(javaFile)) {   //NOI18N
      return platforms[i].getSpecification().getVersion().toString();
    }
  }        
  return null;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-j2me-cdc-platform

public String getSourceLevel(org.openide.filesystems.FileObject javaFile) {
  try {
  } catch (Exception e) {}
  JavaPlatform[] platforms = JavaPlatformManager.getDefault().getInstalledPlatforms ();
  for (JavaPlatform platform : platforms ) {
    if (CDCPlatform.PLATFORM_CDC.equalsIgnoreCase(platform.getSpecification().getName()) && platform.getSourceFolders().contains(javaFile)) {   //NOI18N
      return platform.getSpecification().getVersion().toString();
    }
  }        
  return null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-form-refactoring

private void packageRename(FileObject originalPkgFile) {
  FormEditorSupport fes = getFormEditorSupport();
  if (fes.isOpened()) {
    fes.closeFormEditor();
  }
  String oldName = refInfo.getOldName(originalPkgFile);
  String newName = refInfo.getNewName();
  if (refInfo.getChangeType() == RefactoringInfo.ChangeType.FOLDER_RENAME) {
    // determine full package name for renamed folder
    ClassPath cp = ClassPath.getClassPath(originalPkgFile, ClassPath.SOURCE);
    FileObject parent = originalPkgFile.getParent();
    if (cp != null && cp.contains(parent)) {
      String parentPkgName = cp.getResourceName(parent, '.', false);
      if (parentPkgName != null && parentPkgName.length() > 0) {
        oldName = parentPkgName + "." + oldName; // NOI18N
        newName = parentPkgName + "." + newName; // NOI18N
      }
    }
  }
  if (replaceClassOrPkgName(new String[] { oldName },
               new String[] { newName },
               true)
      && !isGuardedCodeChanging()) {
    // some package references in resource were changed in the form file
    // (not class names since no change in guarded code came from java
    // refactoring) and because no component has changed we can load the
    // form and regenerate to get the new resource names into code
    updateForm(true);
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

if (js != null) {
  final ClassPath scp = js.getClasspathInfo().getClassPath(PathKind.SOURCE);
  if (scp != null && scp.contains(file)) {
    js.runUserActionTask(new Task<CompilationController>() {
      @Override

代码示例来源:origin: dcaoyuan/nbscala

listener = WeakListeners.create(FileChangeListener.class, MainClassUpdater.this, current);
if (current
    != null && sourcePath.contains(current)) {
  current.addFileChangeListener(listener);

相关文章