mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
Remove use of deprecated methods.
Change-Id: Id14e9948dc30a998adad463e338dc86df109e315
This commit is contained in:
parent
6386496e21
commit
4a9287acb5
4 changed files with 54 additions and 59 deletions
|
@ -19,10 +19,8 @@ import org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory;
|
||||||
import org.eclipse.core.runtime.Assert;
|
import org.eclipse.core.runtime.Assert;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
|
||||||
import org.eclipse.core.runtime.OperationCanceledException;
|
import org.eclipse.core.runtime.OperationCanceledException;
|
||||||
import org.eclipse.core.runtime.SubMonitor;
|
import org.eclipse.core.runtime.SubMonitor;
|
||||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
|
||||||
import org.eclipse.jface.text.ITextSelection;
|
import org.eclipse.jface.text.ITextSelection;
|
||||||
import org.eclipse.jface.text.Region;
|
import org.eclipse.jface.text.Region;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
@ -108,31 +106,27 @@ public abstract class CRefactoring extends Refactoring {
|
||||||
@Override
|
@Override
|
||||||
public final RefactoringStatus checkFinalConditions(IProgressMonitor pm)
|
public final RefactoringStatus checkFinalConditions(IProgressMonitor pm)
|
||||||
throws CoreException, OperationCanceledException {
|
throws CoreException, OperationCanceledException {
|
||||||
if (pm == null)
|
SubMonitor progress = SubMonitor.convert(pm, Messages.CRefactoring_checking_final_conditions, 12);
|
||||||
pm = new NullProgressMonitor();
|
|
||||||
pm.beginTask(Messages.CRefactoring_checking_final_conditions, 10);
|
|
||||||
|
|
||||||
|
try {
|
||||||
CheckConditionsContext context= new CheckConditionsContext();
|
CheckConditionsContext context= new CheckConditionsContext();
|
||||||
context.add(new ValidateEditChecker(getValidationContext()));
|
context.add(new ValidateEditChecker(getValidationContext()));
|
||||||
ResourceChangeChecker resourceChecker = new ResourceChangeChecker();
|
ResourceChangeChecker resourceChecker = new ResourceChangeChecker();
|
||||||
IResourceChangeDescriptionFactory deltaFactory = resourceChecker.getDeltaFactory();
|
IResourceChangeDescriptionFactory deltaFactory = resourceChecker.getDeltaFactory();
|
||||||
context.add(resourceChecker);
|
context.add(resourceChecker);
|
||||||
|
|
||||||
RefactoringStatus result = checkFinalConditions(new SubProgressMonitor(pm, 8), context);
|
RefactoringStatus result = checkFinalConditions(progress.split(8), context);
|
||||||
if (result.hasFatalError()) {
|
if (result.hasFatalError())
|
||||||
pm.done();
|
|
||||||
return result;
|
return result;
|
||||||
}
|
|
||||||
if (pm.isCanceled())
|
|
||||||
throw new OperationCanceledException();
|
|
||||||
|
|
||||||
modificationCollector = new ModificationCollector(deltaFactory);
|
modificationCollector = new ModificationCollector(deltaFactory);
|
||||||
collectModifications(pm, modificationCollector);
|
collectModifications(progress.split(2), modificationCollector);
|
||||||
|
|
||||||
result.merge(context.check(new SubProgressMonitor(pm, 2)));
|
result.merge(context.check(progress.split(2)));
|
||||||
|
|
||||||
pm.done();
|
|
||||||
return result;
|
return result;
|
||||||
|
} finally {
|
||||||
|
progress.done();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RefactoringStatus checkFinalConditions(IProgressMonitor subProgressMonitor,
|
protected RefactoringStatus checkFinalConditions(IProgressMonitor subProgressMonitor,
|
||||||
|
|
|
@ -14,6 +14,17 @@ package org.eclipse.cdt.internal.ui.refactoring;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.Assert;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.OperationCanceledException;
|
||||||
|
import org.eclipse.core.runtime.SubMonitor;
|
||||||
|
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||||
|
import org.eclipse.jface.viewers.ArrayContentProvider;
|
||||||
|
import org.eclipse.jface.viewers.ILabelProvider;
|
||||||
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
|
import org.eclipse.jface.window.Window;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
@ -22,20 +33,6 @@ import org.eclipse.swt.widgets.Button;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Control;
|
import org.eclipse.swt.widgets.Control;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.Assert;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
|
||||||
|
|
||||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
|
||||||
import org.eclipse.jface.viewers.ArrayContentProvider;
|
|
||||||
import org.eclipse.jface.viewers.ILabelProvider;
|
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
|
||||||
import org.eclipse.jface.window.Window;
|
|
||||||
|
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.actions.GlobalBuildAction;
|
import org.eclipse.ui.actions.GlobalBuildAction;
|
||||||
|
@ -133,14 +130,17 @@ public class RefactoringSaveHelper {
|
||||||
@Override
|
@Override
|
||||||
public void run(IProgressMonitor pm) throws InterruptedException {
|
public void run(IProgressMonitor pm) throws InterruptedException {
|
||||||
int count= dirtyEditors.length;
|
int count= dirtyEditors.length;
|
||||||
pm.beginTask("", count); //$NON-NLS-1$
|
SubMonitor progress = SubMonitor.convert(pm, "", count); //$NON-NLS-1$
|
||||||
|
try {
|
||||||
for (int i= 0; i < count; i++) {
|
for (int i= 0; i < count; i++) {
|
||||||
IEditorPart editor= dirtyEditors[i];
|
IEditorPart editor= dirtyEditors[i];
|
||||||
editor.doSave(new SubProgressMonitor(pm, 1));
|
editor.doSave(progress.split(1));
|
||||||
if (pm.isCanceled())
|
}
|
||||||
throw new InterruptedException();
|
} catch (OperationCanceledException e) {
|
||||||
|
throw new InterruptedException();
|
||||||
|
} finally {
|
||||||
|
progress.done();
|
||||||
}
|
}
|
||||||
pm.done();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNameSpecifier;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.parser.Keywords;
|
import org.eclipse.cdt.core.parser.Keywords;
|
||||||
|
@ -74,10 +73,10 @@ public class NameHelper {
|
||||||
ICPPASTQualifiedName qname = new CPPASTQualifiedName(
|
ICPPASTQualifiedName qname = new CPPASTQualifiedName(
|
||||||
(ICPPASTName) declaratorName.copy(CopyStyle.withLocations));
|
(ICPPASTName) declaratorName.copy(CopyStyle.withLocations));
|
||||||
|
|
||||||
ICPPASTNameSpecifier[] declarationNames = NamespaceHelper.getSurroundingNamespace(declarationTu,
|
ICPPASTName[] declarationNames =
|
||||||
selectionOffset, astCache).getAllSegments();
|
NamespaceHelper.getSurroundingNamespace(declarationTu, selectionOffset, astCache);
|
||||||
ICPPASTNameSpecifier[] implementationNames = NamespaceHelper.getSurroundingNamespace(insertFileTu,
|
ICPPASTName[] implementationNames =
|
||||||
insertLocation, astCache).getAllSegments();
|
NamespaceHelper.getSurroundingNamespace(insertFileTu, insertLocation, astCache);
|
||||||
|
|
||||||
for (int i = 0; i < declarationNames.length; i++) {
|
for (int i = 0; i < declarationNames.length; i++) {
|
||||||
if (i >= implementationNames.length) {
|
if (i >= implementationNames.length) {
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.refactoring.utils;
|
package org.eclipse.cdt.internal.ui.refactoring.utils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
|
@ -20,14 +23,13 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle;
|
import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNamedTypeSpecifier;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNamedTypeSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleTypeTemplateParameter;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleTypeTemplateParameter;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateId;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateId;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTypeId;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTypeId;
|
||||||
|
@ -49,16 +51,16 @@ public class NamespaceHelper {
|
||||||
* @return ICPPASTQualifiedName with the names of all namespaces
|
* @return ICPPASTQualifiedName with the names of all namespaces
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
public static ICPPASTQualifiedName getSurroundingNamespace(final ITranslationUnit translationUnit, final int offset, CRefactoringContext astCache)
|
public static ICPPASTName[] getSurroundingNamespace(final ITranslationUnit translationUnit,
|
||||||
throws CoreException {
|
final int offset, CRefactoringContext astCache) throws CoreException {
|
||||||
final CPPASTQualifiedName qualifiedName = new CPPASTQualifiedName();
|
final List<ICPPASTName> names = new ArrayList<>();
|
||||||
|
|
||||||
astCache.getAST(translationUnit, null).accept(new CPPASTAllVisitor() {
|
astCache.getAST(translationUnit, null).accept(new CPPASTAllVisitor() {
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclSpecifier declSpec) {
|
public int visit(IASTDeclSpecifier declSpec) {
|
||||||
if (declSpec instanceof ICPPASTCompositeTypeSpecifier &&
|
if (declSpec instanceof ICPPASTCompositeTypeSpecifier &&
|
||||||
checkFileNameAndLocation(translationUnit.getLocation(), offset, declSpec)) {
|
checkFileNameAndLocation(translationUnit.getLocation(), offset, declSpec)) {
|
||||||
qualifiedName.addName(createNameWithTemplates(declSpec));
|
names.add((ICPPASTName) createNameWithTemplates(declSpec));
|
||||||
}
|
}
|
||||||
return super.visit(declSpec);
|
return super.visit(declSpec);
|
||||||
}
|
}
|
||||||
|
@ -66,14 +68,14 @@ public class NamespaceHelper {
|
||||||
@Override
|
@Override
|
||||||
public int visit(ICPPASTNamespaceDefinition namespace) {
|
public int visit(ICPPASTNamespaceDefinition namespace) {
|
||||||
if (checkFileNameAndLocation(translationUnit.getLocation(), offset, namespace)) {
|
if (checkFileNameAndLocation(translationUnit.getLocation(), offset, namespace)) {
|
||||||
qualifiedName.addName((namespace).getName().copy(CopyStyle.withLocations));
|
names.add((ICPPASTName) namespace.getName().copy(CopyStyle.withLocations));
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.visit(namespace);
|
return super.visit(namespace);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return qualifiedName;
|
return names.toArray(new ICPPASTName[names.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean checkFileNameAndLocation(final IPath path, final int offset, IASTNode namespace) {
|
private static boolean checkFileNameAndLocation(final IPath path, final int offset, IASTNode namespace) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue