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


Java JavaProject类代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.core.JavaProject的典型用法代码示例。如果您正苦于以下问题:Java JavaProject类的具体用法?Java JavaProject怎么用?Java JavaProject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: delete

import org.eclipse.jdt.internal.core.JavaProject; //导入依赖的package包/类
/**
 * Removes an IJavaElement's resource. Retries if deletion failed (e.g. because the indexer still
 * locks the file).
 *
 * @param elem the element to delete
 * @throws CoreException if operation failed
 * @see #ASSERT_NO_MIXED_LINE_DELIMIERS
 */
public static void delete(final IJavaElement elem) throws CoreException {
  //		if (ASSERT_NO_MIXED_LINE_DELIMIERS)
  //			MixedLineDelimiterDetector.assertNoMixedLineDelimiters(elem);
  if (elem instanceof JavaProject) {
    ((JavaProject) elem).close();
    JavaModelManager.getJavaModelManager().removePerProjectInfo((JavaProject) elem, true);
  }
  JavaModelManager.getJavaModelManager().resetTemporaryCache();
  IWorkspaceRunnable runnable =
      new IWorkspaceRunnable() {
        public void run(IProgressMonitor monitor) throws CoreException {
          //				performDummySearch();
          if (elem instanceof IJavaProject) {
            IJavaProject jproject = (IJavaProject) elem;
            jproject.setRawClasspath(
                new IClasspathEntry[0], jproject.getProject().getFullPath(), null);
          }
          delete(elem.getResource());
        }
      };
  ResourcesPlugin.getWorkspace().run(runnable, null);
  //		emptyDisplayLoop();
}
 
开发者ID:eclipse,项目名称:che,代码行数:32,代码来源:JavaProjectHelper.java

示例2: testSearchCantFindElement

