本文整理汇总了Java中org.eclipse.jdt.internal.corext.refactoring.changes.MoveCompilationUnitChange类的典型用法代码示例。如果您正苦于以下问题:Java MoveCompilationUnitChange类的具体用法?Java MoveCompilationUnitChange怎么用?Java MoveCompilationUnitChange使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MoveCompilationUnitChange类属于org.eclipse.jdt.internal.corext.refactoring.changes包,在下文中一共展示了MoveCompilationUnitChange类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareMoveChange
import org.eclipse.jdt.internal.corext.refactoring.changes.MoveCompilationUnitChange; //导入依赖的package包/类
private void prepareMoveChange(
ChangeInfo changeInfo, org.eclipse.ltk.core.refactoring.Change ch) {
changeInfo.setName(ChangeInfo.ChangeName.MOVE);
for (org.eclipse.ltk.core.refactoring.Change change : ((CompositeChange) ch).getChildren()) {
if (change instanceof MoveCompilationUnitChange) {
MoveCompilationUnitChange moveChange = (MoveCompilationUnitChange) change;
String className = moveChange.getCu().getPath().lastSegment();
changeInfo.setPath(
moveChange.getDestinationPackage().getPath().append(className).toString());
changeInfo.setOldPath(
((CompilationUnit) change.getModifiedElement()).getPath().toString());
}
}
}
示例2: prepareMoveChange
import org.eclipse.jdt.internal.corext.refactoring.changes.MoveCompilationUnitChange; //导入依赖的package包/类
private void prepareMoveChange(ChangeInfo changeInfo, Change ch) {
changeInfo.setName(ChangeInfo.ChangeName.MOVE);
if (ch instanceof MoveCompilationUnitChange) {
MoveCompilationUnitChange moveChange = (MoveCompilationUnitChange) ch;
String className = moveChange.getCu().getPath().lastSegment();
changeInfo.setOldPath(
moveChange.getDestinationPackage().getPath().append(className).toString());
changeInfo.setPath(((CompilationUnit) ch.getModifiedElement()).getPath().toString());
}
}
示例3: moveCuToPackage
import org.eclipse.jdt.internal.corext.refactoring.changes.MoveCompilationUnitChange; //导入依赖的package包/类
private static Change moveCuToPackage(ICompilationUnit cu, IPackageFragment dest) {
// XXX workaround for bug 31998 we will have to disable renaming of
// linked packages (and cus)
IResource resource = cu.getResource();
if (resource != null && resource.isLinked()) {
if (ResourceUtil.getResource(dest) instanceof IContainer)
return moveFileToContainer(cu, (IContainer) ResourceUtil.getResource(dest));
}
return new MoveCompilationUnitChange(cu, dest);
}
示例4: moveCuToPackage
import org.eclipse.jdt.internal.corext.refactoring.changes.MoveCompilationUnitChange; //导入依赖的package包/类
private static Change moveCuToPackage(ICompilationUnit cu, IPackageFragment dest) {
// XXX workaround for bug 31998 we will have to disable renaming of
// linked packages (and cus)
IResource resource= cu.getResource();
if (resource != null && resource.isLinked()) {
if (ResourceUtil.getResource(dest) instanceof IContainer)
return moveFileToContainer(cu, (IContainer) ResourceUtil.getResource(dest));
}
return new MoveCompilationUnitChange(cu, dest);
}
示例5: getWrongPackageDeclNameProposals
import org.eclipse.jdt.internal.corext.refactoring.changes.MoveCompilationUnitChange; //导入依赖的package包/类
public static void getWrongPackageDeclNameProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) throws CoreException {
ICompilationUnit cu= context.getCompilationUnit();
boolean isLinked= cu.getResource().isLinked();
// correct package declaration
int relevance= cu.getPackageDeclarations().length == 0 ? IProposalRelevance.MISSING_PACKAGE_DECLARATION : IProposalRelevance.CORRECT_PACKAGE_DECLARATION; // bug 38357
proposals.add(new CorrectPackageDeclarationProposal(cu, problem, relevance));
// move to package
IPackageDeclaration[] packDecls= cu.getPackageDeclarations();
String newPackName= packDecls.length > 0 ? packDecls[0].getElementName() : ""; //$NON-NLS-1$
IPackageFragmentRoot root= JavaModelUtil.getPackageFragmentRoot(cu);
IPackageFragment newPack= root.getPackageFragment(newPackName);
ICompilationUnit newCU= newPack.getCompilationUnit(cu.getElementName());
if (!newCU.exists() && !isLinked) {
String label;
if (newPack.isDefaultPackage()) {
label= Messages.format(CorrectionMessages.ReorgCorrectionsSubProcessor_movecu_default_description, BasicElementLabels.getFileName(cu));
} else {
String packageLabel= JavaElementLabels.getElementLabel(newPack, JavaElementLabels.ALL_DEFAULT);
label= Messages.format(CorrectionMessages.ReorgCorrectionsSubProcessor_movecu_description, new Object[] { BasicElementLabels.getFileName(cu), packageLabel });
}
CompositeChange composite= new CompositeChange(label);
composite.add(new CreatePackageChange(newPack));
composite.add(new MoveCompilationUnitChange(cu, newPack));
proposals.add(new ChangeCorrectionProposal(label, composite, IProposalRelevance.MOVE_CU_TO_PACKAGE, JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_MOVE)));
}
}
示例6: getWrongPackageDeclNameProposals
import org.eclipse.jdt.internal.corext.refactoring.changes.MoveCompilationUnitChange; //导入依赖的package包/类
public static void getWrongPackageDeclNameProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) throws CoreException {
ICompilationUnit cu= context.getCompilationUnit();
boolean isLinked= cu.getResource().isLinked();
// correct package declaration
int relevance= cu.getPackageDeclarations().length == 0 ? 7 : 5; // bug 38357
proposals.add(new CorrectPackageDeclarationProposal(cu, problem, relevance));
// move to package
IPackageDeclaration[] packDecls= cu.getPackageDeclarations();
String newPackName= packDecls.length > 0 ? packDecls[0].getElementName() : ""; //$NON-NLS-1$
IPackageFragmentRoot root= JavaModelUtil.getPackageFragmentRoot(cu);
IPackageFragment newPack= root.getPackageFragment(newPackName);
ICompilationUnit newCU= newPack.getCompilationUnit(cu.getElementName());
if (!newCU.exists() && !isLinked) {
String label;
if (newPack.isDefaultPackage()) {
label= Messages.format(CorrectionMessages.ReorgCorrectionsSubProcessor_movecu_default_description, BasicElementLabels.getFileName(cu));
} else {
String packageLabel= JavaElementLabels.getElementLabel(newPack, JavaElementLabels.ALL_DEFAULT);
label= Messages.format(CorrectionMessages.ReorgCorrectionsSubProcessor_movecu_description, new Object[] { BasicElementLabels.getFileName(cu), packageLabel });
}
CompositeChange composite= new CompositeChange(label);
composite.add(new CreatePackageChange(newPack));
composite.add(new MoveCompilationUnitChange(cu, newPack));
proposals.add(new ChangeCorrectionProposal(label, composite, 6, JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_MOVE)));
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:32,代码来源:ReorgCorrectionsSubProcessor.java
示例7: getWrongPackageDeclNameProposals
import org.eclipse.jdt.internal.corext.refactoring.changes.MoveCompilationUnitChange; //导入依赖的package包/类
public static void getWrongPackageDeclNameProposals(
IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals)
throws CoreException {
ICompilationUnit cu = context.getCompilationUnit();
boolean isLinked = cu.getResource().isLinked();
// correct package declaration
int relevance =
cu.getPackageDeclarations().length == 0
? IProposalRelevance.MISSING_PACKAGE_DECLARATION
: IProposalRelevance.CORRECT_PACKAGE_DECLARATION; // bug 38357
proposals.add(new CorrectPackageDeclarationProposal(cu, problem, relevance));
// move to package
IPackageDeclaration[] packDecls = cu.getPackageDeclarations();
String newPackName = packDecls.length > 0 ? packDecls[0].getElementName() : ""; // $NON-NLS-1$
IPackageFragmentRoot root = JavaModelUtil.getPackageFragmentRoot(cu);
IPackageFragment newPack = root.getPackageFragment(newPackName);
ICompilationUnit newCU = newPack.getCompilationUnit(cu.getElementName());
if (!newCU.exists() && !isLinked) {
String label;
if (newPack.isDefaultPackage()) {
label =
Messages.format(
CorrectionMessages.ReorgCorrectionsSubProcessor_movecu_default_description,
BasicElementLabels.getFileName(cu));
} else {
String packageLabel =
JavaElementLabels.getElementLabel(newPack, JavaElementLabels.ALL_DEFAULT);
label =
Messages.format(
CorrectionMessages.ReorgCorrectionsSubProcessor_movecu_description,
new Object[] {BasicElementLabels.getFileName(cu), packageLabel});
}
CompositeChange composite = new CompositeChange(label);
composite.add(new CreatePackageChange(newPack));
composite.add(new MoveCompilationUnitChange(cu, newPack));
proposals.add(
new ChangeCorrectionProposal(
label,
composite,
IProposalRelevance.MOVE_CU_TO_PACKAGE,
JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_MOVE)));
}
}