mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Cosmetics.
This commit is contained in:
parent
b939129fde
commit
dc6bc55815
11 changed files with 67 additions and 116 deletions
|
@ -252,7 +252,7 @@ public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
|
|||
public static synchronized CheckersRegistry getInstance() {
|
||||
if (instance == null)
|
||||
return new CheckersRegistry();
|
||||
if (initialized == false)
|
||||
if (!initialized)
|
||||
throw new IllegalStateException("Registry is not initialized"); //$NON-NLS-1$
|
||||
return instance;
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Doug Schaefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Doug Schaefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
|
@ -21,7 +21,6 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICPPMember extends ICPPBinding {
|
||||
|
||||
public static final int v_private = ICPPASTVisibilityLabel.v_private;
|
||||
public static final int v_protected = ICPPASTVisibilityLabel.v_protected;
|
||||
public static final int v_public = ICPPASTVisibilityLabel.v_public;
|
||||
|
@ -31,7 +30,6 @@ public interface ICPPMember extends ICPPBinding {
|
|||
*/
|
||||
public int getVisibility();
|
||||
|
||||
|
||||
/**
|
||||
* Same as {@link #getOwner()}.
|
||||
*/
|
||||
|
|
|
@ -57,14 +57,14 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* Even 'get' methods may cause changes to the underlying object.
|
||||
*/
|
||||
public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslationUnit, ISkippedIndexedFilesListener {
|
||||
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0];
|
||||
private static final IASTPreprocessorMacroDefinition[] EMPTY_PREPROCESSOR_MACRODEF_ARRAY = new IASTPreprocessorMacroDefinition[0];
|
||||
private static final IASTPreprocessorIncludeStatement[] EMPTY_PREPROCESSOR_INCLUSION_ARRAY = new IASTPreprocessorIncludeStatement[0];
|
||||
private static final IASTProblem[] EMPTY_PROBLEM_ARRAY = new IASTProblem[0];
|
||||
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = {};
|
||||
private static final IASTPreprocessorMacroDefinition[] EMPTY_PREPROCESSOR_MACRODEF_ARRAY = {};
|
||||
private static final IASTPreprocessorIncludeStatement[] EMPTY_PREPROCESSOR_INCLUSION_ARRAY = {};
|
||||
private static final IASTProblem[] EMPTY_PROBLEM_ARRAY = {};
|
||||
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||
|
||||
private IASTDeclaration[] fAllDeclarations = null;
|
||||
private IASTDeclaration[] fActiveDeclarations= null;
|
||||
private IASTDeclaration[] fAllDeclarations;
|
||||
private IASTDeclaration[] fActiveDeclarations;
|
||||
private int fLastDeclaration= -1;
|
||||
|
||||
protected ILocationResolver fLocationResolver;
|
||||
|
@ -130,11 +130,6 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getDeclarations(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||
*/
|
||||
@Override
|
||||
public final IName[] getDeclarations(IBinding binding) {
|
||||
IName[] names= getDeclarationsInAST(binding);
|
||||
|
@ -162,11 +157,6 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
return fLocationResolver.getReferences(binding);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getDefinitions(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||
*/
|
||||
@Override
|
||||
public final IName[] getDefinitions(IBinding binding) {
|
||||
IName[] names= getDefinitionsInAST(binding);
|
||||
|
@ -181,11 +171,6 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
return names;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getMacroDefinitions()
|
||||
*/
|
||||
@Override
|
||||
public final IASTPreprocessorMacroDefinition[] getMacroDefinitions() {
|
||||
if (fLocationResolver == null)
|
||||
|
@ -193,9 +178,6 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
return fLocationResolver.getMacroDefinitions();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getMacroExpansions()
|
||||
*/
|
||||
@Override
|
||||
public IASTPreprocessorMacroExpansion[] getMacroExpansions() {
|
||||
if (fLocationResolver == null)
|
||||
|
@ -203,11 +185,6 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
return fLocationResolver.getMacroExpansions(getFileLocation());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getBuiltinMacroDefinitions()
|
||||
*/
|
||||
@Override
|
||||
public final IASTPreprocessorMacroDefinition[] getBuiltinMacroDefinitions() {
|
||||
if (fLocationResolver == null)
|
||||
|
@ -215,11 +192,6 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
return fLocationResolver.getBuiltinMacroDefinitions();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getIncludeDirectives()
|
||||
*/
|
||||
@Override
|
||||
public final IASTPreprocessorIncludeStatement[] getIncludeDirectives() {
|
||||
if (fLocationResolver == null)
|
||||
|
@ -227,11 +199,6 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
return fLocationResolver.getIncludeDirectives();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getAllPreprocessorStatements()
|
||||
*/
|
||||
@Override
|
||||
public final IASTPreprocessorStatement[] getAllPreprocessorStatements() {
|
||||
if (fLocationResolver == null)
|
||||
|
@ -239,21 +206,11 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
return fLocationResolver.getAllPreprocessorStatements();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.internal.core.parser2.IRequiresLocationInformation#setLocationResolver(org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver)
|
||||
*/
|
||||
public final void setLocationResolver(ILocationResolver resolver) {
|
||||
fLocationResolver= resolver;
|
||||
resolver.setRootNode(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getPreprocesorProblems()
|
||||
*/
|
||||
@Override
|
||||
public final IASTProblem[] getPreprocessorProblems() {
|
||||
if (fLocationResolver == null)
|
||||
|
@ -267,25 +224,19 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final int getPreprocessorProblemsCount() {
|
||||
return fLocationResolver == null ? 0 : fLocationResolver.getScannerProblemsCount();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getFilePath()
|
||||
*/
|
||||
@Override
|
||||
public final String getFilePath() {
|
||||
if (fLocationResolver == null)
|
||||
return EMPTY_STRING;
|
||||
return new String(fLocationResolver.getTranslationUnitPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public final boolean accept(ASTVisitor action) {
|
||||
if (action.shouldVisitTranslationUnit) {
|
||||
switch (action.visit(this)) {
|
||||
|
@ -390,9 +341,6 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
fForContentAssist= forContentAssist;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner.ISkippedIndexedFilesListener#skippedFile(org.eclipse.cdt.internal.core.parser.scanner.IncludeFileContent)
|
||||
*/
|
||||
@Override
|
||||
public void skippedFile(int offset, InternalFileContent fileContent) {
|
||||
if (fIndexFileSet != null) {
|
||||
|
@ -431,11 +379,6 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
return fASTFileSet;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getNodeForLocation(org.eclipse.cdt.core.dom.ast.IASTNodeLocation)
|
||||
*/
|
||||
@Override
|
||||
public final IASTNode selectNodeForLocation(String path, int realOffset, int realLength) {
|
||||
return getNodeSelector(path).findNode(realOffset, realLength);
|
||||
|
@ -481,11 +424,6 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getOriginatingTranslationUnit()
|
||||
*/
|
||||
@Override
|
||||
public ITranslationUnit getOriginatingTranslationUnit() {
|
||||
return fOriginatingTranslationUnit;
|
||||
|
|
|
@ -501,7 +501,7 @@ class ImplicitsAnalysis {
|
|||
} else if (member instanceof IASTFunctionDefinition) {
|
||||
dcltor = ((IASTFunctionDefinition)member).getDeclarator();
|
||||
}
|
||||
if (dcltor instanceof ICPPASTFunctionDeclarator == false)
|
||||
if (!(dcltor instanceof ICPPASTFunctionDeclarator))
|
||||
continue;
|
||||
|
||||
final char[] nchars= ASTQueries.findInnermostDeclarator(dcltor).getName().getLookupKey();
|
||||
|
|
|
@ -249,8 +249,9 @@ public class CPPClassSpecialization extends CPPSpecialization
|
|||
public static boolean isSameClassSpecialization(ICPPClassSpecialization t1, ICPPClassSpecialization t2) {
|
||||
// exclude class template specialization or class instance
|
||||
if (t2 instanceof ICPPTemplateInstance || t2 instanceof ICPPTemplateDefinition ||
|
||||
t2 instanceof IProblemBinding)
|
||||
t2 instanceof IProblemBinding) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (t1.getKey() != t2.getKey())
|
||||
return false;
|
||||
|
@ -265,7 +266,7 @@ public class CPPClassSpecialization extends CPPSpecialization
|
|||
final IBinding owner2= t2.getOwner();
|
||||
|
||||
// for a specialization that is not an instance the owner has to be a class-type
|
||||
if (owner1 instanceof ICPPClassType == false || owner2 instanceof ICPPClassType == false)
|
||||
if (!(owner1 instanceof ICPPClassType) || !(owner2 instanceof ICPPClassType))
|
||||
return false;
|
||||
|
||||
return ((ICPPClassType) owner1).isSameType((ICPPClassType) owner2);
|
||||
|
|
|
@ -36,36 +36,39 @@ public class CPPField extends CPPVariable implements ICPPField {
|
|||
public static class CPPFieldProblem extends ProblemBinding implements ICPPField {
|
||||
private ICPPClassType fOwner;
|
||||
|
||||
public CPPFieldProblem(ICPPClassType owner, IASTNode node, int id, char[] arg ) {
|
||||
super( node, id, arg );
|
||||
public CPPFieldProblem(ICPPClassType owner, IASTNode node, int id, char[] arg) {
|
||||
super(node, id, arg);
|
||||
fOwner= owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVisibility() {
|
||||
return v_private;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPClassType getClassOwner() {
|
||||
return fOwner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICompositeType getCompositeTypeOwner() {
|
||||
return getClassOwner();
|
||||
}
|
||||
}
|
||||
|
||||
public CPPField( IASTName name ){
|
||||
super( name );
|
||||
public CPPField(IASTName name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public IASTDeclaration getPrimaryDeclaration() {
|
||||
//first check if we already know it
|
||||
// First check if we already know it
|
||||
IASTDeclaration decl= findDeclaration(getDefinition());
|
||||
if (decl != null) {
|
||||
return decl;
|
||||
}
|
||||
|
||||
IASTName [] declarations = (IASTName[]) getDeclarations();
|
||||
IASTName[] declarations = (IASTName[]) getDeclarations();
|
||||
if (declarations != null) {
|
||||
for (IASTName name : declarations) {
|
||||
decl= findDeclaration(name);
|
||||
|
@ -75,11 +78,11 @@ public class CPPField extends CPPVariable implements ICPPField {
|
|||
}
|
||||
}
|
||||
|
||||
char [] myName = getNameCharArray();
|
||||
char[] myName = getNameCharArray();
|
||||
|
||||
ICPPClassScope scope = (ICPPClassScope) getScope();
|
||||
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(scope);
|
||||
IASTDeclaration [] members = compSpec.getMembers();
|
||||
IASTDeclaration[] members = compSpec.getMembers();
|
||||
for (IASTDeclaration member : members) {
|
||||
if (member instanceof IASTSimpleDeclaration) {
|
||||
IASTDeclarator[] dtors = ((IASTSimpleDeclaration) member).getDeclarators();
|
||||
|
@ -95,7 +98,7 @@ public class CPPField extends CPPVariable implements ICPPField {
|
|||
}
|
||||
|
||||
private IASTDeclaration findDeclaration(IASTNode node) {
|
||||
while(node != null && node instanceof IASTDeclaration == false) {
|
||||
while (node != null && !(node instanceof IASTDeclaration)) {
|
||||
node = node.getParent();
|
||||
}
|
||||
if (node != null && node.getParent() instanceof ICPPASTCompositeTypeSpecifier) {
|
||||
|
@ -108,20 +111,21 @@ public class CPPField extends CPPVariable implements ICPPField {
|
|||
public int getVisibility() {
|
||||
ICPPASTVisibilityLabel vis = null;
|
||||
IASTDeclaration decl = getPrimaryDeclaration();
|
||||
if( decl != null ) {
|
||||
if (decl != null) {
|
||||
IASTCompositeTypeSpecifier cls = (IASTCompositeTypeSpecifier) decl.getParent();
|
||||
IASTDeclaration [] members = cls.getMembers();
|
||||
|
||||
IASTDeclaration[] members = cls.getMembers();
|
||||
|
||||
for (IASTDeclaration member : members) {
|
||||
if( member instanceof ICPPASTVisibilityLabel )
|
||||
if (member instanceof ICPPASTVisibilityLabel) {
|
||||
vis = (ICPPASTVisibilityLabel) member;
|
||||
else if( member == decl )
|
||||
} else if (member == decl) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( vis != null ){
|
||||
if (vis != null) {
|
||||
return vis.getVisibility();
|
||||
} else if( cls.getKey() == ICPPASTCompositeTypeSpecifier.k_class ){
|
||||
} else if (cls.getKey() == ICPPASTCompositeTypeSpecifier.k_class) {
|
||||
return ICPPASTVisibilityLabel.v_private;
|
||||
}
|
||||
}
|
||||
|
@ -146,10 +150,9 @@ public class CPPField extends CPPVariable implements ICPPField {
|
|||
return super.isStatic();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isMutable() {
|
||||
return hasStorageClass( IASTDeclSpecifier.sc_mutable);
|
||||
return hasStorageClass(IASTDeclSpecifier.sc_mutable);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -277,10 +277,10 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
|||
private ICPPASTFunctionDeclarator extractFunctionDtor(IASTNode node) {
|
||||
if (node instanceof IASTName)
|
||||
node = node.getParent();
|
||||
if (node instanceof IASTDeclarator == false)
|
||||
if (!(node instanceof IASTDeclarator))
|
||||
return null;
|
||||
node= ASTQueries.findTypeRelevantDeclarator((IASTDeclarator) node);
|
||||
if (node instanceof ICPPASTFunctionDeclarator == false)
|
||||
if (!(node instanceof ICPPASTFunctionDeclarator))
|
||||
return null;
|
||||
|
||||
return (ICPPASTFunctionDeclarator) node;
|
||||
|
|
|
@ -19,7 +19,17 @@ import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
|
|||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeOrFunctionSet;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCat;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.ALLCVQ;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.ARRAY;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.MPTR;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.PTR;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.calculateInheritanceDepth;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateTypeUptoPointers;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.isConversionOperator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -1890,12 +1900,12 @@ public class CPPSemantics {
|
|||
try {
|
||||
if (cpp instanceof ICPPNamespace || cpp instanceof ICPPFunction || cpp instanceof ICPPVariable) {
|
||||
IScope scope= cpp.getScope();
|
||||
if (scope instanceof ICPPBlockScope == false && scope instanceof ICPPNamespaceScope) {
|
||||
if (!(scope instanceof ICPPBlockScope) && scope instanceof ICPPNamespaceScope) {
|
||||
return true;
|
||||
}
|
||||
} else if (cpp instanceof ICompositeType || cpp instanceof IEnumeration) {
|
||||
IScope scope= cpp.getScope();
|
||||
if (scope instanceof ICPPBlockScope == false && scope instanceof ICPPNamespaceScope) {
|
||||
if (!(scope instanceof ICPPBlockScope) && scope instanceof ICPPNamespaceScope) {
|
||||
// if this is not the definition, it may be found in a header. (bug 229571)
|
||||
if (cpp.getDefinition() == null) {
|
||||
return true;
|
||||
|
|
|
@ -86,16 +86,17 @@ public class ImplementMethodRefactoring extends CRefactoring2 {
|
|||
}
|
||||
|
||||
@Override
|
||||
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
|
||||
public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
|
||||
throws CoreException, OperationCanceledException {
|
||||
SubMonitor sm = SubMonitor.convert(pm, 10);
|
||||
super.checkInitialConditions(sm.newChild(6));
|
||||
|
||||
if (!initStatus.hasFatalError()) {
|
||||
List<IASTSimpleDeclaration> unimplementedMethodDeclarations = findUnimplementedMethodDeclarations(pm);
|
||||
List<IASTSimpleDeclaration> unimplementedMethodDeclarations =
|
||||
findUnimplementedMethodDeclarations(pm);
|
||||
if (unimplementedMethodDeclarations.isEmpty()) {
|
||||
initStatus.addFatalError(Messages.ImplementMethodRefactoring_NoMethodToImplement);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
data.setMethodDeclarations(unimplementedMethodDeclarations);
|
||||
|
||||
if (selectedRegion.getLength() > 0) {
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
|
|||
*/
|
||||
public class ImplementMethodRefactoringWizard extends RefactoringWizard {
|
||||
private final ImplementMethodRefactoring refactoring;
|
||||
private Map<MethodToImplementConfig, ParameterNamesInputPage>pagesMap =
|
||||
private Map<MethodToImplementConfig, ParameterNamesInputPage> pagesMap =
|
||||
new HashMap<MethodToImplementConfig, ParameterNamesInputPage>();
|
||||
|
||||
public ImplementMethodRefactoringWizard(ImplementMethodRefactoring refactoring) {
|
||||
|
@ -53,7 +53,7 @@ public class ImplementMethodRefactoringWizard extends RefactoringWizard {
|
|||
}
|
||||
|
||||
/**
|
||||
* When canceling the wizard, RefactoringASTCache gets disposed and releases the lock on
|
||||
* When canceling the wizard, CRefactoringContext gets disposed and releases the lock on
|
||||
* the index but the preview jobs might still be running and access the index or an index-based
|
||||
* AST so we need to make sure they are done before disposing the cache
|
||||
* <p>
|
||||
|
|
|
@ -44,21 +44,21 @@ import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
|||
public class DefinitionFinder {
|
||||
|
||||
public static IASTName getDefinition(IASTSimpleDeclaration simpleDeclaration,
|
||||
CRefactoringContext astCache, IProgressMonitor pm) throws CoreException {
|
||||
IIndex index = astCache.getIndex();
|
||||
IASTDeclarator declarator = simpleDeclaration.getDeclarators()[0];
|
||||
CRefactoringContext refactoringContext, IProgressMonitor pm) throws CoreException {
|
||||
IIndex index = refactoringContext.getIndex();
|
||||
if (index == null) {
|
||||
return null;
|
||||
}
|
||||
IASTDeclarator declarator = simpleDeclaration.getDeclarators()[0];
|
||||
IIndexBinding binding = index.adaptBinding(declarator.getName().resolveBinding());
|
||||
if (binding == null) {
|
||||
return null;
|
||||
}
|
||||
return getDefinition(binding, astCache, index, pm);
|
||||
return getDefinition(binding, refactoringContext, index, pm);
|
||||
}
|
||||
|
||||
private static IASTName getDefinition(IIndexBinding binding,
|
||||
CRefactoringContext astCache, IIndex index, IProgressMonitor pm) throws CoreException {
|
||||
CRefactoringContext refactoringContext, IIndex index, IProgressMonitor pm) throws CoreException {
|
||||
Set<String> searchedFiles = new HashSet<String>();
|
||||
List<IASTName> definitions = new ArrayList<IASTName>();
|
||||
IEditorPart[] dirtyEditors = EditorUtility.getDirtyEditors(true);
|
||||
|
@ -70,7 +70,7 @@ public class DefinitionFinder {
|
|||
if (editorInput instanceof ITranslationUnitEditorInput) {
|
||||
ITranslationUnit tu =
|
||||
CModelUtil.toWorkingCopy(((ITranslationUnitEditorInput) editorInput).getTranslationUnit());
|
||||
findDefinitionsInTranslationUnit(binding, tu, astCache, definitions, null);
|
||||
findDefinitionsInTranslationUnit(binding, tu, refactoringContext, definitions, null);
|
||||
searchedFiles.add(tu.getLocation().toOSString());
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public class DefinitionFinder {
|
|||
ITranslationUnit tu = CoreModelUtil.findTranslationUnitForLocation(
|
||||
name.getFile().getLocation(), null);
|
||||
if (searchedFiles.add(tu.getLocation().toOSString())) {
|
||||
findDefinitionsInTranslationUnit(binding, tu, astCache, definitions, pm);
|
||||
findDefinitionsInTranslationUnit(binding, tu, refactoringContext, definitions, pm);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,9 +91,9 @@ public class DefinitionFinder {
|
|||
}
|
||||
|
||||
private static void findDefinitionsInTranslationUnit(IIndexBinding binding, ITranslationUnit tu,
|
||||
CRefactoringContext astCache, List<IASTName> definitions, IProgressMonitor pm)
|
||||
CRefactoringContext refactoringContext, List<IASTName> definitions, IProgressMonitor pm)
|
||||
throws OperationCanceledException, CoreException {
|
||||
IASTTranslationUnit ast = astCache.getAST(tu, pm);
|
||||
IASTTranslationUnit ast = refactoringContext.getAST(tu, pm);
|
||||
findDefinitionsInAST(binding, ast, tu, definitions);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue