本文整理汇总了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;
}
示例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);
}
示例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);
}
}
示例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;
}