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


Java JavaElementUtil.getReferencingProjects方法代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil.getReferencingProjects方法的典型用法代码示例。如果您正苦于以下问题:Java JavaElementUtil.getReferencingProjects方法的具体用法?Java JavaElementUtil.getReferencingProjects怎么用?Java JavaElementUtil.getReferencingProjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil的用法示例。


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

示例1: getUpdateModelFlags

import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; //导入方法依赖的package包/类
protected int getUpdateModelFlags(boolean isCopy) throws JavaModelException {
  final int destination = IPackageFragmentRoot.DESTINATION_PROJECT_CLASSPATH;
  final int replace = IPackageFragmentRoot.REPLACE;
  final int originating;
  final int otherProjects;
  if (isCopy) {
    originating = 0; // ORIGINATING_PROJECT_CLASSPATH does not apply to copy
    otherProjects = 0; // OTHER_REFERRING_PROJECTS_CLASSPATH does not apply to copy
  } else {
    originating = IPackageFragmentRoot.ORIGINATING_PROJECT_CLASSPATH;
    otherProjects = IPackageFragmentRoot.OTHER_REFERRING_PROJECTS_CLASSPATH;
  }

  IJavaElement javaElement = JavaCore.create(getDestination());
  if (javaElement == null || !javaElement.exists()) return replace | originating;

  if (fUpdateClasspathQuery == null) return replace | originating | destination;

  IJavaProject[] referencingProjects = JavaElementUtil.getReferencingProjects(getRoot());
  if (referencingProjects.length <= 1) return replace | originating | destination;

  boolean updateOtherProjectsToo =
      fUpdateClasspathQuery.confirmManipulation(getRoot(), referencingProjects);
  if (updateOtherProjectsToo) return replace | originating | destination | otherProjects;
  else return replace | originating | destination;
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:PackageFragmentRootReorgChange.java

示例2: confirmDeleteIfReferenced

import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; //导入方法依赖的package包/类
private boolean confirmDeleteIfReferenced() throws JavaModelException {
  IPackageFragmentRoot root = getRoot();
  if (!root.isArchive() && !root.isExternal()) // for source folders, you don't ask, just do it
  return true;
  if (fUpdateClasspathQuery == null) return true;
  IJavaProject[] referencingProjects = JavaElementUtil.getReferencingProjects(getRoot());
  if (referencingProjects.length <= 1) return true;
  return fUpdateClasspathQuery.confirmManipulation(getRoot(), referencingProjects);
}
 
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:DeletePackageFragmentRootChange.java

示例3: delete

import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; //导入方法依赖的package包/类
public void delete(IJavaElement element) throws CoreException {
	switch(element.getElementType()) {
		case IJavaElement.JAVA_MODEL:
			return;
		case IJavaElement.JAVA_PROJECT:
			fDelete.add(element);
			if (element.getResource() != null)
				getResourceModifications().addDelete(element.getResource());
			return;
		case IJavaElement.PACKAGE_FRAGMENT_ROOT:
			fDelete.add(element);
			IResource resource= element.getResource();
			// Flag an resource change even if we have an archive. If it is
			// internal (we have a underlying resource then we have a resource
			// change.
			if (resource != null)
				getResourceModifications().addDelete(resource);
			IJavaProject[] referencingProjects= JavaElementUtil.getReferencingProjects((IPackageFragmentRoot) element);
			for (int i= 0; i < referencingProjects.length; i++) {
				IFile classpath= referencingProjects[i].getProject().getFile(".classpath"); //$NON-NLS-1$
				getResourceModifications().addChanged(classpath);
			}
			return;
		case IJavaElement.PACKAGE_FRAGMENT:
			fDelete.add(element);
			fPackagesToDelete.add((IPackageFragment) element);
			return;
		case IJavaElement.COMPILATION_UNIT:
			fDelete.add(element);
			IType[] types= ((ICompilationUnit)element).getTypes();
			fDelete.addAll(Arrays.asList(types));
			if (element.getResource() != null)
				getResourceModifications().addDelete(element.getResource());
			return;
		default:
			fDelete.add(element);
	}

}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:40,代码来源:DeleteModifications.java

示例4: doDelete

import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; //导入方法依赖的package包/类
@Override
protected Change doDelete(IProgressMonitor pm) throws CoreException {
	if (! confirmDeleteIfReferenced())
		return new NullChange();
	int resourceUpdateFlags= IResource.KEEP_HISTORY;
	int jCoreUpdateFlags= IPackageFragmentRoot.ORIGINATING_PROJECT_CLASSPATH | IPackageFragmentRoot.OTHER_REFERRING_PROJECTS_CLASSPATH;

	pm.beginTask("", 2); //$NON-NLS-1$
	IPackageFragmentRoot root= getRoot();
	IResource rootResource= root.getResource();
	CompositeChange result= new CompositeChange(getName());

	ResourceDescription rootDescription = ResourceDescription.fromResource(rootResource);
	IJavaProject[] referencingProjects= JavaElementUtil.getReferencingProjects(root);
	HashMap<IFile, String> classpathFilesContents= new HashMap<IFile, String>();
	for (int i= 0; i < referencingProjects.length; i++) {
		IJavaProject javaProject= referencingProjects[i];
		IFile classpathFile= javaProject.getProject().getFile(".classpath"); //$NON-NLS-1$
		if (classpathFile.exists()) {
			classpathFilesContents.put(classpathFile, getFileContents(classpathFile));
		}
	}

	root.delete(resourceUpdateFlags, jCoreUpdateFlags, new SubProgressMonitor(pm, 1));

	rootDescription.recordStateFromHistory(rootResource, new SubProgressMonitor(pm, 1));
	for (Iterator<Entry<IFile, String>> iterator= classpathFilesContents.entrySet().iterator(); iterator.hasNext();) {
		Entry<IFile, String> entry= iterator.next();
		IFile file= entry.getKey();
		String contents= entry.getValue();
		//Restore time stamps? This should probably be some sort of UndoTextFileChange.
		TextFileChange classpathUndo= new TextFileChange(Messages.format(RefactoringCoreMessages.DeletePackageFragmentRootChange_restore_file, BasicElementLabels.getPathLabel(file.getFullPath(), true)), file);
		classpathUndo.setEdit(new ReplaceEdit(0, getFileLength(file), contents));
		result.add(classpathUndo);
	}
	result.add(new UndoDeleteResourceChange(rootDescription));

	pm.done();
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:41,代码来源:DeletePackageFragmentRootChange.java

示例5: confirmDeleteIfReferenced

import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; //导入方法依赖的package包/类
private boolean confirmDeleteIfReferenced() throws JavaModelException {
	IPackageFragmentRoot root= getRoot();
	if (!root.isArchive() && !root.isExternal()) //for source folders, you don't ask, just do it
		return true;
	if (fUpdateClasspathQuery == null)
		return true;
	IJavaProject[] referencingProjects= JavaElementUtil.getReferencingProjects(getRoot());
	if (referencingProjects.length <= 1)
		return true;
	return fUpdateClasspathQuery.confirmManipulation(getRoot(), referencingProjects);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:DeletePackageFragmentRootChange.java

示例6: getUpdateModelFlags

import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; //导入方法依赖的package包/类
protected int getUpdateModelFlags(boolean isCopy) throws JavaModelException{
	final int destination= IPackageFragmentRoot.DESTINATION_PROJECT_CLASSPATH;
	final int replace= IPackageFragmentRoot.REPLACE;
	final int originating;
	final int otherProjects;
	if (isCopy){
		originating= 0; //ORIGINATING_PROJECT_CLASSPATH does not apply to copy
		otherProjects= 0;//OTHER_REFERRING_PROJECTS_CLASSPATH does not apply to copy
	} else{
		originating= IPackageFragmentRoot.ORIGINATING_PROJECT_CLASSPATH;
		otherProjects= IPackageFragmentRoot.OTHER_REFERRING_PROJECTS_CLASSPATH;
	}

	IJavaElement javaElement= JavaCore.create(getDestination());
	if (javaElement == null || !javaElement.exists())
		return replace | originating;

	if (fUpdateClasspathQuery == null)
		return replace | originating | destination;

	IJavaProject[] referencingProjects= JavaElementUtil.getReferencingProjects(getRoot());
	if (referencingProjects.length <= 1)
		return replace | originating | destination;

	boolean updateOtherProjectsToo= fUpdateClasspathQuery.confirmManipulation(getRoot(), referencingProjects);
	if (updateOtherProjectsToo)
		return replace | originating | destination | otherProjects;
	else
		return replace | originating | destination;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:31,代码来源:PackageFragmentRootReorgChange.java

示例7: doDelete

import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; //导入方法依赖的package包/类
@Override
protected Change doDelete(IProgressMonitor pm) throws CoreException {
  if (!confirmDeleteIfReferenced()) return new NullChange();
  int resourceUpdateFlags = IResource.KEEP_HISTORY;
  int jCoreUpdateFlags =
      IPackageFragmentRoot.ORIGINATING_PROJECT_CLASSPATH
          | IPackageFragmentRoot.OTHER_REFERRING_PROJECTS_CLASSPATH;

  pm.beginTask("", 2); // $NON-NLS-1$
  IPackageFragmentRoot root = getRoot();
  IResource rootResource = root.getResource();
  CompositeChange result = new CompositeChange(getName());

  ResourceDescription rootDescription = ResourceDescription.fromResource(rootResource);
  IJavaProject[] referencingProjects = JavaElementUtil.getReferencingProjects(root);
  HashMap<IFile, String> classpathFilesContents = new HashMap<IFile, String>();
  for (int i = 0; i < referencingProjects.length; i++) {
    IJavaProject javaProject = referencingProjects[i];
    IFile classpathFile = javaProject.getProject().getFile(".classpath"); // $NON-NLS-1$
    if (classpathFile.exists()) {
      classpathFilesContents.put(classpathFile, getFileContents(classpathFile));
    }
  }

  root.delete(resourceUpdateFlags, jCoreUpdateFlags, new SubProgressMonitor(pm, 1));

  rootDescription.recordStateFromHistory(rootResource, new SubProgressMonitor(pm, 1));
  for (Iterator<Entry<IFile, String>> iterator = classpathFilesContents.entrySet().iterator();
      iterator.hasNext(); ) {
    Entry<IFile, String> entry = iterator.next();
    IFile file = entry.getKey();
    String contents = entry.getValue();
    // Restore time stamps? This should probably be some sort of UndoTextFileChange.
    TextFileChange classpathUndo =
        new TextFileChange(
            Messages.format(
                RefactoringCoreMessages.DeletePackageFragmentRootChange_restore_file,
                BasicElementLabels.getPathLabel(file.getFullPath(), true)),
            file);
    classpathUndo.setEdit(new ReplaceEdit(0, getFileLength(file), contents));
    result.add(classpathUndo);
  }
  result.add(new UndoDeleteResourceChange(rootDescription));

  pm.done();
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:48,代码来源:DeletePackageFragmentRootChange.java


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