import org.eclipse.jdt.internal.core.JavaProject; //导入依赖的package包/类
@Test(expected = SearchException.class)
public void testSearchCantFindElement() throws Exception {
  IPackageFragmentRoot root =
      ((JavaProject) JUnitSourceSetup.getProject())
          .getPackageFragmentRoot(new Path(JUnitSourceSetup.SRC_CONTAINER));
  IPackageFragment packageFragment = root.createPackageFragment("che", true, null);
  StringBuilder a = new StringBuilder();
  a.append("package che;\n");
  a.append("public class A{}\n");
  ICompilationUnit compilationUnitA =
      packageFragment.createCompilationUnit("A.java", a.toString(), true, null);
  SearchManager manager = new SearchManager();
  manager.findUsage(
      JUnitSourceSetup.getProject(),
      compilationUnitA.getResource().getFullPath().toOSString(),
      24);
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:FindReferencesTest.java

示例3: indexAll

import org.eclipse.jdt.internal.core.JavaProject; //导入依赖的package包/类
/**
 * Trigger addition of the entire content of a project Note: the actual operation is performed in
 * background
 */
public void indexAll(IProject project) {
  //        if (JavaCore.getPlugin() == null) return;

  // Also request indexing of binaries on the classpath
  // determine the new children
  try {
    JavaModel model = JavaModelManager.getJavaModelManager().getJavaModel();
    JavaProject javaProject = (JavaProject) model.getJavaProject(project);
    // only consider immediate libraries - each project will do the same
    // NOTE: force to resolve CP variables before calling indexer - 19303, so that initializers
    // will be run in the current thread.
    IClasspathEntry[] entries = javaProject.getResolvedClasspath();
    for (int i = 0; i < entries.length; i++) {
      IClasspathEntry entry = entries[i];
      if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY)
        indexLibrary(
            entry.getPath(), project, ((ClasspathEntry) entry).getLibraryIndexLocation());
    }
  } catch (JavaModelException e) { // cannot retrieve classpath info
  }

  // check if the same request is not already in the queue
  IndexRequest request = new IndexAllProject(project, this);
  if (!isJobWaiting(request)) request(request);
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:IndexManager.java

示例4: indexSourceFolder

import org.eclipse.jdt.internal.core.JavaProject; //导入依赖的package包/类
/** Index the content of the given source folder. */
public void indexSourceFolder(
    JavaProject javaProject,
    IPath sourceFolder,
    char[][] inclusionPatterns,
    char[][] exclusionPatterns) {
  IProject project = javaProject.getProject();
  if (this.jobEnd > this.jobStart) {
    // skip it if a job to index the project is already in the queue
    IndexRequest request = new IndexAllProject(project, this);
    if (isJobWaiting(request)) return;
  }

  request(
      new AddFolderToIndex(sourceFolder, project, inclusionPatterns, exclusionPatterns, this));
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:IndexManager.java

示例5: rebuildIndex

import org.eclipse.jdt.internal.core.JavaProject; //导入依赖的package包/类
private void rebuildIndex(IndexLocation indexLocation, IPath containerPath) {
  Object target = JavaModelManager.getTarget(containerPath, true);
  if (target == null) return;

  if (JobManager.VERBOSE)
    Util.verbose(
        "-> request to rebuild index: "
            + indexLocation
            + " path: "
            + containerPath); // $NON-NLS-1$ //$NON-NLS-2$

  updateIndexState(indexLocation, REBUILDING_STATE);
  IndexRequest request = null;
  if (target instanceof IProject) {
    IProject p = (IProject) target;
    if (JavaProject.hasJavaNature(p)) request = new IndexAllProject(p, this);
  } else if (target instanceof IFolder) {
    request = new IndexBinaryFolder((IFolder) target, this);
  } else if (target instanceof IFile) {
    request = new AddJarFileToIndex((IFile) target, null, this);
  } else if (target instanceof File) {
    request = new AddJarFileToIndex(containerPath, null, this);
  }
  if (request != null) request(request);
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:IndexManager.java

示例6: removeSourceFolderFromIndex

import org.eclipse.jdt.internal.core.JavaProject; //导入依赖的package包/类
/** Remove the content of the given source folder from the index. */
public void removeSourceFolderFromIndex(
    JavaProject javaProject,
    IPath sourceFolder,
    char[][] inclusionPatterns,
    char[][] exclusionPatterns) {
  IProject project = javaProject.getProject();
  if (this.jobEnd > this.jobStart) {
    // skip it if a job to index the project is already in the queue
    IndexRequest request = new IndexAllProject(project, this);
    if (isJobWaiting(request)) return;
  }

  request(
      new RemoveFolderFromIndex(
          sourceFolder, inclusionPatterns, exclusionPatterns, project, this));
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:IndexManager.java

示例7: getJarPkgFragmentRoot

import org.eclipse.jdt.internal.core.JavaProject; //导入依赖的package包/类
private PackageFragmentRoot getJarPkgFragmentRoot(
    IPath jarPath, Object target, IJavaProject[] projects) {
  for (int i = 0, projectCount = projects.length; i < projectCount; i++) {
    try {
      JavaProject javaProject = (JavaProject) projects[i];
      IClasspathEntry classpathEnty = javaProject.getClasspathEntryFor(jarPath);
      if (classpathEnty != null) {
        if (target instanceof IFile) {
          // internal jar
          return (PackageFragmentRoot) javaProject.getPackageFragmentRoot((IFile) target);
        } else {
          // external jar
          return (PackageFragmentRoot) javaProject.getPackageFragmentRoot0(jarPath);
        }
      }
    } catch (JavaModelException e) {
      // JavaModelException from getResolvedClasspath - a problem occurred while accessing
      // project: nothing we can do, ignore
    }
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:HandleFactory.java

示例8: getNullableRawClasspathEntryForPackageFragmentRoot

import org.eclipse.jdt.internal.core.JavaProject; //导入依赖的package包/类
public static IClasspathEntry getNullableRawClasspathEntryForPackageFragmentRoot(
    IPackageFragmentRoot root) throws JavaModelException {

  IClasspathEntry rawEntry = null;
  {
    JavaProject project = (JavaProject) root.getJavaProject();
    // force the reverse rawEntry cache to be populated
    project.getResolvedClasspath(true);
    @SuppressWarnings("rawtypes")
    Map rootPathToRawEntries = project.getPerProjectInfo().rootPathToRawEntries;
    if (rootPathToRawEntries != null) {
      rawEntry = (IClasspathEntry) rootPathToRawEntries.get(root.getPath());
    }
  }
  return rawEntry;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:17,代码来源:ClasspathUtilities.java

示例9: JavaSearchNameEnvironment

import org.eclipse.jdt.internal.core.JavaProject; //导入依赖的package包/类
public JavaSearchNameEnvironment(IJavaProject javaProject, org.eclipse.jdt.core.ICompilationUnit[] copies) {
	computeClasspathLocations(javaProject.getProject().getWorkspace().getRoot(), (JavaProject) javaProject);
	try {
		int length = copies == null ? 0 : copies.length;
		this.workingCopies = new HashMap(length);
		if (copies != null) {
			for (int i = 0; i < length; i++) {
				org.eclipse.jdt.core.ICompilationUnit workingCopy = copies[i];
				IPackageDeclaration[] pkgs = workingCopy.getPackageDeclarations();
				String pkg = pkgs.length > 0 ? pkgs[0].getElementName() : ""; //$NON-NLS-1$
				String cuName = workingCopy.getElementName();
				String mainTypeName = Util.getNameWithoutJavaLikeExtension(cuName);
				String qualifiedMainTypeName = pkg.length() == 0 ? mainTypeName : pkg.replace('.', '/') + '/' + mainTypeName;
				this.workingCopies.put(qualifiedMainTypeName, workingCopy);
			}
		}
	} catch (JavaModelException e) {
		// working copy doesn't exist: cannot happen
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:JavaSearchNameEnvironment.java

示例10: locateMatches

import org.eclipse.jdt.internal.core.JavaProject; //导入依赖的package包/类
/**
 * Locate the matches amongst the possible matches.
 */
protected void locateMatches(JavaProject javaProject, PossibleMatchSet matchSet, int expected) throws CoreException {
	PossibleMatch[] possibleMatches = matchSet.getPossibleMatches(javaProject.getPackageFragmentRoots());
	int length = possibleMatches.length;
	// increase progress from duplicate matches not stored in matchSet while adding...
	if (this.progressMonitor != null && expected>length) {
		this.progressWorked += expected-length;
		this.progressMonitor.worked( expected-length);
	}
	// locate matches (processed matches are limited to avoid problem while using VM default memory heap size)
	for (int index = 0; index < length;) {
		int max = Math.min(MAX_AT_ONCE, length - index);
		locateMatches(javaProject, possibleMatches, index, max);
		index += max;
	}
	this.patternLocator.clear();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:MatchLocator.java

示例11: injectAllOpenablesForJavaProject

import org.eclipse.jdt.internal.core.JavaProject; //导入依赖的package包/类
/**
 * Adds all of the openables defined within this java project to the
 * list.
 */
private void injectAllOpenablesForJavaProject(
	IJavaProject project,
	ArrayList openables) {
	try {
		IPackageFragmentRoot[] devPathRoots =
			((JavaProject) project).getPackageFragmentRoots();
		if (devPathRoots == null) {
			return;
		}
		for (int j = 0; j < devPathRoots.length; j++) {
			IPackageFragmentRoot root = devPathRoots[j];
			injectAllOpenablesForPackageFragmentRoot(root, openables);
		}
	} catch (JavaModelException e) {
		// ignore
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:RegionBasedHierarchyBuilder.java

示例12: getClasspath

import org.eclipse.jdt.internal.core.JavaProject; //导入依赖的package包/类
/**
 * Returns the class path.
 */
public IClasspathEntry[] getClasspath(IPath projectPath) {
	try {
		checkAssertion("a workspace must be open", this.isOpen); //$NON-NLS-1$
		JavaProject javaProject = (JavaProject) JavaCore.create(getProject(projectPath));
		return javaProject.getExpandedClasspath();
		//			IPath[] packageFragmentRootsPath = new IPath[entries.length];
		//			for (int i = 0; i < entries.length; ++i)
		//				packageFragmentRootsPath[i] = entries[i].getPath();
		//			return packageFragmentRootsPath;
	} catch (JavaModelException e) {
		e.printStackTrace();
		checkAssertion("JavaModelException", false); //$NON-NLS-1$
		return null; // not reachable
	}
}
 
开发者ID:vogellacompany,项目名称:codemodify,代码行数:19,代码来源:TestingEnvironment.java

示例13: takeSnapshot

import org.eclipse.jdt.internal.core.JavaProject; //导入依赖的package包/类
@SuppressWarnings("restriction")
public String takeSnapshot(final IProject project) {
	if (!isProjectKnown(project))
		knowProject(project);
	
	final String zipFileName = project.getName() + "-" + System.currentTimeMillis() + ".zip";
	final String zipFile = parentDirectory + File.separator + zipFileName;
	Job snapshotJob = new Job("Taking snapshot of " + project.getName()) {
		
		@Override
		protected IStatus run(IProgressMonitor monitor) {
			monitor.beginTask("Taking snapshot of " + project.getName(), 1);
			archiveProjectToFile(project, zipFile);
			clientRecorder.recordSnapshot(zipFileName);
			if (JavaProject.hasJavaNature(project)) {
				IJavaProject javaProject = addExternalLibrariesToZipFile(project, zipFile);
				snapshotRequiredProjects(javaProject);
			}
			monitor.done();
			return Status.OK_STATUS;
		}
	};
	snapshotJob.setRule(project);
	snapshotJob.schedule();
	return zipFile;
}
 
开发者ID:ChangeOrientedProgrammingEnvironment,项目名称:eclipseRecorder,代码行数:27,代码来源:SnapshotManager.java

示例14: getIFile

import org.eclipse.jdt.internal.core.JavaProject; //导入依赖的package包/类
public static IFile getIFile(SourceLocation location) {
  IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();

  for (IProject project : projects) {
    if (project.isOpen() && JavaProject.hasJavaNature(project)) {
      final IJavaProject javaProject = JavaCore.create(project);
      final String filePath = location.getPackageName().replace(".", File.separator);
      try {
        for (IPackageFragmentRoot fragmentRoot : javaProject.getAllPackageFragmentRoots()) {
          if (fragmentRoot.getElementType() == IJavaElement.PACKAGE_FRAGMENT_ROOT && !fragmentRoot.isArchive()) {

            final Path path = Paths.get(fragmentRoot.getResource().getProjectRelativePath().toOSString(), filePath,
                location.getFileName());

            final IFile file = project.getFile(path.toString());

            if (file.exists()) {
              return file;
            }
          }
        }
      } catch (JavaModelException e) {
        MessageDialog.openError(null, "Error occurred", e.getMessage());
      }
    }
  }
  return null;
}
 
开发者ID:k0ner,项目名称:olv-eclipse-integration,代码行数:29,代码来源:OpenPageEditor.java

示例15: init

import org.eclipse.jdt.internal.core.JavaProject; //导入依赖的package包/类
public void init(IWorkbench workbench, IStructuredSelection selection) {
    Object[] jprojects = selection.toArray();
    selectedJavaProjects = new String[jprojects.length];
    for (int i=0; i<jprojects.length; i++) {
        selectedJavaProjects[i] = ((JavaProject)jprojects[i]).getProject().getName();
    }
}
 
开发者ID:thahn0720,项目名称:agui_eclipse_plugin,代码行数:8,代码来源:FJExpWizard.java


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