本文整理汇总了Java中org.eclipse.jdt.internal.corext.refactoring.util.TightSourceRangeComputer类的典型用法代码示例。如果您正苦于以下问题:Java TightSourceRangeComputer类的具体用法?Java TightSourceRangeComputer怎么用?Java TightSourceRangeComputer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TightSourceRangeComputer类属于org.eclipse.jdt.internal.corext.refactoring.util包,在下文中一共展示了TightSourceRangeComputer类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeTemp
import org.eclipse.jdt.internal.corext.refactoring.util.TightSourceRangeComputer; //导入依赖的package包/类
private void removeTemp(CompilationUnitRewrite cuRewrite) {
VariableDeclaration variableDeclaration = getVariableDeclaration();
TextEditGroup groupDesc =
cuRewrite.createGroupDescription(
RefactoringCoreMessages.InlineTempRefactoring_remove_edit_name);
ASTNode parent = variableDeclaration.getParent();
ASTRewrite rewrite = cuRewrite.getASTRewrite();
TightSourceRangeComputer sourceRangeComputer = new TightSourceRangeComputer();
rewrite.setTargetSourceRangeComputer(sourceRangeComputer);
if (parent instanceof VariableDeclarationStatement
&& ((VariableDeclarationStatement) parent).fragments().size() == 1) {
sourceRangeComputer.addTightSourceNode(parent);
rewrite.remove(parent, groupDesc);
} else {
sourceRangeComputer.addTightSourceNode(variableDeclaration);
rewrite.remove(variableDeclaration, groupDesc);
}
}
示例2: InlineTargetCompilationUnit
import org.eclipse.jdt.internal.corext.refactoring.util.TightSourceRangeComputer; //导入依赖的package包/类
private InlineTargetCompilationUnit(
CompilationUnitRewrite cuRewrite,
Name[] references,
InlineConstantRefactoring refactoring,
HashSet<SimpleName> staticImportsInInitializer) {
fInitializer = refactoring.getInitializer();
fInitializerUnit = refactoring.getDeclaringCompilationUnit();
fCuRewrite = cuRewrite;
fSourceRangeComputer = new TightSourceRangeComputer();
fCuRewrite.getASTRewrite().setTargetSourceRangeComputer(fSourceRangeComputer);
if (refactoring.getRemoveDeclaration()
&& refactoring.getReplaceAllReferences()
&& cuRewrite.getCu().equals(fInitializerUnit))
fDeclarationToRemove = refactoring.getDeclaration();
else fDeclarationToRemove = null;
fOriginalDeclaration = refactoring.getDeclaration();
fReferences = new Expression[references.length];
for (int i = 0; i < references.length; i++)
fReferences[i] = getQualifiedReference(references[i]);
fIs15 = JavaModelUtil.is50OrHigher(cuRewrite.getCu().getJavaProject());
fStaticImportsInInitializer = fIs15 ? staticImportsInInitializer : new HashSet<SimpleName>(0);
}
示例3: InlineTargetCompilationUnit
import org.eclipse.jdt.internal.corext.refactoring.util.TightSourceRangeComputer; //导入依赖的package包/类
private InlineTargetCompilationUnit(CompilationUnitRewrite cuRewrite, Name[] references, InlineConstantRefactoring refactoring, HashSet<SimpleName> staticImportsInInitializer) {
fInitializer= refactoring.getInitializer();
fInitializerUnit= refactoring.getDeclaringCompilationUnit();
fCuRewrite= cuRewrite;
fSourceRangeComputer= new TightSourceRangeComputer();
fCuRewrite.getASTRewrite().setTargetSourceRangeComputer(fSourceRangeComputer);
if (refactoring.getRemoveDeclaration() && refactoring.getReplaceAllReferences() && cuRewrite.getCu().equals(fInitializerUnit))
fDeclarationToRemove= refactoring.getDeclaration();
else
fDeclarationToRemove= null;
fOriginalDeclaration= refactoring.getDeclaration();
fReferences= new Expression[references.length];
for (int i= 0; i < references.length; i++)
fReferences[i]= getQualifiedReference(references[i]);
fIs15= JavaModelUtil.is50OrHigher(cuRewrite.getCu().getJavaProject());
fStaticImportsInInitializer= fIs15 ? staticImportsInInitializer : new HashSet<SimpleName>(0);
}
示例4: removeTemp
import org.eclipse.jdt.internal.corext.refactoring.util.TightSourceRangeComputer; //导入依赖的package包/类
private void removeTemp(CompilationUnitRewrite cuRewrite) {
VariableDeclaration variableDeclaration= getVariableDeclaration();
TextEditGroup groupDesc= cuRewrite.createGroupDescription(RefactoringCoreMessages.InlineTempRefactoring_remove_edit_name);
ASTNode parent= variableDeclaration.getParent();
ASTRewrite rewrite= cuRewrite.getASTRewrite();
TightSourceRangeComputer sourceRangeComputer= new TightSourceRangeComputer();
rewrite.setTargetSourceRangeComputer(sourceRangeComputer);
if (parent instanceof VariableDeclarationStatement && ((VariableDeclarationStatement) parent).fragments().size() == 1) {
sourceRangeComputer.addTightSourceNode(parent);
rewrite.remove(parent, groupDesc);
} else {
sourceRangeComputer.addTightSourceNode(variableDeclaration);
rewrite.remove(variableDeclaration, groupDesc);
}
}
示例5: checkFinalConditions
import org.eclipse.jdt.internal.corext.refactoring.util.TightSourceRangeComputer; //导入依赖的package包/类
@Override
public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context)
throws CoreException, OperationCanceledException {
try {
pm.beginTask(RefactoringCoreMessages.ChangeSignatureRefactoring_checking_preconditions, 8);
RefactoringStatus result = new RefactoringStatus();
clearManagers();
fBaseCuRewrite.clearASTAndImportRewrites();
fBaseCuRewrite.getASTRewrite().setTargetSourceRangeComputer(new TightSourceRangeComputer());
if (isSignatureSameAsInitial())
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ChangeSignatureRefactoring_unchanged);
result.merge(checkSignature(true));
if (result.hasFatalError()) return result;
if (fDelegateUpdating && isSignatureClashWithInitial())
result.merge(
RefactoringStatus.createErrorStatus(
RefactoringCoreMessages
.ChangeSignatureRefactoring_old_and_new_signatures_not_sufficiently_different));
String binaryRefsDescription =
Messages.format(
RefactoringCoreMessages.ReferencesInBinaryContext_ref_in_binaries_description,
BasicElementLabels.getJavaElementName(getMethodName()));
ReferencesInBinaryContext binaryRefs = new ReferencesInBinaryContext(binaryRefsDescription);
fRippleMethods =
RippleMethodFinder2.getRelatedMethods(
fMethod, binaryRefs, new SubProgressMonitor(pm, 1), null);
result.merge(checkVarargs());
if (result.hasFatalError()) return result;
fOccurrences = findOccurrences(new SubProgressMonitor(pm, 1), binaryRefs, result);
binaryRefs.addErrorIfNecessary(result);
result.merge(checkVisibilityChanges());
result.merge(checkTypeVariables());
// TODO:
// We need a common way of dealing with possible compilation errors for all occurrences,
// including visibility problems, shadowing and missing throws declarations.
if (!isOrderSameAsInitial()) result.merge(checkReorderings(new SubProgressMonitor(pm, 1)));
else pm.worked(1);
// TODO (bug 58616): check whether changed signature already exists somewhere in the ripple,
// - error if exists
// - warn if exists with different parameter types (may cause overloading)
if (!areNamesSameAsInitial()) result.merge(checkRenamings(new SubProgressMonitor(pm, 1)));
else pm.worked(1);
if (result.hasFatalError()) return result;
// resolveTypesWithoutBindings(new SubProgressMonitor(pm, 1)); // already done in
// checkSignature(true)
createChangeManager(new SubProgressMonitor(pm, 1), result);
fCachedTypeHierarchy = null;
if (mustAnalyzeAstOfDeclaringCu())
result.merge(
checkCompilationofDeclaringCu()); // TODO: should also check in ripple methods (move
// into createChangeManager)
if (result.hasFatalError()) return result;
Checks.addModifiedFilesToChecker(getAllFilesToModify(), context);
return result;
} finally {
pm.done();
}
}
示例6: createChangeManager
import org.eclipse.jdt.internal.corext.refactoring.util.TightSourceRangeComputer; //导入依赖的package包/类
private TextChangeManager createChangeManager(IProgressMonitor pm, RefactoringStatus result)
throws CoreException {
pm.beginTask(RefactoringCoreMessages.ChangeSignatureRefactoring_preview, 2);
fChangeManager = new TextChangeManager();
boolean isNoArgConstructor = isNoArgConstructor();
Map<ICompilationUnit, Set<IType>> namedSubclassMapping = null;
if (isNoArgConstructor) {
// create only when needed;
namedSubclassMapping = createNamedSubclassMapping(new SubProgressMonitor(pm, 1));
} else {
pm.worked(1);
}
for (int i = 0; i < fOccurrences.length; i++) {
if (pm.isCanceled()) throw new OperationCanceledException();
SearchResultGroup group = fOccurrences[i];
ICompilationUnit cu = group.getCompilationUnit();
if (cu == null) continue;
CompilationUnitRewrite cuRewrite;
if (cu.equals(getCu())) {
cuRewrite = fBaseCuRewrite;
} else {
cuRewrite = new CompilationUnitRewrite(cu);
cuRewrite.getASTRewrite().setTargetSourceRangeComputer(new TightSourceRangeComputer());
}
ASTNode[] nodes = ASTNodeSearchUtil.findNodes(group.getSearchResults(), cuRewrite.getRoot());
// IntroduceParameterObjectRefactoring needs to update declarations first:
List<OccurrenceUpdate<? extends ASTNode>> deferredUpdates =
new ArrayList<OccurrenceUpdate<? extends ASTNode>>();
for (int j = 0; j < nodes.length; j++) {
OccurrenceUpdate<? extends ASTNode> update =
createOccurrenceUpdate(nodes[j], cuRewrite, result);
if (update instanceof DeclarationUpdate) {
update.updateNode();
} else {
deferredUpdates.add(update);
}
}
for (Iterator<OccurrenceUpdate<? extends ASTNode>> iter = deferredUpdates.iterator();
iter.hasNext(); ) {
iter.next().updateNode();
}
if (isNoArgConstructor && namedSubclassMapping.containsKey(cu)) {
// only non-anonymous subclasses may have noArgConstructors to modify - see bug 43444
Set<IType> subtypes = namedSubclassMapping.get(cu);
for (Iterator<IType> iter = subtypes.iterator(); iter.hasNext(); ) {
IType subtype = iter.next();
AbstractTypeDeclaration subtypeNode =
ASTNodeSearchUtil.getAbstractTypeDeclarationNode(subtype, cuRewrite.getRoot());
if (subtypeNode != null) modifyImplicitCallsToNoArgConstructor(subtypeNode, cuRewrite);
}
}
TextChange change = cuRewrite.createChange(true);
if (change != null) fChangeManager.manage(cu, change);
}
pm.done();
return fChangeManager;
}
示例7: getTightSourceRangeComputer
import org.eclipse.jdt.internal.corext.refactoring.util.TightSourceRangeComputer; //导入依赖的package包/类
protected final TightSourceRangeComputer getTightSourceRangeComputer() {
return (TightSourceRangeComputer) fCuRewrite.getASTRewrite().getExtendedSourceRangeComputer();
}
示例8: checkFinalConditions
import org.eclipse.jdt.internal.corext.refactoring.util.TightSourceRangeComputer; //导入依赖的package包/类
@Override
public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException, OperationCanceledException {
try {
pm.beginTask(RefactoringCoreMessages.ChangeSignatureRefactoring_checking_preconditions, 8);
RefactoringStatus result= new RefactoringStatus();
clearManagers();
fBaseCuRewrite.clearASTAndImportRewrites();
fBaseCuRewrite.getASTRewrite().setTargetSourceRangeComputer(new TightSourceRangeComputer());
if (isSignatureSameAsInitial())
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ChangeSignatureRefactoring_unchanged);
result.merge(checkSignature(true));
if (result.hasFatalError())
return result;
if (fDelegateUpdating && isSignatureClashWithInitial())
result.merge(RefactoringStatus.createErrorStatus(RefactoringCoreMessages.ChangeSignatureRefactoring_old_and_new_signatures_not_sufficiently_different ));
String binaryRefsDescription= Messages.format(RefactoringCoreMessages.ReferencesInBinaryContext_ref_in_binaries_description , BasicElementLabels.getJavaElementName(getMethodName()));
ReferencesInBinaryContext binaryRefs= new ReferencesInBinaryContext(binaryRefsDescription);
fRippleMethods= RippleMethodFinder2.getRelatedMethods(fMethod, binaryRefs, new SubProgressMonitor(pm, 1), null);
result.merge(checkVarargs());
if (result.hasFatalError())
return result;
fOccurrences= findOccurrences(new SubProgressMonitor(pm, 1), binaryRefs, result);
binaryRefs.addErrorIfNecessary(result);
result.merge(checkVisibilityChanges());
result.merge(checkTypeVariables());
//TODO:
// We need a common way of dealing with possible compilation errors for all occurrences,
// including visibility problems, shadowing and missing throws declarations.
if (! isOrderSameAsInitial())
result.merge(checkReorderings(new SubProgressMonitor(pm, 1)));
else
pm.worked(1);
//TODO (bug 58616): check whether changed signature already exists somewhere in the ripple,
// - error if exists
// - warn if exists with different parameter types (may cause overloading)
if (! areNamesSameAsInitial())
result.merge(checkRenamings(new SubProgressMonitor(pm, 1)));
else
pm.worked(1);
if (result.hasFatalError())
return result;
// resolveTypesWithoutBindings(new SubProgressMonitor(pm, 1)); // already done in checkSignature(true)
createChangeManager(new SubProgressMonitor(pm, 1), result);
fCachedTypeHierarchy= null;
if (mustAnalyzeAstOfDeclaringCu())
result.merge(checkCompilationofDeclaringCu()); //TODO: should also check in ripple methods (move into createChangeManager)
if (result.hasFatalError())
return result;
Checks.addModifiedFilesToChecker(getAllFilesToModify(), context);
return result;
} finally {
pm.done();
}
}
示例9: createChangeManager
import org.eclipse.jdt.internal.corext.refactoring.util.TightSourceRangeComputer; //导入依赖的package包/类
private TextChangeManager createChangeManager(IProgressMonitor pm, RefactoringStatus result) throws CoreException {
pm.beginTask(RefactoringCoreMessages.ChangeSignatureRefactoring_preview, 2);
fChangeManager= new TextChangeManager();
boolean isNoArgConstructor= isNoArgConstructor();
Map<ICompilationUnit, Set<IType>> namedSubclassMapping= null;
if (isNoArgConstructor){
//create only when needed;
namedSubclassMapping= createNamedSubclassMapping(new SubProgressMonitor(pm, 1));
}else{
pm.worked(1);
}
for (int i= 0; i < fOccurrences.length; i++) {
if (pm.isCanceled())
throw new OperationCanceledException();
SearchResultGroup group= fOccurrences[i];
ICompilationUnit cu= group.getCompilationUnit();
if (cu == null)
continue;
CompilationUnitRewrite cuRewrite;
if (cu.equals(getCu())) {
cuRewrite= fBaseCuRewrite;
} else {
cuRewrite= new CompilationUnitRewrite(cu);
cuRewrite.getASTRewrite().setTargetSourceRangeComputer(new TightSourceRangeComputer());
}
ASTNode[] nodes= ASTNodeSearchUtil.findNodes(group.getSearchResults(), cuRewrite.getRoot());
//IntroduceParameterObjectRefactoring needs to update declarations first:
List<OccurrenceUpdate<? extends ASTNode>> deferredUpdates= new ArrayList<OccurrenceUpdate<? extends ASTNode>>();
for (int j= 0; j < nodes.length; j++) {
OccurrenceUpdate<? extends ASTNode> update= createOccurrenceUpdate(nodes[j], cuRewrite, result);
if (update instanceof DeclarationUpdate) {
update.updateNode();
} else {
deferredUpdates.add(update);
}
}
for (Iterator<OccurrenceUpdate<? extends ASTNode>> iter= deferredUpdates.iterator(); iter.hasNext();) {
iter.next().updateNode();
}
if (isNoArgConstructor && namedSubclassMapping.containsKey(cu)){
//only non-anonymous subclasses may have noArgConstructors to modify - see bug 43444
Set<IType> subtypes= namedSubclassMapping.get(cu);
for (Iterator<IType> iter= subtypes.iterator(); iter.hasNext();) {
IType subtype= iter.next();
AbstractTypeDeclaration subtypeNode= ASTNodeSearchUtil.getAbstractTypeDeclarationNode(subtype, cuRewrite.getRoot());
if (subtypeNode != null)
modifyImplicitCallsToNoArgConstructor(subtypeNode, cuRewrite);
}
}
TextChange change= cuRewrite.createChange(true);
if (change != null)
fChangeManager.manage(cu, change);
}
pm.done();
return fChangeManager;
}
示例10: getTightSourceRangeComputer
import org.eclipse.jdt.internal.corext.refactoring.util.TightSourceRangeComputer; //导入依赖的package包/类
protected final TightSourceRangeComputer getTightSourceRangeComputer() {
return (TightSourceRangeComputer) fCuRewrite.getASTRewrite().getExtendedSourceRangeComputer();
}