1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 09:46:02 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2012-02-21 13:14:51 -08:00
parent b939129fde
commit dc6bc55815
11 changed files with 67 additions and 116 deletions

View file

@ -252,7 +252,7 @@ public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
public static synchronized CheckersRegistry getInstance() { public static synchronized CheckersRegistry getInstance() {
if (instance == null) if (instance == null)
return new CheckersRegistry(); return new CheckersRegistry();
if (initialized == false) if (!initialized)
throw new IllegalStateException("Registry is not initialized"); //$NON-NLS-1$ throw new IllegalStateException("Registry is not initialized"); //$NON-NLS-1$
return instance; return instance;
} }

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp; 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. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ICPPMember extends ICPPBinding { public interface ICPPMember extends ICPPBinding {
public static final int v_private = ICPPASTVisibilityLabel.v_private; public static final int v_private = ICPPASTVisibilityLabel.v_private;
public static final int v_protected = ICPPASTVisibilityLabel.v_protected; public static final int v_protected = ICPPASTVisibilityLabel.v_protected;
public static final int v_public = ICPPASTVisibilityLabel.v_public; public static final int v_public = ICPPASTVisibilityLabel.v_public;
@ -31,7 +30,6 @@ public interface ICPPMember extends ICPPBinding {
*/ */
public int getVisibility(); public int getVisibility();
/** /**
* Same as {@link #getOwner()}. * Same as {@link #getOwner()}.
*/ */

View file

@ -57,14 +57,14 @@ import org.eclipse.core.runtime.CoreException;
* Even 'get' methods may cause changes to the underlying object. * Even 'get' methods may cause changes to the underlying object.
*/ */
public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslationUnit, ISkippedIndexedFilesListener { public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslationUnit, ISkippedIndexedFilesListener {
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0]; private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = {};
private static final IASTPreprocessorMacroDefinition[] EMPTY_PREPROCESSOR_MACRODEF_ARRAY = new IASTPreprocessorMacroDefinition[0]; private static final IASTPreprocessorMacroDefinition[] EMPTY_PREPROCESSOR_MACRODEF_ARRAY = {};
private static final IASTPreprocessorIncludeStatement[] EMPTY_PREPROCESSOR_INCLUSION_ARRAY = new IASTPreprocessorIncludeStatement[0]; private static final IASTPreprocessorIncludeStatement[] EMPTY_PREPROCESSOR_INCLUSION_ARRAY = {};
private static final IASTProblem[] EMPTY_PROBLEM_ARRAY = new IASTProblem[0]; private static final IASTProblem[] EMPTY_PROBLEM_ARRAY = {};
private static final String EMPTY_STRING = ""; //$NON-NLS-1$ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private IASTDeclaration[] fAllDeclarations = null; private IASTDeclaration[] fAllDeclarations;
private IASTDeclaration[] fActiveDeclarations= null; private IASTDeclaration[] fActiveDeclarations;
private int fLastDeclaration= -1; private int fLastDeclaration= -1;
protected ILocationResolver fLocationResolver; 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 @Override
public final IName[] getDeclarations(IBinding binding) { public final IName[] getDeclarations(IBinding binding) {
IName[] names= getDeclarationsInAST(binding); IName[] names= getDeclarationsInAST(binding);
@ -162,11 +157,6 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
return fLocationResolver.getReferences(binding); return fLocationResolver.getReferences(binding);
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getDefinitions(org.eclipse.cdt.core.dom.ast.IBinding)
*/
@Override @Override
public final IName[] getDefinitions(IBinding binding) { public final IName[] getDefinitions(IBinding binding) {
IName[] names= getDefinitionsInAST(binding); IName[] names= getDefinitionsInAST(binding);
@ -181,11 +171,6 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
return names; return names;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getMacroDefinitions()
*/
@Override @Override
public final IASTPreprocessorMacroDefinition[] getMacroDefinitions() { public final IASTPreprocessorMacroDefinition[] getMacroDefinitions() {
if (fLocationResolver == null) if (fLocationResolver == null)
@ -193,9 +178,6 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
return fLocationResolver.getMacroDefinitions(); return fLocationResolver.getMacroDefinitions();
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getMacroExpansions()
*/
@Override @Override
public IASTPreprocessorMacroExpansion[] getMacroExpansions() { public IASTPreprocessorMacroExpansion[] getMacroExpansions() {
if (fLocationResolver == null) if (fLocationResolver == null)
@ -203,11 +185,6 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
return fLocationResolver.getMacroExpansions(getFileLocation()); return fLocationResolver.getMacroExpansions(getFileLocation());
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getBuiltinMacroDefinitions()
*/
@Override @Override
public final IASTPreprocessorMacroDefinition[] getBuiltinMacroDefinitions() { public final IASTPreprocessorMacroDefinition[] getBuiltinMacroDefinitions() {
if (fLocationResolver == null) if (fLocationResolver == null)
@ -215,11 +192,6 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
return fLocationResolver.getBuiltinMacroDefinitions(); return fLocationResolver.getBuiltinMacroDefinitions();
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getIncludeDirectives()
*/
@Override @Override
public final IASTPreprocessorIncludeStatement[] getIncludeDirectives() { public final IASTPreprocessorIncludeStatement[] getIncludeDirectives() {
if (fLocationResolver == null) if (fLocationResolver == null)
@ -227,11 +199,6 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
return fLocationResolver.getIncludeDirectives(); return fLocationResolver.getIncludeDirectives();
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getAllPreprocessorStatements()
*/
@Override @Override
public final IASTPreprocessorStatement[] getAllPreprocessorStatements() { public final IASTPreprocessorStatement[] getAllPreprocessorStatements() {
if (fLocationResolver == null) if (fLocationResolver == null)
@ -239,21 +206,11 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
return fLocationResolver.getAllPreprocessorStatements(); 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) { public final void setLocationResolver(ILocationResolver resolver) {
fLocationResolver= resolver; fLocationResolver= resolver;
resolver.setRootNode(this); resolver.setRootNode(this);
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getPreprocesorProblems()
*/
@Override @Override
public final IASTProblem[] getPreprocessorProblems() { public final IASTProblem[] getPreprocessorProblems() {
if (fLocationResolver == null) if (fLocationResolver == null)
@ -267,17 +224,11 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
return result; return result;
} }
@Override @Override
public final int getPreprocessorProblemsCount() { public final int getPreprocessorProblemsCount() {
return fLocationResolver == null ? 0 : fLocationResolver.getScannerProblemsCount(); return fLocationResolver == null ? 0 : fLocationResolver.getScannerProblemsCount();
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getFilePath()
*/
@Override @Override
public final String getFilePath() { public final String getFilePath() {
if (fLocationResolver == null) if (fLocationResolver == null)
@ -285,7 +236,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
return new String(fLocationResolver.getTranslationUnitPath()); return new String(fLocationResolver.getTranslationUnitPath());
} }
@Override @Override
public final boolean accept(ASTVisitor action) { public final boolean accept(ASTVisitor action) {
if (action.shouldVisitTranslationUnit) { if (action.shouldVisitTranslationUnit) {
switch (action.visit(this)) { switch (action.visit(this)) {
@ -390,9 +341,6 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
fForContentAssist= forContentAssist; fForContentAssist= forContentAssist;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.scanner.ISkippedIndexedFilesListener#skippedFile(org.eclipse.cdt.internal.core.parser.scanner.IncludeFileContent)
*/
@Override @Override
public void skippedFile(int offset, InternalFileContent fileContent) { public void skippedFile(int offset, InternalFileContent fileContent) {
if (fIndexFileSet != null) { if (fIndexFileSet != null) {
@ -431,11 +379,6 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
return fASTFileSet; return fASTFileSet;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getNodeForLocation(org.eclipse.cdt.core.dom.ast.IASTNodeLocation)
*/
@Override @Override
public final IASTNode selectNodeForLocation(String path, int realOffset, int realLength) { public final IASTNode selectNodeForLocation(String path, int realOffset, int realLength) {
return getNodeSelector(path).findNode(realOffset, 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 @Override
public ITranslationUnit getOriginatingTranslationUnit() { public ITranslationUnit getOriginatingTranslationUnit() {
return fOriginatingTranslationUnit; return fOriginatingTranslationUnit;

View file

@ -501,7 +501,7 @@ class ImplicitsAnalysis {
} else if (member instanceof IASTFunctionDefinition) { } else if (member instanceof IASTFunctionDefinition) {
dcltor = ((IASTFunctionDefinition)member).getDeclarator(); dcltor = ((IASTFunctionDefinition)member).getDeclarator();
} }
if (dcltor instanceof ICPPASTFunctionDeclarator == false) if (!(dcltor instanceof ICPPASTFunctionDeclarator))
continue; continue;
final char[] nchars= ASTQueries.findInnermostDeclarator(dcltor).getName().getLookupKey(); final char[] nchars= ASTQueries.findInnermostDeclarator(dcltor).getName().getLookupKey();

View file

@ -249,8 +249,9 @@ public class CPPClassSpecialization extends CPPSpecialization
public static boolean isSameClassSpecialization(ICPPClassSpecialization t1, ICPPClassSpecialization t2) { public static boolean isSameClassSpecialization(ICPPClassSpecialization t1, ICPPClassSpecialization t2) {
// exclude class template specialization or class instance // exclude class template specialization or class instance
if (t2 instanceof ICPPTemplateInstance || t2 instanceof ICPPTemplateDefinition || if (t2 instanceof ICPPTemplateInstance || t2 instanceof ICPPTemplateDefinition ||
t2 instanceof IProblemBinding) t2 instanceof IProblemBinding) {
return false; return false;
}
if (t1.getKey() != t2.getKey()) if (t1.getKey() != t2.getKey())
return false; return false;
@ -265,7 +266,7 @@ public class CPPClassSpecialization extends CPPSpecialization
final IBinding owner2= t2.getOwner(); final IBinding owner2= t2.getOwner();
// for a specialization that is not an instance the owner has to be a class-type // 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 false;
return ((ICPPClassType) owner1).isSameType((ICPPClassType) owner2); return ((ICPPClassType) owner1).isSameType((ICPPClassType) owner2);

View file

@ -36,36 +36,39 @@ public class CPPField extends CPPVariable implements ICPPField {
public static class CPPFieldProblem extends ProblemBinding implements ICPPField { public static class CPPFieldProblem extends ProblemBinding implements ICPPField {
private ICPPClassType fOwner; private ICPPClassType fOwner;
public CPPFieldProblem(ICPPClassType owner, IASTNode node, int id, char[] arg ) { public CPPFieldProblem(ICPPClassType owner, IASTNode node, int id, char[] arg) {
super( node, id, arg ); super(node, id, arg);
fOwner= owner; fOwner= owner;
} }
@Override @Override
public int getVisibility() { public int getVisibility() {
return v_private; return v_private;
} }
@Override @Override
public ICPPClassType getClassOwner() { public ICPPClassType getClassOwner() {
return fOwner; return fOwner;
} }
@Override @Override
public ICompositeType getCompositeTypeOwner() { public ICompositeType getCompositeTypeOwner() {
return getClassOwner(); return getClassOwner();
} }
} }
public CPPField( IASTName name ){ public CPPField(IASTName name) {
super( name ); super(name);
} }
public IASTDeclaration getPrimaryDeclaration() { public IASTDeclaration getPrimaryDeclaration() {
//first check if we already know it // First check if we already know it
IASTDeclaration decl= findDeclaration(getDefinition()); IASTDeclaration decl= findDeclaration(getDefinition());
if (decl != null) { if (decl != null) {
return decl; return decl;
} }
IASTName [] declarations = (IASTName[]) getDeclarations(); IASTName[] declarations = (IASTName[]) getDeclarations();
if (declarations != null) { if (declarations != null) {
for (IASTName name : declarations) { for (IASTName name : declarations) {
decl= findDeclaration(name); decl= findDeclaration(name);
@ -75,11 +78,11 @@ public class CPPField extends CPPVariable implements ICPPField {
} }
} }
char [] myName = getNameCharArray(); char[] myName = getNameCharArray();
ICPPClassScope scope = (ICPPClassScope) getScope(); ICPPClassScope scope = (ICPPClassScope) getScope();
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(scope); ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(scope);
IASTDeclaration [] members = compSpec.getMembers(); IASTDeclaration[] members = compSpec.getMembers();
for (IASTDeclaration member : members) { for (IASTDeclaration member : members) {
if (member instanceof IASTSimpleDeclaration) { if (member instanceof IASTSimpleDeclaration) {
IASTDeclarator[] dtors = ((IASTSimpleDeclaration) member).getDeclarators(); IASTDeclarator[] dtors = ((IASTSimpleDeclaration) member).getDeclarators();
@ -95,7 +98,7 @@ public class CPPField extends CPPVariable implements ICPPField {
} }
private IASTDeclaration findDeclaration(IASTNode node) { private IASTDeclaration findDeclaration(IASTNode node) {
while(node != null && node instanceof IASTDeclaration == false) { while (node != null && !(node instanceof IASTDeclaration)) {
node = node.getParent(); node = node.getParent();
} }
if (node != null && node.getParent() instanceof ICPPASTCompositeTypeSpecifier) { if (node != null && node.getParent() instanceof ICPPASTCompositeTypeSpecifier) {
@ -108,20 +111,21 @@ public class CPPField extends CPPVariable implements ICPPField {
public int getVisibility() { public int getVisibility() {
ICPPASTVisibilityLabel vis = null; ICPPASTVisibilityLabel vis = null;
IASTDeclaration decl = getPrimaryDeclaration(); IASTDeclaration decl = getPrimaryDeclaration();
if( decl != null ) { if (decl != null) {
IASTCompositeTypeSpecifier cls = (IASTCompositeTypeSpecifier) decl.getParent(); IASTCompositeTypeSpecifier cls = (IASTCompositeTypeSpecifier) decl.getParent();
IASTDeclaration [] members = cls.getMembers(); IASTDeclaration[] members = cls.getMembers();
for (IASTDeclaration member : members) { for (IASTDeclaration member : members) {
if( member instanceof ICPPASTVisibilityLabel ) if (member instanceof ICPPASTVisibilityLabel) {
vis = (ICPPASTVisibilityLabel) member; vis = (ICPPASTVisibilityLabel) member;
else if( member == decl ) } else if (member == decl) {
break; break;
}
} }
if( vis != null ){ if (vis != null) {
return vis.getVisibility(); return vis.getVisibility();
} else if( cls.getKey() == ICPPASTCompositeTypeSpecifier.k_class ){ } else if (cls.getKey() == ICPPASTCompositeTypeSpecifier.k_class) {
return ICPPASTVisibilityLabel.v_private; return ICPPASTVisibilityLabel.v_private;
} }
} }
@ -146,10 +150,9 @@ public class CPPField extends CPPVariable implements ICPPField {
return super.isStatic(); return super.isStatic();
} }
@Override @Override
public boolean isMutable() { public boolean isMutable() {
return hasStorageClass( IASTDeclSpecifier.sc_mutable); return hasStorageClass(IASTDeclSpecifier.sc_mutable);
} }
@Override @Override

View file

@ -277,10 +277,10 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
private ICPPASTFunctionDeclarator extractFunctionDtor(IASTNode node) { private ICPPASTFunctionDeclarator extractFunctionDtor(IASTNode node) {
if (node instanceof IASTName) if (node instanceof IASTName)
node = node.getParent(); node = node.getParent();
if (node instanceof IASTDeclarator == false) if (!(node instanceof IASTDeclarator))
return null; return null;
node= ASTQueries.findTypeRelevantDeclarator((IASTDeclarator) node); node= ASTQueries.findTypeRelevantDeclarator((IASTDeclarator) node);
if (node instanceof ICPPASTFunctionDeclarator == false) if (!(node instanceof ICPPASTFunctionDeclarator))
return null; return null;
return (ICPPASTFunctionDeclarator) node; return (ICPPASTFunctionDeclarator) node;

View file

@ -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.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.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.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.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -1890,12 +1900,12 @@ public class CPPSemantics {
try { try {
if (cpp instanceof ICPPNamespace || cpp instanceof ICPPFunction || cpp instanceof ICPPVariable) { if (cpp instanceof ICPPNamespace || cpp instanceof ICPPFunction || cpp instanceof ICPPVariable) {
IScope scope= cpp.getScope(); IScope scope= cpp.getScope();
if (scope instanceof ICPPBlockScope == false && scope instanceof ICPPNamespaceScope) { if (!(scope instanceof ICPPBlockScope) && scope instanceof ICPPNamespaceScope) {
return true; return true;
} }
} else if (cpp instanceof ICompositeType || cpp instanceof IEnumeration) { } else if (cpp instanceof ICompositeType || cpp instanceof IEnumeration) {
IScope scope= cpp.getScope(); 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 this is not the definition, it may be found in a header. (bug 229571)
if (cpp.getDefinition() == null) { if (cpp.getDefinition() == null) {
return true; return true;

View file

@ -86,16 +86,17 @@ public class ImplementMethodRefactoring extends CRefactoring2 {
} }
@Override @Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException { public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
throws CoreException, OperationCanceledException {
SubMonitor sm = SubMonitor.convert(pm, 10); SubMonitor sm = SubMonitor.convert(pm, 10);
super.checkInitialConditions(sm.newChild(6)); super.checkInitialConditions(sm.newChild(6));
if (!initStatus.hasFatalError()) { if (!initStatus.hasFatalError()) {
List<IASTSimpleDeclaration> unimplementedMethodDeclarations = findUnimplementedMethodDeclarations(pm); List<IASTSimpleDeclaration> unimplementedMethodDeclarations =
findUnimplementedMethodDeclarations(pm);
if (unimplementedMethodDeclarations.isEmpty()) { if (unimplementedMethodDeclarations.isEmpty()) {
initStatus.addFatalError(Messages.ImplementMethodRefactoring_NoMethodToImplement); initStatus.addFatalError(Messages.ImplementMethodRefactoring_NoMethodToImplement);
} } else {
else {
data.setMethodDeclarations(unimplementedMethodDeclarations); data.setMethodDeclarations(unimplementedMethodDeclarations);
if (selectedRegion.getLength() > 0) { if (selectedRegion.getLength() > 0) {

View file

@ -27,7 +27,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
*/ */
public class ImplementMethodRefactoringWizard extends RefactoringWizard { public class ImplementMethodRefactoringWizard extends RefactoringWizard {
private final ImplementMethodRefactoring refactoring; private final ImplementMethodRefactoring refactoring;
private Map<MethodToImplementConfig, ParameterNamesInputPage>pagesMap = private Map<MethodToImplementConfig, ParameterNamesInputPage> pagesMap =
new HashMap<MethodToImplementConfig, ParameterNamesInputPage>(); new HashMap<MethodToImplementConfig, ParameterNamesInputPage>();
public ImplementMethodRefactoringWizard(ImplementMethodRefactoring refactoring) { 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 * 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 * AST so we need to make sure they are done before disposing the cache
* <p> * <p>

View file

@ -44,21 +44,21 @@ import org.eclipse.cdt.internal.ui.util.EditorUtility;
public class DefinitionFinder { public class DefinitionFinder {
public static IASTName getDefinition(IASTSimpleDeclaration simpleDeclaration, public static IASTName getDefinition(IASTSimpleDeclaration simpleDeclaration,
CRefactoringContext astCache, IProgressMonitor pm) throws CoreException { CRefactoringContext refactoringContext, IProgressMonitor pm) throws CoreException {
IIndex index = astCache.getIndex(); IIndex index = refactoringContext.getIndex();
IASTDeclarator declarator = simpleDeclaration.getDeclarators()[0];
if (index == null) { if (index == null) {
return null; return null;
} }
IASTDeclarator declarator = simpleDeclaration.getDeclarators()[0];
IIndexBinding binding = index.adaptBinding(declarator.getName().resolveBinding()); IIndexBinding binding = index.adaptBinding(declarator.getName().resolveBinding());
if (binding == null) { if (binding == null) {
return null; return null;
} }
return getDefinition(binding, astCache, index, pm); return getDefinition(binding, refactoringContext, index, pm);
} }
private static IASTName getDefinition(IIndexBinding binding, 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>(); Set<String> searchedFiles = new HashSet<String>();
List<IASTName> definitions = new ArrayList<IASTName>(); List<IASTName> definitions = new ArrayList<IASTName>();
IEditorPart[] dirtyEditors = EditorUtility.getDirtyEditors(true); IEditorPart[] dirtyEditors = EditorUtility.getDirtyEditors(true);
@ -70,7 +70,7 @@ public class DefinitionFinder {
if (editorInput instanceof ITranslationUnitEditorInput) { if (editorInput instanceof ITranslationUnitEditorInput) {
ITranslationUnit tu = ITranslationUnit tu =
CModelUtil.toWorkingCopy(((ITranslationUnitEditorInput) editorInput).getTranslationUnit()); CModelUtil.toWorkingCopy(((ITranslationUnitEditorInput) editorInput).getTranslationUnit());
findDefinitionsInTranslationUnit(binding, tu, astCache, definitions, null); findDefinitionsInTranslationUnit(binding, tu, refactoringContext, definitions, null);
searchedFiles.add(tu.getLocation().toOSString()); searchedFiles.add(tu.getLocation().toOSString());
} }
} }
@ -83,7 +83,7 @@ public class DefinitionFinder {
ITranslationUnit tu = CoreModelUtil.findTranslationUnitForLocation( ITranslationUnit tu = CoreModelUtil.findTranslationUnitForLocation(
name.getFile().getLocation(), null); name.getFile().getLocation(), null);
if (searchedFiles.add(tu.getLocation().toOSString())) { 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, 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 { throws OperationCanceledException, CoreException {
IASTTranslationUnit ast = astCache.getAST(tu, pm); IASTTranslationUnit ast = refactoringContext.getAST(tu, pm);
findDefinitionsInAST(binding, ast, tu, definitions); findDefinitionsInAST(binding, ast, tu, definitions);
} }