diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CaseBreakQuickFixBreak.java b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CaseBreakQuickFixBreak.java index 97878a20028..7de791f5e8c 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CaseBreakQuickFixBreak.java +++ b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CaseBreakQuickFixBreak.java @@ -53,7 +53,7 @@ public class CaseBreakQuickFixBreak extends AbstractAstRewriteQuickFix { IASTNode containedNode = nodeSelector.findFirstContainedNode(lineInformation.getOffset(), lineInformation.getLength()); IASTNode beforeBreakNode = null; if (containedNode != null) - beforeBreakNode = CxxAstUtils.getInstance().getEnclosingStatement(containedNode); + beforeBreakNode = CxxAstUtils.getEnclosingStatement(containedNode); else beforeBreakNode = nodeSelector.findEnclosingNode(lineInformation.getOffset(), lineInformation.getLength()); if (beforeBreakNode instanceof IASTCompoundStatement) { diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CaseBreakQuickFixComment.java b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CaseBreakQuickFixComment.java index 7a15d6430d9..2ed2893fabc 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CaseBreakQuickFixComment.java +++ b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CaseBreakQuickFixComment.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2011 Alena Laskavaia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alena Laskavaia - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.codan.internal.checkers.ui.quickfix; import org.eclipse.cdt.codan.core.model.IProblem; diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CatchByConstReferenceQuickFix.java b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CatchByConstReferenceQuickFix.java index f8337c4b683..4a469d0923e 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CatchByConstReferenceQuickFix.java +++ b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CatchByConstReferenceQuickFix.java @@ -17,7 +17,7 @@ import org.eclipse.core.resources.IMarker; import org.eclipse.jface.text.IDocument; /** - * quick fix for catch by value + * Quick fix for catch by value */ public class CatchByConstReferenceQuickFix extends AbstractCodanCMarkerResolution { @Override diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CatchByReferenceQuickFix.java b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CatchByReferenceQuickFix.java index 9136c2ff6ce..3218e48e567 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CatchByReferenceQuickFix.java +++ b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CatchByReferenceQuickFix.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Alena Laskavaia - initial API and implementation + * Alena Laskavaia - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.codan.internal.checkers.ui.quickfix; @@ -18,7 +18,7 @@ import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; /** - * quick fix for catch by value + * Quick fix for catch by value */ public class CatchByReferenceQuickFix extends AbstractCodanCMarkerResolution { @Override diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixAssignmentInCondition.java b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixAssignmentInCondition.java index c4d0f14efc0..422713fc7e5 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixAssignmentInCondition.java +++ b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixAssignmentInCondition.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Gvozdev - initial API and implementation + * Andrew Gvozdev - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.codan.internal.checkers.ui.quickfix; diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateField.java b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateField.java index b460058bb37..a499c3e0b1c 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateField.java +++ b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateField.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Tomasz Wesolowski - initial API and implementation + * Tomasz Wesolowski - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.codan.internal.checkers.ui.quickfix; @@ -40,19 +40,18 @@ public class QuickFixCreateField extends AbstractAstRewriteQuickFix { @Override public void modifyAST(IIndex index, IMarker marker) { - CxxAstUtils utils = CxxAstUtils.getInstance(); try { IASTTranslationUnit ast = getTranslationUnitViaEditor(marker).getAST(index, ITranslationUnit.AST_SKIP_INDEXED_HEADERS); IASTName astName = getASTNameFromMarker(marker, ast); if (astName == null) { return; } - IASTDeclaration declaration = utils.createDeclaration(astName, ast.getASTNodeFactory(), index); - IASTCompositeTypeSpecifier targetCompositeType = utils.getEnclosingCompositeTypeSpecifier(astName); + IASTDeclaration declaration = CxxAstUtils.createDeclaration(astName, ast.getASTNodeFactory(), index); + IASTCompositeTypeSpecifier targetCompositeType = CxxAstUtils.getEnclosingCompositeTypeSpecifier(astName); if (targetCompositeType == null) { // We're not in an inline method; // check if we're in a method at all - targetCompositeType = utils.getCompositeTypeFromFunction(utils.getEnclosingFunction(astName), index); + targetCompositeType = CxxAstUtils.getCompositeTypeFromFunction(CxxAstUtils.getEnclosingFunction(astName), index); if (targetCompositeType == null) { return; } diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateLocalVariable.java b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateLocalVariable.java index ff330b1c7bb..cf9eecc07bc 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateLocalVariable.java +++ b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateLocalVariable.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Tomasz Wesolowski - initial API and implementation + * Tomasz Wesolowski - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.codan.internal.checkers.ui.quickfix; @@ -33,15 +33,8 @@ public class QuickFixCreateLocalVariable extends AbstractAstRewriteQuickFix { return Messages.QuickFixCreateLocalVariable_0; } - /** - * - * @param ast - * @param astName - * @param r - */ @Override public void modifyAST(IIndex index, IMarker marker) { - CxxAstUtils utils = CxxAstUtils.getInstance(); IASTTranslationUnit ast; try { ITranslationUnit tu = getTranslationUnitViaEditor(marker); @@ -61,9 +54,9 @@ public class QuickFixCreateLocalVariable extends AbstractAstRewriteQuickFix { } ASTRewrite r = ASTRewrite.create(ast); INodeFactory factory = ast.getASTNodeFactory(); - IASTDeclaration declaration = utils.createDeclaration(astName, factory, index); + IASTDeclaration declaration = CxxAstUtils.createDeclaration(astName, factory, index); IASTDeclarationStatement newStatement = factory.newDeclarationStatement(declaration); - IASTNode targetStatement = utils.getEnclosingStatement(astName); + IASTNode targetStatement = CxxAstUtils.getEnclosingStatement(astName); if (targetStatement == null) { return; } diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateParameter.java b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateParameter.java index afc17a25008..0ffefec2e0d 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateParameter.java +++ b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateParameter.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Tomasz Wesolowski - initial API and implementation + * Tomasz Wesolowski - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.codan.internal.checkers.ui.quickfix; @@ -45,7 +45,6 @@ public class QuickFixCreateParameter extends AbstractAstRewriteQuickFix { @Override public void modifyAST(IIndex index, IMarker marker) { - CxxAstUtils utils = CxxAstUtils.getInstance(); CompositeChange c = new CompositeChange(Messages.QuickFixCreateParameter_0); try { ITranslationUnit baseTU = getTranslationUnitViaEditor(marker); @@ -54,11 +53,11 @@ public class QuickFixCreateParameter extends AbstractAstRewriteQuickFix { if (astName == null) { return; } - IASTDeclaration declaration = CxxAstUtils.getInstance().createDeclaration(astName, baseAST.getASTNodeFactory(), index); + IASTDeclaration declaration = CxxAstUtils.createDeclaration(astName, baseAST.getASTNodeFactory(), index); // We'll need a FunctionParameterDeclaration later final IASTDeclSpecifier finalDeclSpec = (IASTDeclSpecifier) declaration.getChildren()[0]; final IASTDeclarator finalDeclarator = (IASTDeclarator) declaration.getChildren()[1]; - IASTFunctionDefinition function = utils.getEnclosingFunction(astName); + IASTFunctionDefinition function = CxxAstUtils.getEnclosingFunction(astName); if (function == null) { return; } @@ -74,7 +73,7 @@ public class QuickFixCreateParameter extends AbstractAstRewriteQuickFix { HashMap cachedASTs = new HashMap(); HashMap cachedRewrites = new HashMap(); for (IIndexName iname : declarations) { - ITranslationUnit declTU = utils.getTranslationUnitFromIndexName(iname); + ITranslationUnit declTU = CxxAstUtils.getTranslationUnitFromIndexName(iname); ASTRewrite rewrite; IASTTranslationUnit declAST; if (!cachedASTs.containsKey(declTU)) { diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AbstractClassInstantiationChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AbstractClassInstantiationChecker.java index 927f37209a9..0461da5b940 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AbstractClassInstantiationChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AbstractClassInstantiationChecker.java @@ -51,7 +51,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper; */ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker { public static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation"; //$NON-NLS-1$ - private HashMap pureVirtualMethodsCache = new HashMap(); + private final HashMap pureVirtualMethodsCache = new HashMap(); @Override public void initPreferences(IProblemWorkingCopy problem) { @@ -189,7 +189,7 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker { * If it is, reports violations on each pure virtual method */ private void reportProblemsIfAbstract(IType typeToCheck, IASTNode problemNode ) { - IType unwindedType = CxxAstUtils.getInstance().unwindTypedef(typeToCheck); + IType unwindedType = CxxAstUtils.unwindTypedef(typeToCheck); if (!(unwindedType instanceof ICPPClassType) || unwindedType instanceof IProblemBinding) { return; } diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CaseBreakChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CaseBreakChecker.java index 13f4f3c21ef..dc39e19c277 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CaseBreakChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CaseBreakChecker.java @@ -71,10 +71,9 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke * - "exit" */ protected boolean isBreakOrExitStatement(IASTStatement statement) { - CxxAstUtils utils = CxxAstUtils.getInstance(); return (statement instanceof IASTBreakStatement) || statement instanceof IASTReturnStatement || statement instanceof IASTContinueStatement || statement instanceof IASTGotoStatement - || utils.isThrowStatement(statement) || utils.isExitStatement(statement); + || CxxAstUtils.isThrowStatement(statement) || CxxAstUtils.isExitStatement(statement); } @Override diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CatchByReference.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CatchByReference.java index 6d493a11e80..ee4de9bbcd9 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CatchByReference.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CatchByReference.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Alena Laskavaia - initial API and implementation + * Alena Laskavaia - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.codan.internal.checkers; @@ -72,7 +72,7 @@ public class CatchByReference extends AbstractIndexAstChecker { if (spec instanceof IASTNamedTypeSpecifier) { IASTName tname = ((IASTNamedTypeSpecifier) spec).getName(); IType typeName = (IType) tname.resolveBinding(); - typeName = CxxAstUtils.getInstance().unwindTypedef(typeName); + typeName = CxxAstUtils.unwindTypedef(typeName); if (typeName instanceof IBasicType || typeName instanceof IPointerType || typeName == null) continue; if (typeName instanceof IProblemBinding && !shouldReportForUnknownType()) diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ClassMembersInitializationChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ClassMembersInitializationChecker.java index ccd265c378e..ca27fa12035 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ClassMembersInitializationChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ClassMembersInitializationChecker.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Anton Gorenkov - initial implementation + * Anton Gorenkov - initial implementation *******************************************************************************/ package org.eclipse.cdt.codan.internal.checkers; diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ProblemBindingChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ProblemBindingChecker.java index a5eba7e178c..e6efcdea7d4 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ProblemBindingChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ProblemBindingChecker.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Marc-Andre Laperle - Initial API and implementation - * Tomasz Wesolowski - Extension for fixes + * Marc-Andre Laperle - Initial API and implementation + * Tomasz Wesolowski - Extension for fixes *******************************************************************************/ package org.eclipse.cdt.codan.internal.checkers; @@ -179,11 +179,10 @@ public class ProblemBindingChecker extends AbstractIndexAstChecker { } private boolean isInClassContext(IASTName name) { - CxxAstUtils utils = CxxAstUtils.getInstance(); - if (utils.getEnclosingCompositeTypeSpecifier(name) != null) { + if (CxxAstUtils.getEnclosingCompositeTypeSpecifier(name) != null) { return true; } - IASTFunctionDefinition function = utils.getEnclosingFunction(name); + IASTFunctionDefinition function = CxxAstUtils.getEnclosingFunction(name); if (function == null) { return false; } @@ -194,8 +193,7 @@ public class ProblemBindingChecker extends AbstractIndexAstChecker { } private boolean isInFunctionContext(IASTName name) { - CxxAstUtils utils = CxxAstUtils.getInstance(); - IASTFunctionDefinition function = utils.getEnclosingFunction(name); + IASTFunctionDefinition function = CxxAstUtils.getEnclosingFunction(name); return (function != null); } diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnChecker.java index 8747dfacb2b..07825aa1ab4 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnChecker.java @@ -204,13 +204,14 @@ public class ReturnChecker extends AbstractAstFunctionChecker { * @return */ private boolean isCompoundStatement(IASTStatement last) { - return last instanceof IASTIfStatement || last instanceof IASTWhileStatement || last instanceof IASTDoStatement - || last instanceof IASTForStatement || last instanceof IASTSwitchStatement || last instanceof IASTCompoundStatement; + return last instanceof IASTIfStatement || last instanceof IASTWhileStatement || + last instanceof IASTDoStatement || last instanceof IASTForStatement || + last instanceof IASTSwitchStatement || last instanceof IASTCompoundStatement; } protected boolean isFuncExitStatement(IASTStatement statement) { - CxxAstUtils utils = CxxAstUtils.getInstance(); - return statement instanceof IASTReturnStatement || utils.isThrowStatement(statement) || utils.isExitStatement(statement); + return statement instanceof IASTReturnStatement || CxxAstUtils.isThrowStatement(statement) || + CxxAstUtils.isExitStatement(statement); } /** @@ -300,7 +301,7 @@ public class ReturnChecker extends AbstractAstFunctionChecker { type = ((IASTSimpleDeclSpecifier) declSpecifier).getType(); } else if (declSpecifier instanceof IASTNamedTypeSpecifier) { IBinding binding = ((IASTNamedTypeSpecifier) declSpecifier).getName().resolveBinding(); - IType utype = CxxAstUtils.getInstance().unwindTypedef((IType) binding); + IType utype = CxxAstUtils.unwindTypedef((IType) binding); if (isVoid(utype)) return IASTSimpleDeclSpecifier.t_void; } diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/CxxAstUtils.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/CxxAstUtils.java index e7214b3016d..afe58718799 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/CxxAstUtils.java +++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/CxxAstUtils.java @@ -75,7 +75,7 @@ public final class CxxAstUtils { } } - private class FunctionNameFinderVisitor extends NameFinderVisitor { + private static class FunctionNameFinderVisitor extends NameFinderVisitor { { shouldVisitExpressions = true; } @@ -90,19 +90,11 @@ public final class CxxAstUtils { } } - private static CxxAstUtils instance; - + // Not instantiatable. All methods are static. private CxxAstUtils() { - // private constructor } - public synchronized static CxxAstUtils getInstance() { - if (instance == null) - instance = new CxxAstUtils(); - return instance; - } - - public IType unwindTypedef(IType type) { + public static IType unwindTypedef(IType type) { if (!(type instanceof IBinding)) return type; IBinding typeName = (IBinding) type; @@ -129,21 +121,21 @@ public final class CxxAstUtils { return macro != null; } - public IASTFunctionDefinition getEnclosingFunction(IASTNode node) { + public static IASTFunctionDefinition getEnclosingFunction(IASTNode node) { while (node != null && !(node instanceof IASTFunctionDefinition)) { node = node.getParent(); } return (IASTFunctionDefinition) node; } - public IASTCompositeTypeSpecifier getEnclosingCompositeTypeSpecifier(IASTNode node) { + public static IASTCompositeTypeSpecifier getEnclosingCompositeTypeSpecifier(IASTNode node) { while (node != null && !(node instanceof IASTCompositeTypeSpecifier)) { node = node.getParent(); } return (IASTCompositeTypeSpecifier) node; } - public IASTStatement getEnclosingStatement(IASTNode node) { + public static IASTStatement getEnclosingStatement(IASTNode node) { while (node != null && !(node instanceof IASTStatement)) { node = node.getParent(); } @@ -158,7 +150,7 @@ public final class CxxAstUtils { * @param index * @return */ - public IASTDeclaration createDeclaration(IASTName astName, INodeFactory factory, IIndex index) { + public static IASTDeclaration createDeclaration(IASTName astName, INodeFactory factory, IIndex index) { // Depending on context, either a type or a declaration is easier to // infer IType inferredType = null; @@ -193,7 +185,7 @@ public final class CxxAstUtils { * * @return inferred type or null if couldn't infer */ - private IType tryInferTypeFromBinaryExpr(IASTName astName) { + private static IType tryInferTypeFromBinaryExpr(IASTName astName) { if (astName.getParent() instanceof IASTIdExpression && astName.getParent().getParent() instanceof IASTBinaryExpression) { IASTNode binaryExpr = astName.getParent().getParent(); for (IASTNode node : binaryExpr.getChildren()) { @@ -214,7 +206,7 @@ public final class CxxAstUtils { * * @return a generated declaration or null if not suitable */ - private IASTSimpleDeclaration tryInferTypeFromFunctionCall(IASTName astName, INodeFactory factory, IIndex index) { + private static IASTSimpleDeclaration tryInferTypeFromFunctionCall(IASTName astName, INodeFactory factory, IIndex index) { if (astName.getParent() instanceof IASTIdExpression && astName.getParent().getParent() instanceof IASTFunctionCallExpression && astName.getParent().getPropertyInParent() == IASTFunctionCallExpression.ARGUMENT) { IASTFunctionCallExpression call = (IASTFunctionCallExpression) astName.getParent().getParent(); @@ -304,14 +296,14 @@ public final class CxxAstUtils { return null; } - private void setNameInNestedDeclarator(IASTDeclarator declarator, IASTName astName) { + private static void setNameInNestedDeclarator(IASTDeclarator declarator, IASTName astName) { while (declarator.getNestedDeclarator() != null) { declarator = declarator.getNestedDeclarator(); } declarator.setName(astName); } - public ITranslationUnit getTranslationUnitFromIndexName(IIndexName decl) throws CoreException { + public static ITranslationUnit getTranslationUnitFromIndexName(IIndexName decl) throws CoreException { Path path = new Path(decl.getFile().getLocation().getFullPath()); IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); ITranslationUnit tu = (ITranslationUnit) CoreModel.getDefault().create(file); @@ -328,7 +320,7 @@ public final class CxxAstUtils { * the index to use for name lookup * @return Either a type specifier or null */ - public IASTCompositeTypeSpecifier getCompositeTypeFromFunction(final IASTFunctionDefinition function, final IIndex index) { + public static IASTCompositeTypeSpecifier getCompositeTypeFromFunction(final IASTFunctionDefinition function, final IIndex index) { // return value to be set via visitor final IASTCompositeTypeSpecifier returnSpecifier[] = { null }; final HashMap astCache = new HashMap(); @@ -389,7 +381,7 @@ public final class CxxAstUtils { * @param body * @return */ - public boolean isThrowStatement(IASTNode body) { + public static boolean isThrowStatement(IASTNode body) { if (!(body instanceof IASTExpressionStatement)) return false; IASTExpression expression = ((IASTExpressionStatement) body).getExpression(); @@ -398,7 +390,7 @@ public final class CxxAstUtils { return ((IASTUnaryExpression) expression).getOperator() == IASTUnaryExpression.op_throw; } - public boolean isExitStatement(IASTNode body) { + public static boolean isExitStatement(IASTNode body) { if (!(body instanceof IASTExpressionStatement)) return false; IASTExpression expression = ((IASTExpressionStatement) body).getExpression(); @@ -407,6 +399,4 @@ public final class CxxAstUtils { IASTExpression functionNameExpression = ((IASTFunctionCallExpression) expression).getFunctionNameExpression(); return functionNameExpression.getRawSignature().equals("exit"); //$NON-NLS-1$ } - - } diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/cxx/CxxAstUtilsTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/cxx/CxxAstUtilsTest.java index 4d8a8d4ab14..7e4c036ca05 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/cxx/CxxAstUtilsTest.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/cxx/CxxAstUtilsTest.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2009,2010 QNX Software Systems + * Copyright (c) 2009, 2010 QNX Software Systems * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * QNX Software Systems (Alena Laskavaia) - initial API and implementation + * QNX Software Systems (Alena Laskavaia) - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.codan.core.cxx; @@ -31,13 +31,6 @@ import org.eclipse.cdt.core.dom.ast.c.ICBasicType; * Test CxxAstUtils */ public class CxxAstUtilsTest extends CodanFastCxxAstTestCase { - private CxxAstUtils instance; - - @Override - protected void setUp() throws Exception { - instance = CxxAstUtils.getInstance(); - } - @Override public IChecker getChecker() { return null; // not testing checker @@ -65,7 +58,7 @@ public class CxxAstUtilsTest extends CodanFastCxxAstTestCase { if (spec instanceof IASTNamedTypeSpecifier) { IASTName tname = ((IASTNamedTypeSpecifier) spec).getName(); IType typeName = (IType) tname.resolveBinding(); - result[0] = instance.unwindTypedef(typeName); + result[0] = CxxAstUtils.unwindTypedef(typeName); } } return PROCESS_CONTINUE; @@ -95,7 +88,7 @@ public class CxxAstUtilsTest extends CodanFastCxxAstTestCase { @Override public int visit(IASTStatement stmt) { if (stmt instanceof IASTExpressionStatement) { - boolean check = instance.isInMacro(((IASTExpressionStatement) stmt).getExpression()); + boolean check = CxxAstUtils.isInMacro(((IASTExpressionStatement) stmt).getExpression()); result[i] = check; i++; } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index 88031483a6e..d6afa8b3022 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -5703,4 +5703,14 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPDeferredClassInstance shortHand= bh.assertNonProblem("derived:", -1); assertTrue(shortHand.getClassTemplate() instanceof ICPPClassTemplatePartialSpecialization); } + + // template class A {}; + // template struct B {}; + // template struct B > { + // typedef int type; + // }; + // typedef B >::type type; // ERROR HERE + public void testPartialClassTemplateSpecUsingDefaultArgument_367997() throws Exception { + parseAndCheckBindings(); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index e8207e08630..6d25bb28016 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; +import static org.eclipse.cdt.core.parser.ParserLanguage.CPP; + import java.io.IOException; import junit.framework.TestSuite; @@ -24,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression; import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; import org.eclipse.cdt.core.dom.ast.IASTCaseStatement; import org.eclipse.cdt.core.dom.ast.IASTCastExpression; +import org.eclipse.cdt.core.dom.ast.IASTComment; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement; import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression; @@ -7386,5 +7389,16 @@ public class AST2Tests extends AST2BaseTest { IValue v= at.getSize(); assertTrue(v.numericalValue() == 4); } - } + } + + // #define NULL_STATEMENT_MACRO ;; + // void macro_test() { + // NULL_STATEMENT_MACRO //comment + // } + public void testCommentAfterMacroExpansion_367827() throws Exception { + IASTTranslationUnit tu= parse(getAboveComment(), CPP); + IASTComment comment= tu.getComments()[0]; + assertEquals("//comment", new String(comment.getComment())); + assertEquals("//comment", comment.getRawSignature()); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteBaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteBaseTest.java index 150d0307a45..70363a4f9a8 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteBaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteBaseTest.java @@ -13,9 +13,9 @@ package org.eclipse.cdt.core.parser.tests.rewrite; import java.io.BufferedReader; import java.io.InputStreamReader; +import java.util.List; import java.util.Map; import java.util.TreeMap; -import java.util.Vector; import org.eclipse.cdt.core.tests.BaseTestFramework; import org.eclipse.core.resources.IFile; @@ -38,8 +38,8 @@ public abstract class RewriteBaseTest extends BaseTestFramework implements ILogL protected RewriteBaseTest(String name) { super(name); } - - public RewriteBaseTest(String name, Vector files) { + + public RewriteBaseTest(String name, List files) { super(name); for (TestSourceFile file : files) { fileMap.put(file.getName(), file); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTester.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTester.java index a3a3d20a8a4..7fd51237662 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTester.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTester.java @@ -18,7 +18,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Iterator; -import java.util.Vector; +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -59,7 +59,7 @@ public class RewriteTester extends TestSuite { private static ArrayList createTests(BufferedReader inputReader) throws Exception { String line; - Vector files = new Vector(); + List files = new ArrayList(); TestSourceFile actFile = null; MatcherState matcherState = MatcherState.skip; ArrayList testCases = new ArrayList(); @@ -72,7 +72,7 @@ public class RewriteTester extends TestSuite { if (!bevorFirstTest) { RewriteBaseTest test = createTestClass(className, testName, files); testCases.add(test); - files = new Vector(); + files = new ArrayList(); className = null; testName = null; } @@ -114,17 +114,11 @@ public class RewriteTester extends TestSuite { } private static RewriteBaseTest createTestClass(String className, String testName, - Vector files) throws Exception { + List files) throws Exception { try { Class refClass = Class.forName(className); - Class paratypes[] = new Class[2]; - paratypes[0] = testName.getClass(); - paratypes[1] = files.getClass(); - Constructor ct = refClass.getConstructor(paratypes); - Object arglist[] = new Object[2]; - arglist[0] = testName; - arglist[1] = files; - RewriteBaseTest test = (RewriteBaseTest) ct.newInstance(arglist); + Constructor ct = refClass.getConstructor(new Class[] { String.class, List.class }); + RewriteBaseTest test = (RewriteBaseTest) ct.newInstance(new Object[] { testName, files }); for (TestSourceFile file : files) { TextSelection sel = file.getSelection(); if (sel != null) { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTest.java index 41eae83f14e..cda751ea9f3 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTest.java @@ -15,7 +15,6 @@ import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.TreeSet; -import java.util.Vector; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -85,7 +84,7 @@ public class CommentHandlingTest extends RewriteBaseTest { private static final String TRAILING_COMMENT_TITLE = "<<<=== Trailing Comment Test Section ===>>>"; //$NON-NLS-1$ private static final String FREESTANDING_COMMENT_TITLE = "<<<=== Freestanding Comment Test Section ===>>>"; //$NON-NLS-1$ - public CommentHandlingTest(String name, Vector files) { + public CommentHandlingTest(String name, List files) { super(name, files); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LocationMapTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LocationMapTests.java index 2c177dd0a6b..661231fea6f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LocationMapTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LocationMapTests.java @@ -477,9 +477,14 @@ public class LocationMapTests extends BaseTestCase { fLocationMap.encounterPoundDefine(3, 13, 33, 63, 103, true, macro3); IASTName name1= fLocationMap.encounterImplicitMacroExpansion(macro1, null); IASTName name2= fLocationMap.encounterImplicitMacroExpansion(macro2, null); - fLocationMap.pushMacroExpansion(110, 115, 125, 30, macro3, new IASTName[]{name1, name2}, new ImageLocationInfo[0]); - fLocationMap.encounteredComment(12, 23, false); - checkComment(fLocationMap.getComments()[0], new String(LONGDIGITS, 110, 15), false, FN, 110, 15, 2, 2); + ILocationCtx me = fLocationMap.pushMacroExpansion(110, 115, 125, 30, macro3, new IASTName[]{name1, name2}, new ImageLocationInfo[0]); + // Comment in expansion + fLocationMap.encounteredComment(116, 120, false); + // Comment right after expansion, reported before expansion completes. + fLocationMap.encounteredComment(125, 140, false); + fLocationMap.popContext(me); + checkComment(fLocationMap.getComments()[0], new String(LONGDIGITS, 116, 4), false, FN, 116, 4, 2, 2); + checkComment(fLocationMap.getComments()[1], new String(LONGDIGITS, 125, 15), false, FN, 125, 15, 2, 2); IASTName[] refs= fLocationMap.getReferences(macro3); assertEquals(1, refs.length); @@ -505,7 +510,6 @@ public class LocationMapTests extends BaseTestCase { // number: [0,6)[26,30) ILocationCtx pre2= fLocationMap.pushPreInclusion(new CharArray("a1a2a3a4a5"), 0, true); assertEquals(FN, fLocationMap.getCurrentFilePath()); - fLocationMap.encounteredComment(0,2,true); // number: [6,15)[25,26) ILocationCtx i1= fLocationMap.pushInclusion(0, 2, 4, 6, new CharArray("b1b2b3b4b5"), "pre1", "pre1".toCharArray(), false, false, false); assertEquals("pre1", fLocationMap.getCurrentFilePath()); @@ -533,11 +537,10 @@ public class LocationMapTests extends BaseTestCase { IASTComment[] comments= fLocationMap.getComments(); - checkComment(comments[0], "", true, FN, 0, 0, 1, 1); - checkComment(comments[1], "b2", true, "pre1", 2, 2, 1, 1); - checkComment(comments[2], "c2c3", true, "pre11", 2, 4, 1, 1); - checkComment(comments[3], "b3", false, "pre1", 4, 2, 1, 1); - checkComment(comments[4], "d1", true, "pre2", 0, 2, 1, 1); + checkComment(comments[0], "b2", true, "pre1", 2, 2, 1, 1); + checkComment(comments[1], "c2c3", true, "pre11", 2, 4, 1, 1); + checkComment(comments[2], "b3", false, "pre1", 4, 2, 1, 1); + checkComment(comments[3], "d1", true, "pre2", 0, 2, 1, 1); checkLocation(fLocationMap.getMappedFileLocation(0, 6), FN, 0, 0, 1, 1); checkLocation(fLocationMap.getMappedFileLocation(6, 9), "pre1", 0, 9, 1, 1); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMSearchTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMSearchTest.java index c642f470b1e..d9cc6b78319 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMSearchTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMSearchTest.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM Corporation - initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.pdom.tests; @@ -41,7 +41,6 @@ import org.eclipse.core.runtime.NullProgressMonitor; * Test the correctness of C/C++ searches * * @author Vivian Kong - * */ public class PDOMSearchTest extends PDOMTestBase { final Comparator BINDING_COMPARATOR = new Comparator() { @@ -72,11 +71,11 @@ public class PDOMSearchTest extends PDOMTestBase { protected void tearDown() throws Exception { pdom.releaseReadLock(); } + /** * Test the members inside namespaces */ public void testNamespaces() throws Exception { - /* Members in the namespace */ IBinding[] namespaces = pdom.findBindings(Pattern.compile("namespace1"), false, INDEX_FILTER, NULL_MONITOR); assertEquals(1, namespaces.length); @@ -117,7 +116,6 @@ public class PDOMSearchTest extends PDOMTestBase { assertEquals(1, defs.length); loc = defs[0].getFileLocation(); assertEquals(offset("Class1.h","namespace namespace1") + 10, loc.getNodeOffset()); //character offset - } public void testClasses() throws Exception { @@ -223,7 +221,6 @@ public class PDOMSearchTest extends PDOMTestBase { } public void testFunction() throws Exception { - IBinding[] functions = pdom.findBindings(Pattern.compile("foo2"), false, INDEX_FILTER, NULL_MONITOR); assertEquals(1, functions.length); assertTrue(functions[0] instanceof ICPPFunction); @@ -233,20 +230,16 @@ public class PDOMSearchTest extends PDOMTestBase { assertEquals(1, functions.length); assertTrue(functions[0] instanceof ICPPFunction); assertEquals("main", getBindingQualifiedName(pdom.getLinkageImpls()[0].adaptBinding(functions[0]))); - } public void testMethods() throws Exception { - IBinding[] methods = pdom.findBindings(Pattern.compile("~Class2"), false, INDEX_FILTER, NULL_MONITOR); assertEquals(1, methods.length); assertTrue(methods[0] instanceof ICPPMethod); assertEquals("Class2::~Class2", getBindingQualifiedName(pdom.getLinkageImpls()[0].adaptBinding(methods[0]))); - } public void testFields() throws Exception { - IBinding[] fields = pdom.findBindings(Pattern.compile("class1x"), false, INDEX_FILTER, NULL_MONITOR); assertEquals(1, fields.length); assertTrue(fields[0] instanceof ICPPField); @@ -256,11 +249,9 @@ public class PDOMSearchTest extends PDOMTestBase { assertEquals(1, fields.length); assertTrue(fields[0] instanceof ICPPField); assertEquals("namespace1::Class1::class1y", getBindingQualifiedName(pdom.getLinkageImpls()[0].adaptBinding(fields[0]))); - } public void testVariables() throws Exception { - IBinding[] variables = pdom.findBindings(Pattern.compile("var"), false, INDEX_FILTER, NULL_MONITOR); assertEquals(1, variables.length); assertTrue(variables[0] instanceof ICPPVariable); @@ -283,7 +274,6 @@ public class PDOMSearchTest extends PDOMTestBase { assertEquals(1, defs.length); loc = defs[0].getFileLocation(); assertEquals(offset("main.cpp","int var;") + 4, loc.getNodeOffset()); //character offset - } /** diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/Main.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/Main.java index 2c8057143e2..588257516eb 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/Main.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/Main.java @@ -22,8 +22,8 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; +import java.util.List; import java.util.StringTokenizer; -import java.util.Vector; /** * Startup class for Eclipse. Creates a class loader using * supplied URL of platform installation, loads and calls @@ -181,14 +181,14 @@ protected Object basicRun(String[] args) throws Exception { private String[] getArrayFromList(String prop) { if (prop == null || prop.trim().equals("")) return new String[0]; - Vector list = new Vector(); + List list = new ArrayList(); StringTokenizer tokens = new StringTokenizer(prop, ","); while (tokens.hasMoreTokens()) { String token = tokens.nextToken().trim(); if (!token.equals("")) - list.addElement(token); + list.add(token); } - return list.isEmpty() ? new String[0] : (String[]) list.toArray(new String[0]); + return list.toArray(new String[list.size()]); } /** * Creates and returns a platform BootLoader which can be used to start @@ -404,10 +404,10 @@ public static void endSplash() { * @exception Exception thrown if a problem occurs during launching */ public static void main(String argString) throws Exception { - Vector list = new Vector(5); + List list = new ArrayList(5); for (StringTokenizer tokens = new StringTokenizer(argString, " "); tokens.hasMoreElements();) - list.addElement(tokens.nextElement()); - main((String[]) list.toArray(new String[list.size()])); + list.add((String) tokens.nextElement()); + main(list.toArray(new String[list.size()])); } /** diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/NewMain.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/NewMain.java index f570c06b5d1..de29162a058 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/NewMain.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/NewMain.java @@ -14,18 +14,17 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.net.URL; +import java.util.ArrayList; +import java.util.List; import java.util.Properties; import java.util.StringTokenizer; -import java.util.Vector; /** * Application is responsible for calling core launch api */ - public class NewMain extends Main { private static final String DEFAULT_APPLICATION= "org.eclipse.ui.workbench"; - public NewMain(String application, String location, URL pluginPathLocation, String bootLocation, boolean debug) throws IOException { this.application= application; this.location= location; @@ -44,17 +43,16 @@ public class NewMain extends Main { System.exit(0); } - /** * Run this launcher with the arguments specified in the given string. * This is a short cut method for people running the launcher from * a scrapbook (i.e., swip-and-doit facility). */ public static void main(String argString) throws Exception { - Vector list= new Vector(5); + List list= new ArrayList(5); for (StringTokenizer tokens= new StringTokenizer(argString, " "); tokens.hasMoreElements();) - list.addElement(tokens.nextElement()); - main((String[]) list.toArray(new String[list.size()])); + list.add((String) tokens.nextElement()); + main(list.toArray(new String[list.size()])); } public static String getLocationFromProperties(String key) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLabelStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLabelStatement.java index e856f4c5de6..d0da8fea66a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLabelStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLabelStatement.java @@ -17,6 +17,8 @@ package org.eclipse.cdt.core.dom.ast; * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTLabelStatement extends IASTStatement, IASTNameOwner { + /** @since 5.4 */ + public static final IASTStatement[] EMPTY_LABEL_STATEMENT_ARRAY = {}; public static final ASTNodeProperty NAME = new ASTNodeProperty("IASTLabelStatement.NAME - name for IASTLabelStatement"); //$NON-NLS-1$ public static final ASTNodeProperty NESTED_STATEMENT = new ASTNodeProperty( "IASTLabelStatement.NESTED_STATEMENT - statement for IASTLabelStatement" ); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStatement.java index eab95eb8392..e1ed40c0af9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStatement.java @@ -20,7 +20,7 @@ public interface IASTStatement extends IASTNode { /** * Constant. */ - public static final IASTStatement[] EMPTY_STATEMENT_ARRAY = new IASTStatement[0]; + public static final IASTStatement[] EMPTY_STATEMENT_ARRAY = {}; /** * @since 5.1 diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBinding.java index 2477df5a19d..6f32a398fbb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBinding.java @@ -26,7 +26,8 @@ import org.eclipse.core.runtime.IAdaptable; * @noimplement This interface is not intended to be implemented by clients. */ public interface IBinding extends IAdaptable { - public static final IBinding[] EMPTY_BINDING_ARRAY = new IBinding[0]; + public static final IBinding[] EMPTY_BINDING_ARRAY = {}; + /** * Returns the unqualified name of the binding as a string. */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IField.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IField.java index 38e269ebeb3..57f36f9961b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IField.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IField.java @@ -16,8 +16,7 @@ package org.eclipse.cdt.core.dom.ast; * @noimplement This interface is not intended to be implemented by clients. */ public interface IField extends IVariable { - - public static final IField[] EMPTY_FIELD_ARRAY = new IField[0]; + public static final IField[] EMPTY_FIELD_ARRAY = {}; /** * Returns the composite type that owns the field. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ILabel.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ILabel.java index 6c963b85cec..8982f9b3c1b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ILabel.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ILabel.java @@ -18,7 +18,10 @@ package org.eclipse.cdt.core.dom.ast; * @noimplement This interface is not intended to be implemented by clients. */ public interface ILabel extends IBinding { - /** + /** @since 5.4 */ + public static final IBinding[] EMPTY_LABEL_ARRAY = {}; + + /** * Returns the label statement for this label. */ public IASTLabelStatement getLabelStatement(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java index 5bd2d9863ba..6f981587f47 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java @@ -15,6 +15,7 @@ package org.eclipse.cdt.core.parser.util; import java.lang.reflect.Array; +import java.util.Arrays; import org.eclipse.core.runtime.Assert; @@ -31,7 +32,7 @@ public abstract class ArrayUtil { * the given class object. */ @SuppressWarnings("unchecked") - static public T[] append(Class c, T[] array, T obj) { + static public T[] append(Class c, T[] array, T obj) { if (obj == null) return array; if (array == null || array.length == 0) { @@ -52,26 +53,6 @@ public abstract class ArrayUtil { return temp; } - /** - * Assumes that array contains nulls at the end, only. - * @returns index of first null, or -1 - */ - private static int findFirstNull(Object[] array) { - boolean haveNull= false; - int left= 0; - int right= array.length - 1; - while (left <= right) { - int mid= (left + right) / 2; - if (array[mid] == null) { - haveNull= true; - right= mid - 1; - } else { - left= mid + 1; - } - } - return haveNull ? right + 1 : -1; - } - /** * Assumes that array contains nulls at the end, only. * Appends element after the last non-null element. @@ -103,6 +84,26 @@ public abstract class ArrayUtil { return temp; } + /** + * Assumes that array contains nulls at the end, only. + * @returns index of first null, or -1 + */ + private static int findFirstNull(Object[] array) { + boolean haveNull= false; + int left= 0; + int right= array.length - 1; + while (left <= right) { + int mid= (left + right) / 2; + if (array[mid] == null) { + haveNull= true; + right= mid - 1; + } else { + left= mid + 1; + } + } + return haveNull ? right + 1 : -1; + } + /** * @deprecated Use {@link #appendAt(Class, Object[], int, Object)} instead. * @since 4.0 @@ -154,7 +155,7 @@ public abstract class ArrayUtil { * @param forceNew */ @SuppressWarnings("unchecked") - static public T[] trim(Class c, T[] array, boolean forceNew) { + static public T[] trim(Class c, T[] array, boolean forceNew) { if (array == null) return (T[]) Array.newInstance(c, 0); @@ -173,7 +174,7 @@ public abstract class ArrayUtil { return temp; } - public static T[] trim(Class c, T[] array) { + public static T[] trim(Class c, T[] array) { return trim(c, array, false); } @@ -188,7 +189,6 @@ public abstract class ArrayUtil { * @param forceNew * @since 5.2 */ - @SuppressWarnings("unchecked") static public T[] trim(T[] array, boolean forceNew) { int i = array.length; if (i == 0 || array[i - 1] != null) { @@ -200,9 +200,7 @@ public abstract class ArrayUtil { Assert.isTrue(i >= 0); } - T[] temp = (T[]) Array.newInstance(array.getClass().getComponentType(), i); - System.arraycopy(array, 0, temp, 0, i); - return temp; + return Arrays.copyOf(array, i); } /** @@ -227,7 +225,7 @@ public abstract class ArrayUtil { * @return The concatenated array, which may be the same as the first parameter. */ @SuppressWarnings("unchecked") - public static T[] addAll(Class c, T[] dest, T[] source) { + public static T[] addAll(Class c, T[] dest, Object[] source) { if (source == null || source.length == 0) return dest; @@ -254,10 +252,9 @@ public abstract class ArrayUtil { System.arraycopy(source, 0, dest, firstFree, numToAdd); return dest; } - T[] temp = (T[]) Array.newInstance(c, firstFree + numToAdd); - System.arraycopy(dest, 0, temp, 0, firstFree); - System.arraycopy(source, 0, temp, firstFree, numToAdd); - return temp; + dest = Arrays.copyOf(dest, firstFree + numToAdd); + System.arraycopy(source, 0, dest, firstFree, numToAdd); + return dest; } /** @@ -270,7 +267,7 @@ public abstract class ArrayUtil { * @since 5.2 */ @SuppressWarnings("unchecked") - public static T[] addAll(T[] dest, T[] source) { + public static T[] addAll(T[] dest, Object[] source) { if (source == null || source.length == 0) return dest; @@ -299,10 +296,9 @@ public abstract class ArrayUtil { System.arraycopy(source, 0, dest, firstFree, numToAdd); return dest; } - T[] temp = (T[]) Array.newInstance(dest.getClass().getComponentType(), firstFree + numToAdd); - System.arraycopy(dest, 0, temp, 0, firstFree); - System.arraycopy(source, 0, temp, firstFree, numToAdd); - return temp; + dest = Arrays.copyOf(dest, firstFree + numToAdd); + System.arraycopy(source, 0, dest, firstFree, numToAdd); + return dest; } /** @@ -379,7 +375,7 @@ public abstract class ArrayUtil { * If there are no nulls in the original array then the original array is returned. */ @SuppressWarnings("unchecked") - public static T[] removeNulls(Class c, T[] array) { + public static T[] removeNulls(Class c, T[] array) { if (array == null) return (T[]) Array.newInstance(c, 0); @@ -469,7 +465,7 @@ public abstract class ArrayUtil { * Assumes that array contains nulls at the end, only. */ @SuppressWarnings("unchecked") - public static T[] prepend(Class c, T[] array, T obj) { + public static T[] prepend(Class c, T[] array, T obj) { if (obj == null) return array; if (array == null || array.length == 0) { @@ -569,8 +565,8 @@ public abstract class ArrayUtil { * runtime type. * @param target the runtime type of the new array * @param source the source array - * @return the current array stored in a new array with the - * specified runtime type, or null if source is null. + * @return the current array stored in a new array with the specified runtime type, + * or null if source is null. */ @SuppressWarnings("unchecked") public static T[] convert(Class target, S[] source) { @@ -584,6 +580,30 @@ public abstract class ArrayUtil { return result; } + /** + * Reverses order of elements in an array. + * @param array the array + * @since 5.4 + */ + public static void reverse(Object[] array) { + reverse(array, 0, array.length); + } + + /** + * Reverses order of elements in a subsection of an array. + * @param array the array + * @param fromIndex the index of the first affected element (inclusive) + * @param toIndex the index of the last affected element (exclusive) + * @since 5.4 + */ + public static void reverse(Object[] array, int fromIndex, int toIndex) { + for (int i = fromIndex, j = toIndex; i < --j; i++) { + Object tmp = array[i]; + array[i] = array[j]; + array[j] = tmp; + } + } + /** * Returns a new array that contains all of the elements of the * given array except the first one. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java index c3d79aa6247..4d45e26519a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java @@ -40,8 +40,12 @@ public abstract class ASTNode implements IASTNode { private IASTNode parent; private ASTNodeProperty property; - private int length; + /** + * The sequence number of the ast-node as calculated by the location map. + * Do not access directly, because getOffset() may be overloaded for lazy calculations. + */ private int offset; + private int length; private IASTNodeLocation[] locations; private IASTFileLocation fileLocation; @@ -112,17 +116,20 @@ public abstract class ASTNode implements IASTNode { public void setOffset(int offset) { this.offset = offset; this.locations = null; + this.fileLocation = null; } public void setLength(int length) { this.length = length; this.locations = null; + this.fileLocation = null; } public void setOffsetAndLength(int offset, int length) { this.offset = offset; this.length = length; this.locations = null; + this.fileLocation = null; } public void setOffsetAndLength(ASTNode node) { @@ -140,7 +147,7 @@ public abstract class ASTNode implements IASTNode { if (tu != null) { ILocationResolver l= (ILocationResolver) tu.getAdapter(ILocationResolver.class); if (l != null) { - locations= l.getLocations(offset, length); + locations= l.getLocations(getOffset(), length); } } } @@ -152,7 +159,7 @@ public abstract class ASTNode implements IASTNode { if (tu != null) { ILocationResolver l= (ILocationResolver) tu.getAdapter(ILocationResolver.class); if (l != null) { - return l.getImageLocation(offset, length); + return l.getImageLocation(getOffset(), length); } } return null; @@ -177,7 +184,8 @@ public abstract class ASTNode implements IASTNode { @Override public String getContainingFilename() { - if (offset <= 0 && (length == 0 || offset < 0)) { + final int offset = getOffset(); + if (offset <= 0 && (length == 0 || offset < 0)) { final IASTNode parent = getParent(); if (parent == null) { if (this instanceof IASTTranslationUnit) { @@ -195,7 +203,8 @@ public abstract class ASTNode implements IASTNode { if (fileLocation != null) return fileLocation; // TODO(sprigogin): The purpose of offset == 0 && length == 0 condition is not clear to me. - if (offset < 0 || (offset == 0 && length == 0 && !(this instanceof IASTTranslationUnit))) { + final int offset = getOffset(); + if (offset < 0 || (offset == 0 && length == 0 && !(this instanceof IASTTranslationUnit))) { return null; } IASTTranslationUnit ast = getTranslationUnit(); @@ -217,7 +226,7 @@ public abstract class ASTNode implements IASTNode { if (ast != null) { ILocationResolver lr= (ILocationResolver) ast.getAdapter(ILocationResolver.class); if (lr != null) { - return lr.isPartOfTranslationUnitFile(offset); + return lr.isPartOfTranslationUnitFile(getOffset()); } } return false; @@ -228,7 +237,7 @@ public abstract class ASTNode implements IASTNode { if (ast != null) { ILocationResolver lr= (ILocationResolver) ast.getAdapter(ILocationResolver.class); if (lr != null) { - return lr.isPartOfSourceFile(offset); + return lr.isPartOfSourceFile(getOffset()); } } return false; @@ -248,27 +257,29 @@ public abstract class ASTNode implements IASTNode { public boolean contains(IASTNode node) { if (node instanceof ASTNode) { ASTNode astNode= (ASTNode) node; - return offset <= astNode.offset && - astNode.offset+astNode.length <= offset+length; + final int offset = getOffset(); + final int nodeOffset= astNode.getOffset(); + return offset <= nodeOffset && nodeOffset+astNode.length <= offset+length; } return false; } @Override public IToken getSyntax() throws ExpansionOverlapsBoundaryException { + final int offset = getOffset(); return getSyntax(offset, offset+length, 0); } @Override public IToken getLeadingSyntax() throws ExpansionOverlapsBoundaryException { int left= getBoundary(-1); - return getSyntax(left, offset, -1); + return getSyntax(left, getOffset(), -1); } @Override public IToken getTrailingSyntax() throws ExpansionOverlapsBoundaryException { int right= getBoundary(1); - return getSyntax(offset+length, right, 1); + return getSyntax(getOffset()+length, right, 1); } /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java index 0fb8c3ae9f2..491f570695f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ILinkage; -import org.eclipse.cdt.core.dom.IName; import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTTypeId; @@ -80,13 +79,13 @@ public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbig if (binding instanceof IMacroBinding) { return getMacroDefinitionsInAST((IMacroBinding) binding); } - IName[] names = CVisitor.getDeclarations(this, binding); + IASTName[] names = CVisitor.getDeclarations(this, binding); for (int i = 0; i < names.length; i++) { if (!names[i].isDefinition()) names[i] = null; } // nulls can be anywhere, don't use trim() - return (IASTName[])ArrayUtil.removeNulls(IASTName.class, names); + return ArrayUtil.removeNulls(IASTName.class, names); } /* diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CCompositeTypeScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CCompositeTypeScope.java index 5a80e30e0a7..f5537c5268f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CCompositeTypeScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CCompositeTypeScope.java @@ -95,10 +95,10 @@ public class CCompositeTypeScope extends CScope implements ICCompositeTypeScope } // anonymous structures and unions if (declarators.length == 0 && ((IASTSimpleDeclaration) node).getDeclSpecifier() instanceof IASTCompositeTypeSpecifier) { - IASTCompositeTypeSpecifier declSpec = (IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) node).getDeclSpecifier(); + ICASTCompositeTypeSpecifier declSpec = (ICASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) node).getDeclSpecifier(); IASTName n = declSpec.getName(); if (n.toCharArray().length == 0) { - specStack = (ICASTCompositeTypeSpecifier[]) ArrayUtil.append(ICASTCompositeTypeSpecifier.class, specStack, declSpec); + specStack = ArrayUtil.append(ICASTCompositeTypeSpecifier.class, specStack, declSpec); } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionScope.java index 802a92f1c92..959698cfc37 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionScope.java @@ -24,57 +24,57 @@ import org.eclipse.cdt.core.dom.ast.c.ICFunctionScope; import org.eclipse.cdt.core.parser.util.ArrayUtil; public class CFunctionScope extends CScope implements ICFunctionScope { - public CFunctionScope( IASTFunctionDefinition function ){ - super( function, EScopeKind.eLocal); + public CFunctionScope(IASTFunctionDefinition function) { + super(function, EScopeKind.eLocal); } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.c.ICFunctionScope#getBinding(char[]) */ @Override - public IBinding getBinding( char[] name ) { - return super.getBinding( NAMESPACE_TYPE_OTHER, name ); + public IBinding getBinding(char[] name) { + return super.getBinding(NAMESPACE_TYPE_OTHER, name); } @Override - public IScope getBodyScope(){ + public IScope getBodyScope() { IASTNode node = getPhysicalNode(); IASTStatement statement = ((IASTFunctionDefinition)node).getBody(); - if( statement instanceof IASTCompoundStatement ){ - return ((IASTCompoundStatement)statement).getScope(); + if (statement instanceof IASTCompoundStatement) { + return ((IASTCompoundStatement) statement).getScope(); } return null; } - public ILabel[] getLabels(){ + public ILabel[] getLabels() { FindLabelsAction action = new FindLabelsAction(); - getPhysicalNode().accept( action ); + getPhysicalNode().accept(action); - ILabel [] result = null; - if( action.labels != null ){ - for( int i = 0; i < action.labels.length && action.labels[i] != null; i++ ){ + ILabel[] result = null; + if (action.labels != null) { + for (int i = 0; i < action.labels.length && action.labels[i] != null; i++) { IASTLabelStatement labelStatement = action.labels[i]; IBinding binding = labelStatement.getName().resolveBinding(); - if( binding != null ) - result = (ILabel[]) ArrayUtil.append( ILabel.class, result, binding ); + if (binding != null) + result = ArrayUtil.append(ILabel.class, result, (ILabel) binding); } } - return ArrayUtil.trim( ILabel.class, result ); + return ArrayUtil.trim(ILabel.class, result); } static private class FindLabelsAction extends ASTVisitor { - public IASTLabelStatement [] labels = null; + public IASTLabelStatement[] labels = null; - public FindLabelsAction(){ + public FindLabelsAction() { shouldVisitStatements = true; } @Override - public int visit( IASTStatement statement ) { - if( statement instanceof IASTLabelStatement ){ - labels = (IASTLabelStatement[]) ArrayUtil.append( IASTLabelStatement.class, labels, statement ); + public int visit(IASTStatement statement) { + if (statement instanceof IASTLabelStatement) { + labels = ArrayUtil.append(IASTLabelStatement.class, labels, (IASTLabelStatement) statement); } return PROCESS_CONTINUE; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java index 581d9ed3d22..04141c59240 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java @@ -112,7 +112,7 @@ public class CScope implements ICScope, IASTInternalScope { private IASTNode physicalNode = null; private boolean isCached = false; - private CharArrayObjectMap mapsToNameOrBinding[] = { CharArrayObjectMap.EMPTY_MAP, CharArrayObjectMap.EMPTY_MAP }; + private final CharArrayObjectMap mapsToNameOrBinding[] = { CharArrayObjectMap.EMPTY_MAP, CharArrayObjectMap.EMPTY_MAP }; private final EScopeKind kind; public CScope(IASTNode physical, EScopeKind eKind) { @@ -134,7 +134,7 @@ public class CScope implements ICScope, IASTInternalScope { } protected static class CollectNamesAction extends ASTVisitor { - private char[] name; + private final char[] name; private IASTName[] result = null; CollectNamesAction(char[] n) { @@ -376,7 +376,7 @@ public class CScope implements ICScope, IASTInternalScope { for (Object element : obj) { if (element instanceof IBinding) { - result = (IBinding[]) ArrayUtil.append(IBinding.class, result, element); + result = ArrayUtil.append(IBinding.class, result, (IBinding) element); } else { IASTName n= null; if (element instanceof IASTName) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java index a6f23ab423e..cbf9327dcfe 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java @@ -132,8 +132,8 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte @Override public IScope getScope() throws DOMException { - IASTDeclSpecifier declSpec = (IASTDeclSpecifier) ((definition != null) ? (IASTNode) definition - .getParent() : declarations[0].getParent()); + IASTDeclSpecifier declSpec = (IASTDeclSpecifier) ((definition != null) ? + (IASTNode) definition.getParent() : declarations[0].getParent()); IScope scope = CVisitor.getContainingScope(declSpec); while (scope instanceof ICCompositeTypeScope) { scope = scope.getParent(); @@ -149,8 +149,8 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray()) }; } ICASTCompositeTypeSpecifier compSpec = (ICASTCompositeTypeSpecifier) definition.getParent(); - IField[] fields = collectFields(compSpec, null); - return ArrayUtil.trim(IField.class, fields); + IField[] fields = collectFields(compSpec, IField.EMPTY_FIELD_ARRAY); + return ArrayUtil.trim(fields); } private IField[] collectFields(ICASTCompositeTypeSpecifier compSpec, IField[] fields) { @@ -171,7 +171,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte IASTName name = ASTQueries.findInnermostDeclarator(declarator).getName(); IBinding binding = name.resolveBinding(); if (binding != null) - fields = (IField[]) ArrayUtil.append(IField.class, fields, binding); + fields = ArrayUtil.append(fields, (IField) binding); } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariableReadWriteFlags.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariableReadWriteFlags.java index 67704164d75..36d4e63ccbd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariableReadWriteFlags.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariableReadWriteFlags.java @@ -28,7 +28,6 @@ import org.eclipse.cdt.internal.core.dom.parser.VariableReadWriteFlags; * with the variable. */ public final class CVariableReadWriteFlags extends VariableReadWriteFlags { - private static CVariableReadWriteFlags INSTANCE= new CVariableReadWriteFlags(); public static int getReadWriteFlags(IASTName variable) { @@ -73,15 +72,14 @@ public final class CVariableReadWriteFlags extends VariableReadWriteFlags { if (indirection == 0) { return READ; } - while(indirection > 0 && (type instanceof IPointerType)) { + while (indirection > 0 && (type instanceof IPointerType)) { type= ((IPointerType) type).getType(); indirection--; } if (indirection == 0) { if (type instanceof IQualifierType) { return ((IQualifierType) type).isConst() ? READ : READ | WRITE; - } - else if (type instanceof IPointerType) { + } else if (type instanceof IPointerType) { return ((IPointerType) type).isConst() ? READ : READ | WRITE; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java index 760aa746449..1147986b8d0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java @@ -91,7 +91,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS if (parameter != null) { parameter.setParent(this); parameter.setPropertyInParent(FUNCTION_PARAMETER); - parameters = (ICPPASTParameterDeclaration[]) ArrayUtil.append(ICPPASTParameterDeclaration.class, parameters, parameter); + parameters = ArrayUtil.append(ICPPASTParameterDeclaration.class, parameters, (ICPPASTParameterDeclaration) parameter); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java index b325b1a406a..7583bd9c98d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java @@ -288,22 +288,22 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope { IBinding binding = null; if (o instanceof ObjectSet) { ObjectSet set = (ObjectSet) o; - IBinding[] bs = null; + ICPPConstructor[] bs = ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY; for (int i = 0; i < set.size(); i++) { Object obj = set.keyAt(i); if (obj instanceof IASTName) { IASTName n = (IASTName) obj; binding = shouldResolve(forceResolve, n, forName) ? n.resolveBinding() : n.getBinding(); if (binding instanceof ICPPConstructor) { - bs = ArrayUtil.append(ICPPConstructor.class, bs, binding); + bs = ArrayUtil.append(bs, (ICPPConstructor) binding); } } else if (obj instanceof ICPPConstructor) { - bs = (IBinding[]) ArrayUtil.append(ICPPConstructor.class, bs, obj); + bs = ArrayUtil.append(bs, (ICPPConstructor) obj); } } - return (ICPPConstructor[]) ArrayUtil.trim(ICPPConstructor.class, bs); + return ArrayUtil.trim(ICPPConstructor.class, bs); } else if (o instanceof IASTName) { - if (shouldResolve(forceResolve, (IASTName) o, forName) || ((IASTName)o).getBinding() != null) { + if (shouldResolve(forceResolve, (IASTName) o, forName) || ((IASTName) o).getBinding() != null) { // always store the name, rather than the binding, such that we can properly flush the scope. nameMap.put(CONSTRUCTOR_KEY, o); binding = ((IASTName)o).resolveBinding(); @@ -409,11 +409,11 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope { * @see chapter 12 of the ISO specification */ class ImplicitsAnalysis { - private boolean hasUserDeclaredConstructor; + private final boolean hasUserDeclaredConstructor; private boolean hasUserDeclaredCopyConstructor; private boolean hasUserDeclaredCopyAssignmentOperator; - private boolean hasUserDeclaredDestructor; - private ICPPClassType classType; + private final boolean hasUserDeclaredDestructor; + private final ICPPClassType classType; ImplicitsAnalysis(ICPPASTCompositeTypeSpecifier compSpec, ICPPClassType clsType) { classType= clsType; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplatePartialSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplatePartialSpecialization.java index 600d625863b..ad8ca63cf42 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplatePartialSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplatePartialSpecialization.java @@ -33,17 +33,15 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; public class CPPClassTemplatePartialSpecialization extends CPPClassTemplate implements ICPPClassTemplatePartialSpecialization, ICPPSpecialization { - private ICPPTemplateArgument[] arguments; + private final ICPPTemplateArgument[] arguments; - public CPPClassTemplatePartialSpecialization(ICPPASTTemplateId name) { + public CPPClassTemplatePartialSpecialization(ICPPASTTemplateId name, ICPPTemplateArgument[] arguments) { super(name); + this.arguments= arguments; } @Override public ICPPTemplateArgument[] getTemplateArguments() throws DOMException { - if (arguments == null) { - arguments= CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) getTemplateName()); - } return arguments; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java index a9e1c000d37..452640243af 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java @@ -224,7 +224,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC for (ICPPASTTemplateParameter param : params) { p= CPPTemplates.getTemplateParameterName(param).resolveBinding(); if (p instanceof ICPPTemplateParameter) { - result = (ICPPTemplateParameter[]) ArrayUtil.append(ICPPTemplateParameter.class, result, p); + result = ArrayUtil.append(ICPPTemplateParameter.class, result, (ICPPTemplateParameter) p); } } templateParameters = ArrayUtil.trim(ICPPTemplateParameter.class, result); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java index 27a1f197756..67f62f5fe8b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java @@ -79,14 +79,14 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement if (templateParameters == null) { ICPPASTTemplatedTypeTemplateParameter template = (ICPPASTTemplatedTypeTemplateParameter) getPrimaryDeclaration().getParent(); ICPPASTTemplateParameter[] params = template.getTemplateParameters(); - ICPPTemplateParameter[] result = null; + ICPPTemplateParameter[] result = ICPPTemplateParameter.EMPTY_TEMPLATE_PARAMETER_ARRAY; for (ICPPASTTemplateParameter param : params) { IBinding binding = CPPTemplates.getTemplateParameterName(param).resolvePreBinding(); if (binding instanceof ICPPTemplateParameter) { - result = (ICPPTemplateParameter[]) ArrayUtil.append(ICPPTemplateParameter.class, result, binding); + result = ArrayUtil.append(result, (ICPPTemplateParameter) binding); } } - templateParameters = ArrayUtil.trim(ICPPTemplateParameter.class, result); + templateParameters = ArrayUtil.trim(result); } return templateParameters; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java index 84394d52ea8..9e864e324df 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java @@ -221,7 +221,7 @@ public class ClassTypeHelper { for (IASTDeclarator dtor : dtors) { binding = ASTQueries.findInnermostDeclarator(dtor).getName().resolveBinding(); if (binding instanceof ICPPField) - result = (ICPPField[]) ArrayUtil.append(ICPPField.class, result, binding); + result = ArrayUtil.append(ICPPField.class, result, (ICPPField) binding); } } else if (decl instanceof ICPPASTUsingDeclaration) { IASTName n = ((ICPPASTUsingDeclaration)decl).getName(); @@ -230,10 +230,10 @@ public class ClassTypeHelper { IBinding[] bs = ((ICPPUsingDeclaration)binding).getDelegates(); for (IBinding element : bs) { if (element instanceof ICPPField) - result = (ICPPField[]) ArrayUtil.append(ICPPField.class, result, element); + result = ArrayUtil.append(ICPPField.class, result, (ICPPField) element); } } else if (binding instanceof ICPPField) { - result = (ICPPField[]) ArrayUtil.append(ICPPField.class, result, binding); + result = ArrayUtil.append(ICPPField.class, result, (ICPPField) binding); } } } @@ -349,7 +349,7 @@ public class ClassTypeHelper { for (IASTDeclarator dtor : dtors) { binding = ASTQueries.findInnermostDeclarator(dtor).getName().resolveBinding(); if (binding instanceof ICPPMethod) - result = (ICPPMethod[]) ArrayUtil.append(ICPPMethod.class, result, binding); + result = ArrayUtil.append(ICPPMethod.class, result, (ICPPMethod) binding); } } } else if (decl instanceof IASTFunctionDefinition) { @@ -359,7 +359,7 @@ public class ClassTypeHelper { dtor = ASTQueries.findInnermostDeclarator(dtor); binding = dtor.getName().resolveBinding(); if (binding instanceof ICPPMethod) { - result = (ICPPMethod[]) ArrayUtil.append(ICPPMethod.class, result, binding); + result = ArrayUtil.append(ICPPMethod.class, result, (ICPPMethod) binding); } } } else if (decl instanceof ICPPASTUsingDeclaration) { @@ -369,10 +369,10 @@ public class ClassTypeHelper { IBinding[] bs = ((ICPPUsingDeclaration)binding).getDelegates(); for (IBinding element : bs) { if (element instanceof ICPPMethod) - result = (ICPPMethod[]) ArrayUtil.append(ICPPMethod.class, result, element); + result = ArrayUtil.append(ICPPMethod.class, result, (ICPPMethod) element); } } else if (binding instanceof ICPPMethod) { - result = (ICPPMethod[]) ArrayUtil.append(ICPPMethod.class, result, binding); + result = ArrayUtil.append(ICPPMethod.class, result, (ICPPMethod) binding); } } } @@ -418,7 +418,7 @@ public class ClassTypeHelper { binding = ((ICPPASTElaboratedTypeSpecifier)declSpec).getName().resolveBinding(); } if (binding instanceof ICPPClassType) - result = (ICPPClassType[])ArrayUtil.append(ICPPClassType.class, result, binding); + result = ArrayUtil.append(ICPPClassType.class, result, (ICPPClassType) binding); } } return ArrayUtil.trim(ICPPClassType.class, result); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index 761b47cb16e..a43ea8824ea 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -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; @@ -1782,10 +1792,11 @@ public class CPPSemantics { IBinding[] result = null; for (Object binding : bindings) { - if (binding instanceof IASTName) + if (binding instanceof IASTName) { result = ArrayUtil.append(IBinding.class, result, ((IASTName) binding).resolveBinding()); - else if (binding instanceof IBinding) - result = (IBinding[]) ArrayUtil.append(IBinding.class, result, binding); + } else if (binding instanceof IBinding) { + result = ArrayUtil.append(IBinding.class, result, (IBinding) binding); + } } return new CPPCompositeBinding(result); } @@ -2019,13 +2030,13 @@ public class CPPSemantics { } } - IBinding[] bindings = null; + IBinding[] bindings = IBinding.EMPTY_BINDING_ARRAY; if (cmp > 0) { - bindings = ArrayUtil.append(IBinding.class, bindings, obj); - bindings = ArrayUtil.append(IBinding.class, bindings, type); + bindings = ArrayUtil.append(bindings, obj); + bindings = ArrayUtil.append(bindings, type); } else { - bindings = ArrayUtil.append(IBinding.class, bindings, type); - bindings = (IBinding[]) ArrayUtil.addAll(IBinding.class, bindings, fns.keyArray()); + bindings = ArrayUtil.append(bindings, type); + bindings = ArrayUtil.addAll(bindings, fns.keyArray()); } bindings = ArrayUtil.trim(IBinding.class, bindings); ICPPUsingDeclaration composite = new CPPUsingDeclaration(data.astName, bindings); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index c46a0b1e620..eb17e322247 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -531,7 +531,7 @@ public class CPPTemplates { while (parent.getParent() instanceof ICPPASTTemplateDeclaration) { parent = parent.getParent(); - templates = (ICPPASTTemplateDeclaration[]) ArrayUtil.append(ICPPASTTemplateDeclaration.class, templates, parent); + templates = ArrayUtil.append(ICPPASTTemplateDeclaration.class, templates, (ICPPASTTemplateDeclaration) parent); } templates = ArrayUtil.trim(ICPPASTTemplateDeclaration.class, templates); @@ -677,10 +677,14 @@ public class CPPTemplates { if (argsAreTrivial(classTemplate.getTemplateParameters(), args)) { result= classTemplate; } else { + args= addDefaultArguments(classTemplate, args); + if (args == null) { + return new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, templateName.toCharArray()); + } ICPPClassTemplatePartialSpecialization partialSpec= findPartialSpecialization(classTemplate, args); if (isDeclaration || isDefinition) { if (partialSpec == null) { - partialSpec = new CPPClassTemplatePartialSpecialization(id); + partialSpec = new CPPClassTemplatePartialSpecialization(id, args); if (template instanceof ICPPInternalClassTemplate) ((ICPPInternalClassTemplate) template).addPartialSpecialization(partialSpec); return partialSpec; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVariableReadWriteFlags.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVariableReadWriteFlags.java index 89862e99f52..d8d9464f7dc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVariableReadWriteFlags.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVariableReadWriteFlags.java @@ -35,7 +35,6 @@ import org.eclipse.cdt.internal.core.dom.parser.VariableReadWriteFlags; * with the variable. */ public final class CPPVariableReadWriteFlags extends VariableReadWriteFlags { - private static CPPVariableReadWriteFlags INSTANCE= new CPPVariableReadWriteFlags(); public static int getReadWriteFlags(IASTName variable) { @@ -109,8 +108,7 @@ public final class CPPVariableReadWriteFlags extends VariableReadWriteFlags { if (indirection == 0) { if (type instanceof IQualifierType) { return ((IQualifierType) type).isConst() ? READ : READ | WRITE; - } - else if (type instanceof IPointerType) { + } else if (type instanceof IPointerType) { return ((IPointerType) type).isConst() ? READ : READ | WRITE; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java index f8229c7fbe0..6fbb424e8c6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java @@ -13,7 +13,11 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; -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.CVTYPE; +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.getNestedType; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateTypeUptoPointers; import java.util.ArrayList; import java.util.Collections; @@ -209,6 +213,7 @@ public class CPPVisitor extends ASTQueries { private static final char[] PTRDIFF_T = "ptrdiff_t".toCharArray(); //$NON-NLS-1$ private static final char[] TYPE_INFO= "type_info".toCharArray(); //$NON-NLS-1$ private static final char[] INITIALIZER_LIST = "initializer_list".toCharArray(); //$NON-NLS-1$ + private static final char[][] EMPTY_CHAR_ARRAY_ARRAY = {}; public static final IASTInitializerClause[] NO_ARGS = {}; // Thread-local set of DeclSpecifiers for which auto types are being created. @@ -2301,7 +2306,8 @@ public class CPPVisitor extends ASTQueries { } public static char[][] getQualifiedNameCharArray(IBinding binding) { - char[][] ns = null; + char[][] ns = EMPTY_CHAR_ARRAY_ARRAY; + ns = ArrayUtil.append(ns, binding.getNameCharArray()); for (IBinding owner= binding.getOwner(); owner != null; owner= owner.getOwner()) { char[] n= owner.getNameCharArray(); if (n == null) @@ -2311,16 +2317,11 @@ public class CPPVisitor extends ASTQueries { if (owner instanceof ICPPNamespace && n.length == 0) continue; - ns = ArrayUtil.append(n.getClass(), ns, n); + ns = ArrayUtil.append(ns, n); } - final char[] bname = binding.getNameCharArray(); - ns = ArrayUtil.trim(bname.getClass(), ns); - char[][] result = new char[ns.length + 1][]; - for (int i = ns.length - 1; i >= 0; i--) { - result[ns.length - i - 1] = ns[i]; - } - result[ns.length]= bname; - return result; + ns = ArrayUtil.trim(ns); + ArrayUtil.reverse(ns); + return ns; } private static IScope getParentScope(IScope scope, IASTTranslationUnit unit) throws DOMException { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommenter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommenter.java index 8938c60ff23..ec0d9f9afc8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommenter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommenter.java @@ -12,7 +12,8 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.commenthandler; -import java.util.Vector; +import java.util.ArrayList; +import java.util.List; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTComment; @@ -63,13 +64,13 @@ public class NodeCommenter { protected ASTVisitor visitor; protected CommentHandler commHandler; protected NodeCommentMap commentMap; - protected Vector children; + protected List children; public NodeCommenter(ASTVisitor visitor, CommentHandler commHandler, NodeCommentMap commentMap) { this.visitor = visitor; this.commHandler = commHandler; this.commentMap = commentMap; - this.children = new Vector(); + this.children = new ArrayList(); } protected void writeNodeList(IASTNode[] nodes) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplate.java index 455ea46095d..e29c56407da 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplate.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial implementation - * Markus Schorn (Wind River Systems) + * Andrew Ferguson (Symbian) - Initial implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite.cpp; @@ -50,10 +50,9 @@ public class CompositeCPPClassTemplate extends CompositeCPPClassType System.arraycopy(ss, 0, preresult[i], 0, ss.length); } - return (ICPPClassTemplatePartialSpecialization[]) ArrayUtil.addAll( - ICPPClassTemplatePartialSpecialization.class, - ICPPClassTemplatePartialSpecialization.EMPTY_PARTIAL_SPECIALIZATION_ARRAY, cf - .getCompositeBindings(preresult)); + return ArrayUtil.addAll( + ICPPClassTemplatePartialSpecialization.EMPTY_PARTIAL_SPECIALIZATION_ARRAY, + cf.getCompositeBindings(preresult)); } catch (CoreException ce) { CCorePlugin.log(ce); return ICPPClassTemplatePartialSpecialization.EMPTY_PARTIAL_SPECIALIZATION_ARRAY; @@ -97,5 +96,4 @@ public class CompositeCPPClassTemplate extends CompositeCPPClassType ICPPTemplateArgument[] args = CPPTemplates.templateParametersAsArguments(getTemplateParameters()); return new CPPDeferredClassInstance(this, args, getCompositeScope()); } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexerInputAdapter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexerInputAdapter.java index 3dcc9c10df4..fc22a1ce3ba 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexerInputAdapter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexerInputAdapter.java @@ -22,6 +22,7 @@ import org.eclipse.cdt.core.parser.FileContent; import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.internal.core.index.IndexFileLocation; import org.eclipse.cdt.internal.core.parser.InternalParserUtil; +import org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask.UnusedHeaderStrategy; import org.eclipse.cdt.internal.core.pdom.IndexerInputAdapter; import org.eclipse.cdt.internal.core.pdom.indexer.FileExistsCache; import org.eclipse.cdt.utils.UNCPathConverter; @@ -178,7 +179,7 @@ public class StandaloneIndexerInputAdapter extends IndexerInputAdapter { } @Override - public AbstractLanguage[] getLanguages(Object tu, boolean bothForHeaders) { + public AbstractLanguage[] getLanguages(Object tu, UnusedHeaderStrategy strat) { ILanguage language = fIndexer.getLanguageMapper().getLanguage(tu.toString()); if (language instanceof AbstractLanguage) { return new AbstractLanguage[] {(AbstractLanguage) language}; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ASTPreprocessorNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ASTPreprocessorNode.java index 555666df72b..d438bd47cac 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ASTPreprocessorNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ASTPreprocessorNode.java @@ -105,21 +105,35 @@ abstract class ASTPreprocessorNode extends ASTNode { @Override public String toString() { - return String.valueOf(getSource(getOffset(), getLength())); + return String.valueOf(getRawSignatureChars()); } } - class ASTComment extends ASTPreprocessorNode implements IASTComment { private final boolean fIsBlockComment; - public ASTComment(IASTTranslationUnit parent, int startNumber, int endNumber, boolean isBlockComment) { - super(parent, IASTTranslationUnit.PREPROCESSOR_STATEMENT, startNumber, endNumber); + private String fFilePath; + public ASTComment(IASTTranslationUnit parent, String filePath, int offset, int endOffset, boolean isBlockComment) { + super(parent, IASTTranslationUnit.PREPROCESSOR_STATEMENT, offset, endOffset); fIsBlockComment= isBlockComment; + fFilePath= filePath; } + @Override + public int getOffset() { + if (fFilePath != null) { + // Perform lazy conversion to sequence number + ILocationResolver lr= (ILocationResolver) getTranslationUnit().getAdapter(ILocationResolver.class); + if (lr != null) { + setOffset(lr.getSequenceNumberForFileOffset(fFilePath, super.getOffset())); + fFilePath= null; + } + } + return super.getOffset(); + } + @Override public char[] getComment() { - return getSource(getOffset(), getLength()); + return getRawSignatureChars(); } @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationMap.java index 0e6fab5dcb3..e797ca97f7c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationMap.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationMap.java @@ -245,9 +245,7 @@ public class LocationMap implements ILocationResolver { } public void encounteredComment(int offset, int endOffset, boolean isBlockComment) { - offset= getSequenceNumberForOffset(offset); - endOffset= getSequenceNumberForOffset(endOffset); - fComments.add(new ASTComment(fTranslationUnit, offset, endOffset, isBlockComment)); + fComments.add(new ASTComment(fTranslationUnit, getCurrentFilePath(), offset, endOffset, isBlockComment)); } public void encounterProblem(int id, char[] arg, int offset, int endOffset) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java index ffc4d33176f..2f68dfe2484 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java @@ -71,12 +71,12 @@ import org.eclipse.osgi.util.NLS; * @since 5.0 */ public abstract class AbstractIndexerTask extends PDOMWriter { - protected static enum UnusedHeaderStrategy { - skip, useDefaultLanguage, useAlternateLanguage, useBoth + public static enum UnusedHeaderStrategy { + skip, useC, useCPP, useDefaultLanguage, useBoth } private static final int MAX_ERRORS = 500; - private static enum UpdateKind {REQUIRED_SOURCE, REQUIRED_HEADER, OTHER_HEADER} + private static enum UpdateKind {REQUIRED_SOURCE, REQUIRED_HEADER, ONE_LINKAGE_HEADER, OTHER_HEADER} private static class LinkageTask { final int fLinkageID; private final Map fLocationTasks; @@ -87,13 +87,19 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } boolean requestUpdate(IIndexFileLocation ifl, IIndexFragmentFile ifile, Object tu, - UpdateKind kind) { + UpdateKind kind, Map oneLinkageTasks) { LocationTask locTask= fLocationTasks.get(ifl); if (locTask == null) { locTask= new LocationTask(); fLocationTasks.put(ifl, locTask); } - return locTask.requestUpdate(ifile, tu, kind); + boolean result = locTask.requestUpdate(ifile, tu, kind); + + // Store one-linkage tasks. + if (kind == UpdateKind.ONE_LINKAGE_HEADER && locTask.fVersionTasks.isEmpty()) + oneLinkageTasks.put(ifl, locTask); + + return result; } LocationTask find(IIndexFileLocation ifl) { @@ -282,6 +288,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { private List fRequestsPerLinkage= new ArrayList(); private Map fIndexContentCache= new LRUCache(500); private Map fIndexFilesCache= new LRUCache(5000); + private Map fOneLinkageTasks= new HashMap(); private Object[] fFilesToUpdate; private List fFilesToRemove = new ArrayList(); @@ -386,6 +393,8 @@ public abstract class AbstractIndexerTask extends PDOMWriter { * @return array of linkage IDs that shall be parsed */ protected int[] getLinkagesToParse() { + if (fIndexHeadersWithoutContext == UnusedHeaderStrategy.useCPP) + return PDOMManager.IDS_FOR_LINKAGES_TO_INDEX_C_FIRST; return PDOMManager.IDS_FOR_LINKAGES_TO_INDEX; } @@ -494,6 +503,11 @@ public abstract class AbstractIndexerTask extends PDOMWriter { final List filesForLinkage = files.get(linkageID); if (filesForLinkage != null) { parseLinkage(linkageID, filesForLinkage, monitor); + for (Iterator it = fOneLinkageTasks.values().iterator(); it.hasNext();) { + LocationTask task = it.next(); + if (task.isCompleted()) + it.remove(); + } fIndexContentCache.clear(); fIndexFilesCache.clear(); } @@ -569,7 +583,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { final boolean forceAll= (fUpdateFlags & IIndexManager.UPDATE_ALL) != 0; final boolean checkTimestamps= (fUpdateFlags & IIndexManager.UPDATE_CHECK_TIMESTAMPS) != 0; final boolean checkFileContentsHash = (fUpdateFlags & IIndexManager.UPDATE_CHECK_CONTENTS_HASH) != 0; - + final boolean both = fIndexHeadersWithoutContext == UnusedHeaderStrategy.useBoth; int count= 0; int forceFirst= fForceNumberFiles; BitSet linkages= new BitSet(); @@ -585,28 +599,33 @@ public abstract class AbstractIndexerTask extends PDOMWriter { final IIndexFragmentFile[] indexFiles= fIndex.getWritableFiles(ifl); final boolean isSourceUnit= fResolver.isSourceUnit(tu); linkages.clear(); - if (isRequiredInIndex(tu, ifl, isSourceUnit)) { + final boolean regularContent = isRequiredInIndex(tu, ifl, isSourceUnit); + final boolean indexedUnconditionally = fResolver.isIndexedUnconditionally(ifl); + if (regularContent || indexedUnconditionally) { // Headers or sources required with a specific linkage - final UpdateKind updateKind = isSourceUnit ? UpdateKind.REQUIRED_SOURCE : UpdateKind.REQUIRED_HEADER; - AbstractLanguage[] langs= fResolver.getLanguages(tu, fIndexHeadersWithoutContext == UnusedHeaderStrategy.useBoth); - for (AbstractLanguage lang : langs) { - int linkageID = lang.getLinkageID(); - boolean foundInLinkage = false; - for (int i = 0; i < indexFiles.length; i++) { - IIndexFragmentFile ifile = indexFiles[i]; - if (ifile != null && ifile.getLinkageID() == linkageID && ifile.hasContent()) { - foundInLinkage = true; - indexFiles[i]= null; // Take the file. - boolean update= force || isModified(checkTimestamps, checkFileContentsHash, ifl, tu, ifile); - if (update && requestUpdate(linkageID, ifl, ifile, tu, updateKind)) { - count++; - linkages.set(linkageID); + final UpdateKind updateKind = isSourceUnit ? UpdateKind.REQUIRED_SOURCE + : regularContent && both ? UpdateKind.REQUIRED_HEADER : UpdateKind.ONE_LINKAGE_HEADER; + if (regularContent || indexFiles.length == 0) { + AbstractLanguage[] langs= fResolver.getLanguages(tu, fIndexHeadersWithoutContext); + for (AbstractLanguage lang : langs) { + int linkageID = lang.getLinkageID(); + boolean foundInLinkage = false; + for (int i = 0; i < indexFiles.length; i++) { + IIndexFragmentFile ifile = indexFiles[i]; + if (ifile != null && ifile.getLinkageID() == linkageID && ifile.hasContent()) { + foundInLinkage = true; + indexFiles[i]= null; // Take the file. + boolean update= force || isModified(checkTimestamps, checkFileContentsHash, ifl, tu, ifile); + if (update && requestUpdate(linkageID, ifl, ifile, tu, updateKind)) { + count++; + linkages.set(linkageID); + } } } - } - if (!foundInLinkage && requestUpdate(linkageID, ifl, null, tu, updateKind)) { - linkages.set(linkageID); - count++; + if (!foundInLinkage && requestUpdate(linkageID, ifl, null, tu, updateKind)) { + linkages.set(linkageID); + count++; + } } } } @@ -615,7 +634,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { for (IIndexFragmentFile ifile : indexFiles) { if (ifile != null) { IIndexInclude ctx= ifile.getParsedInContext(); - if (ctx == null && !fResolver.isIndexedUnconditionally(ifile.getLocation())) { + if (ctx == null && !indexedUnconditionally) { iFilesToRemove.add(ifile); count++; } else { @@ -656,10 +675,6 @@ public abstract class AbstractIndexerTask extends PDOMWriter { if (fIndexHeadersWithoutContext != UnusedHeaderStrategy.skip) return true; - // File required because it is open in the editor. - if (fResolver.isIndexedUnconditionally(ifl)) - return true; - // Source file if (isSourceUnit) { if (fIndexFilesWithoutConfiguration || fResolver.isFileBuildConfigured(tu)) @@ -689,7 +704,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { private boolean requestUpdate(int linkageID, IIndexFileLocation ifl, IIndexFragmentFile ifile, Object tu, UpdateKind kind) { LinkageTask fileMap= createRequestMap(linkageID); - return fileMap.requestUpdate(ifl, ifile, tu, kind); + return fileMap.requestUpdate(ifl, ifile, tu, kind, fOneLinkageTasks); } private LinkageTask createRequestMap(int linkageID) { @@ -712,11 +727,13 @@ public abstract class AbstractIndexerTask extends PDOMWriter { @Override protected void reportFileWrittenToIndex(FileInAST file, IIndexFragmentFile ifile) throws CoreException { final FileContentKey fck = file.fFileContentKey; + final IIndexFileLocation location = fck.getLocation(); boolean wasCounted= false; UpdateKind kind= UpdateKind.OTHER_HEADER; LinkageTask map = findRequestMap(fck.getLinkageID()); + LocationTask locTask= null; if (map != null) { - LocationTask locTask = map.find(fck.getLocation()); + locTask = map.find(location); if (locTask != null) { kind= locTask.fKind; FileVersionTask v = locTask.findVersion(ifile); @@ -733,6 +750,21 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } fIndexContentCache.remove(ifile); fIndexFilesCache.remove(file.fFileContentKey.getLocation()); + + LocationTask task= fOneLinkageTasks.remove(location); + if (task != null && task != locTask) { + if (task.fKind == UpdateKind.ONE_LINKAGE_HEADER && !task.isCompleted()) { + task.fKind= UpdateKind.OTHER_HEADER; + if (task.isCompleted()) { + if (!wasCounted) { + kind= UpdateKind.ONE_LINKAGE_HEADER; + wasCounted= true; + } else { + reportFile(wasCounted, UpdateKind.ONE_LINKAGE_HEADER); + } + } + } + } reportFile(wasCounted, kind); } @@ -989,7 +1021,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } private AbstractLanguage getLanguage(Object tu, int linkageID) { - for (AbstractLanguage language : fResolver.getLanguages(tu, true)) { + for (AbstractLanguage language : fResolver.getLanguages(tu, UnusedHeaderStrategy.useBoth)) { if (language.getLinkageID() == linkageID) { return language; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/IndexerInputAdapter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/IndexerInputAdapter.java index 26efb9e36b3..7d02e96c2e5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/IndexerInputAdapter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/IndexerInputAdapter.java @@ -71,7 +71,7 @@ public abstract class IndexerInputAdapter extends ASTFilePathResolver { /** * Obtains the languages the input file should be parsed with. */ - public abstract AbstractLanguage[] getLanguages(Object tu, boolean bothForHeaders); + public abstract AbstractLanguage[] getLanguages(Object tu, AbstractIndexerTask.UnusedHeaderStrategy strat); /** * Obtains the scanner configuration for the input file. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java index 782173d66ef..478e4cf5b12 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java @@ -137,6 +137,9 @@ public class PDOMManager implements IWritableIndexManager, IListener { public static final int[] IDS_FOR_LINKAGES_TO_INDEX = { ILinkage.CPP_LINKAGE_ID, ILinkage.C_LINKAGE_ID, ILinkage.FORTRAN_LINKAGE_ID }; + public static final int[] IDS_FOR_LINKAGES_TO_INDEX_C_FIRST = { + ILinkage.C_LINKAGE_ID, ILinkage.CPP_LINKAGE_ID, ILinkage.FORTRAN_LINKAGE_ID + }; private final LinkedList fProjectQueue= new LinkedList(); private final PDOMSetupJob fSetupJob; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java index bce49fd1f0c..10b51fc78c9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java @@ -24,6 +24,7 @@ import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.internal.core.index.IWritableIndex; import org.eclipse.cdt.internal.core.index.IWritableIndexManager; +import org.eclipse.cdt.internal.core.model.CProject; import org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask; import org.eclipse.cdt.internal.core.pdom.ITodoTaskUpdater; import org.eclipse.cdt.internal.core.pdom.IndexerProgress; @@ -80,10 +81,11 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD boolean i1= checkProperty(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG); boolean i2= checkProperty(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG); UnusedHeaderStrategy strategy; - if (i1) { - strategy= i2 ? UnusedHeaderStrategy.useBoth : UnusedHeaderStrategy.useDefaultLanguage; + if (i1 == i2) { + strategy = i1 ? UnusedHeaderStrategy.useBoth : UnusedHeaderStrategy.skip; } else { - strategy= i2 ? UnusedHeaderStrategy.useAlternateLanguage: UnusedHeaderStrategy.skip; + strategy = i1 == CProject.hasCCNature(getProject().getProject()) + ? UnusedHeaderStrategy.useCPP : UnusedHeaderStrategy.useC; } setIndexHeadersWithoutContext(strategy); } else { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/ProjectIndexerInputAdapter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/ProjectIndexerInputAdapter.java index 85a503c9141..c82b1a90df8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/ProjectIndexerInputAdapter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/ProjectIndexerInputAdapter.java @@ -30,6 +30,7 @@ import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.internal.core.CCoreInternals; import org.eclipse.cdt.internal.core.parser.InternalParserUtil; +import org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask.UnusedHeaderStrategy; import org.eclipse.cdt.internal.core.pdom.IndexerInputAdapter; import org.eclipse.cdt.internal.core.resources.PathCanonicalizationStrategy; import org.eclipse.cdt.utils.UNCPathConverter; @@ -193,7 +194,7 @@ public class ProjectIndexerInputAdapter extends IndexerInputAdapter { } @Override - public AbstractLanguage[] getLanguages(Object tuo, boolean bothForHeaders) { + public AbstractLanguage[] getLanguages(Object tuo, UnusedHeaderStrategy strategy) { if (tuo instanceof PotentialTranslationUnit) { if (fLangC != null) { if (fLangCpp != null) { @@ -211,14 +212,23 @@ public class ProjectIndexerInputAdapter extends IndexerInputAdapter { try { ILanguage lang= tu.getLanguage(); if (lang instanceof AbstractLanguage) { - if (bothForHeaders && tu.isHeaderUnit()) { + final boolean both = strategy == UnusedHeaderStrategy.useBoth; + final boolean useC = strategy == UnusedHeaderStrategy.useC; + final boolean useCpp = strategy == UnusedHeaderStrategy.useCPP; + if ((both || useC || useCpp) && tu.isHeaderUnit()) { String filename= tu.getElementName(); if (filename.indexOf('.') >= 0) { final String contentTypeId= tu.getContentTypeId(); if (contentTypeId.equals(CCorePlugin.CONTENT_TYPE_CXXHEADER) && fLangC != null) { - return new AbstractLanguage[] {(AbstractLanguage) lang, fLangC}; + if (both) + return new AbstractLanguage[] {(AbstractLanguage) lang, fLangC}; + if (useC) + return new AbstractLanguage[] {fLangC}; } else if (contentTypeId.equals(CCorePlugin.CONTENT_TYPE_CHEADER) && fLangCpp != null) { - return new AbstractLanguage[] {(AbstractLanguage) lang, fLangCpp}; + if (both) + return new AbstractLanguage[] {(AbstractLanguage) lang, fLangCpp}; + if (useCpp) + return new AbstractLanguage[] {fLangCpp}; } } } diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/CPPPopulateASTViewAction.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/CPPPopulateASTViewAction.java index a97f0b189cf..84b76b6bc6d 100644 --- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/CPPPopulateASTViewAction.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/CPPPopulateASTViewAction.java @@ -93,9 +93,9 @@ public class CPPPopulateASTViewAction extends ASTGenericVisitor implements IPopu tree.setFiltersFlag(DOMASTNodeLeaf.FLAG_PROBLEM); if (node instanceof IASTProblemHolder) - astProblems = ArrayUtil.append(IASTProblem.class, astProblems, ((IASTProblemHolder)node).getProblem()); + astProblems = ArrayUtil.append(IASTProblem.class, astProblems, ((IASTProblemHolder) node).getProblem()); else - astProblems = (IASTProblem[])ArrayUtil.append(IASTProblem.class, astProblems, node); + astProblems = ArrayUtil.append(IASTProblem.class, astProblems, (IASTProblem) node); } if (node instanceof IASTPreprocessorStatement) tree.setFiltersFlag(DOMASTNodeLeaf.FLAG_PREPROCESSOR); diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/CPopulateASTViewAction.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/CPopulateASTViewAction.java index 00fa52f8828..d125bbdc7d3 100644 --- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/CPopulateASTViewAction.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/CPopulateASTViewAction.java @@ -117,9 +117,9 @@ public class CPopulateASTViewAction extends ASTVisitor implements IPopulateDOMAS tree.setFiltersFlag(DOMASTNodeLeaf.FLAG_PROBLEM); if (node instanceof IASTProblemHolder) - astProblems = ArrayUtil.append(IASTProblem.class, astProblems, ((IASTProblemHolder)node).getProblem()); + astProblems = ArrayUtil.append(IASTProblem.class, astProblems, ((IASTProblemHolder) node).getProblem()); else - astProblems = (IASTProblem[])ArrayUtil.append(IASTProblem.class, astProblems, node); + astProblems = ArrayUtil.append(IASTProblem.class, astProblems, (IASTProblem) node); } if (node instanceof IASTPreprocessorStatement) tree.setFiltersFlag(DOMASTNodeLeaf.FLAG_PREPROCESSOR); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/BasicSearchTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/BasicSearchTest.java index 0eef8ff3784..1502948a487 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/BasicSearchTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/BasicSearchTest.java @@ -51,10 +51,10 @@ import org.eclipse.cdt.core.testplugin.util.TestSourceReader; import org.eclipse.cdt.ui.testplugin.CTestPlugin; import org.eclipse.cdt.ui.tests.BaseUITestCase; -import org.eclipse.cdt.internal.ui.search.PDOMSearchPatternQuery; -import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery; -import org.eclipse.cdt.internal.ui.search.PDOMSearchResult; -import org.eclipse.cdt.internal.ui.search.PDOMSearchViewPage; +import org.eclipse.cdt.internal.ui.search.CSearchPatternQuery; +import org.eclipse.cdt.internal.ui.search.CSearchQuery; +import org.eclipse.cdt.internal.ui.search.CSearchResult; +import org.eclipse.cdt.internal.ui.search.CSearchViewPage; public class BasicSearchTest extends BaseUITestCase { ICProject fCProject; @@ -109,15 +109,15 @@ public class BasicSearchTest extends BaseUITestCase { assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor())); // open a query - PDOMSearchQuery query= makeProjectQuery("foo"); - PDOMSearchResult result= runQuery(query); + CSearchQuery query= makeProjectQuery("foo"); + CSearchResult result= runQuery(query); assertEquals(2, result.getElements().length); ISearchResultViewPart vp= NewSearchUI.getSearchResultView(); ISearchResultPage page= vp.getActivePage(); - assertTrue(""+page, page instanceof PDOMSearchViewPage); + assertTrue(""+page, page instanceof CSearchViewPage); - PDOMSearchViewPage pdomsvp= (PDOMSearchViewPage) page; + CSearchViewPage pdomsvp= (CSearchViewPage) page; StructuredViewer viewer= pdomsvp.getViewer(); ILabelProvider labpv= (ILabelProvider) viewer.getLabelProvider(); IStructuredContentProvider scp= (IStructuredContentProvider) viewer.getContentProvider(); @@ -152,15 +152,15 @@ public class BasicSearchTest extends BaseUITestCase { assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor())); // open a query - PDOMSearchQuery query= makeProjectQuery("x"); - PDOMSearchResult result= runQuery(query); + CSearchQuery query= makeProjectQuery("x"); + CSearchResult result= runQuery(query); assertEquals(0, result.getElements().length); ISearchResultViewPart vp= NewSearchUI.getSearchResultView(); ISearchResultPage page= vp.getActivePage(); - assertTrue("" + page, page instanceof PDOMSearchViewPage); + assertTrue("" + page, page instanceof CSearchViewPage); - PDOMSearchViewPage pdomsvp= (PDOMSearchViewPage) page; + CSearchViewPage pdomsvp= (CSearchViewPage) page; StructuredViewer viewer= pdomsvp.getViewer(); ILabelProvider labpv= (ILabelProvider) viewer.getLabelProvider(); IStructuredContentProvider scp= (IStructuredContentProvider) viewer.getContentProvider(); @@ -229,8 +229,8 @@ public class BasicSearchTest extends BaseUITestCase { */ private void coreTestIndexerInProgress(boolean expectComplete) { // open a query - PDOMSearchQuery query= makeProjectQuery("data*"); - PDOMSearchResult result= runQuery(query); + CSearchQuery query= makeProjectQuery("data*"); + CSearchResult result= runQuery(query); final int maximumHits = INDEXER_IN_PROGRESS_FILE_COUNT * INDEXER_IN_PROGRESS_STRUCT_COUNT; Object[] elements = result.getElements(); @@ -241,9 +241,9 @@ public class BasicSearchTest extends BaseUITestCase { ISearchResultViewPart vp= NewSearchUI.getSearchResultView(); ISearchResultPage page= vp.getActivePage(); - assertTrue(""+page, page instanceof PDOMSearchViewPage); + assertTrue(""+page, page instanceof CSearchViewPage); - PDOMSearchViewPage pdomsvp= (PDOMSearchViewPage) page; + CSearchViewPage pdomsvp= (CSearchViewPage) page; StructuredViewer viewer= pdomsvp.getViewer(); ILabelProvider labpv= (ILabelProvider) viewer.getLabelProvider(); IStructuredContentProvider scp= (IStructuredContentProvider) viewer.getContentProvider(); @@ -281,7 +281,7 @@ public class BasicSearchTest extends BaseUITestCase { * @param query * @return */ - protected PDOMSearchResult runQuery(PDOMSearchQuery query) { + protected CSearchResult runQuery(CSearchQuery query) { final ISearchResult result[]= new ISearchResult[1]; IQueryListener listener= new IQueryListener() { @Override @@ -304,9 +304,9 @@ public class BasicSearchTest extends BaseUITestCase { runnable.run(npm()); } }, query); - assertTrue(result[0] instanceof PDOMSearchResult); + assertTrue(result[0] instanceof CSearchResult); runEventQueue(500); - return (PDOMSearchResult) result[0]; + return (CSearchResult) result[0]; } // void foo() {} @@ -315,7 +315,7 @@ public class BasicSearchTest extends BaseUITestCase { // foo(); // } public void testNewResultsOnSearchAgainA() throws Exception { - PDOMSearchQuery query= makeProjectQuery("foo"); + CSearchQuery query= makeProjectQuery("foo"); assertOccurrences(query, 2); assertOccurrences(query, 2); @@ -332,7 +332,7 @@ public class BasicSearchTest extends BaseUITestCase { // void bar() {foo();foo();foo();} public void testNewResultsOnSearchAgainB() throws Exception { - PDOMSearchQuery query= makeProjectQuery("foo"); + CSearchQuery query= makeProjectQuery("foo"); assertOccurrences(query, 4); assertOccurrences(query, 4); @@ -355,14 +355,14 @@ public class BasicSearchTest extends BaseUITestCase { assertOccurrences(query, 3); } - private PDOMSearchQuery makeProjectQuery(String pattern) { + private CSearchQuery makeProjectQuery(String pattern) { String scope1= "Human Readable Description"; - return new PDOMSearchPatternQuery(new ICElement[] {fCProject}, scope1, pattern, true, PDOMSearchQuery.FIND_ALL_OCCURRENCES | PDOMSearchPatternQuery.FIND_ALL_TYPES); + return new CSearchPatternQuery(new ICElement[] {fCProject}, scope1, pattern, true, CSearchQuery.FIND_ALL_OCCURRENCES | CSearchPatternQuery.FIND_ALL_TYPES); } - private void assertOccurrences(PDOMSearchQuery query, int expected) { + private void assertOccurrences(CSearchQuery query, int expected) { query.run(npm()); - PDOMSearchResult result= (PDOMSearchResult) query.getSearchResult(); + CSearchResult result= (CSearchResult) query.getSearchResult(); assertEquals(expected, result.getMatchCount()); } @@ -383,7 +383,7 @@ public class BasicSearchTest extends BaseUITestCase { // f(&a); // } public void testSearchAndTemplateIDs() throws Exception { - PDOMSearchQuery query= makeProjectQuery("CT"); + CSearchQuery query= makeProjectQuery("CT"); assertOccurrences(query, 5); query= makeProjectQuery("f"); assertOccurrences(query, 6); diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index 0ac2a70755f..1dd49edbb72 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -3069,7 +3069,7 @@ point="org.eclipse.search.searchPages"> + searchResultClass="org.eclipse.cdt.internal.ui.search.CSearchResult"/> diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindDeclarationsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindDeclarationsAction.java index 6715736e73e..5dbaefc5c66 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindDeclarationsAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindDeclarationsAction.java @@ -21,7 +21,7 @@ import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery; +import org.eclipse.cdt.internal.ui.search.CSearchQuery; /** * @author Doug Schaefer @@ -57,7 +57,7 @@ public class FindDeclarationsAction extends IndexAction { null, cproject, indexView.getLastWriteAccess(cproject), (IIndexBinding) binding.fObject, binding.fText, - PDOMSearchQuery.FIND_DECLARATIONS | PDOMSearchQuery.FIND_DEFINITIONS); + CSearchQuery.FIND_DECLARATIONS | CSearchQuery.FIND_DEFINITIONS); NewSearchUI.activateSearchResultView(); NewSearchUI.runQueryInBackground(query); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindReferencesAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindReferencesAction.java index 2bb5baeff23..0eb5483cdc7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindReferencesAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindReferencesAction.java @@ -12,7 +12,7 @@ package org.eclipse.cdt.internal.ui.indexview; -import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery; +import org.eclipse.cdt.internal.ui.search.CSearchQuery; import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.model.ICProject; @@ -56,7 +56,7 @@ public class FindReferencesAction extends IndexAction { null, cproject, indexView.getLastWriteAccess(cproject), (IIndexBinding) binding.fObject, binding.fText, - PDOMSearchQuery.FIND_REFERENCES); + CSearchQuery.FIND_REFERENCES); NewSearchUI.activateSearchResultView(); NewSearchUI.runQueryInBackground(query); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexViewSearchQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexViewSearchQuery.java index bdd370a4626..1e0410458f1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexViewSearchQuery.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexViewSearchQuery.java @@ -27,14 +27,14 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.core.CCoreInternals; -import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery; +import org.eclipse.cdt.internal.ui.search.CSearchQuery; /** * @author Doug Schaefer * * This is the search query to be used for searching the PDOM. */ -public class IndexViewSearchQuery extends PDOMSearchQuery { +public class IndexViewSearchQuery extends CSearchQuery { private IIndexBinding fBinding; private long fLastWrite; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.java index 13d0d67d2a4..93d5ca243ff 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.java @@ -35,7 +35,6 @@ public final class Messages extends NLS { public static String Refactoring_CantLoadTU; public static String Refactoring_Ambiguity; public static String Refactoring_ParsingError; - public static String NodeContainer_Name; public static String NO_FILE; public static String RefactoringSaveHelper_unexpected_exception; public static String RefactoringSaveHelper_saving; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.properties index 6ae45bc3622..04adb314e15 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.properties @@ -31,7 +31,6 @@ Refactoring_CantLoadTU=Can not load translation unit. Refactoring_Ambiguity=Translation unit is ambiguous. Refactoring_ParsingError=Unable to parse {0}. NO_FILE=File not found. -NodeContainer_Name=name: RefactoringSaveHelper_unexpected_exception=An unexpected exception occurred. See the error log for more details. RefactoringSaveHelper_saving=Saving Resources RefactoringSaveHelper_always_save=&Always save all modified resources automatically prior to refactoring diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java index 169f1400639..6b86328d49f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java @@ -50,14 +50,14 @@ import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriter; public class NodeContainer { public final NameInformation NULL_NAME_INFORMATION = new NameInformation(new CPPASTName()); - private final ArrayList vec; - private final ArrayList names; + private final List nodes; + private final List names; public class NameInformation { private IASTName name; private IASTName declaration; - private final ArrayList references; - private ArrayList referencesAfterCached; + private final List references; + private List referencesAfterCached; private int lastCachedReferencesHash; private boolean isReference; private boolean isReturnValue; @@ -103,9 +103,8 @@ public class NodeContainer { references.add(name); } - public ArrayList getReferencesAfterSelection() { - if (referencesAfterCached == null - || lastCachedReferencesHash != references.hashCode()) { + public List getReferencesAfterSelection() { + if (referencesAfterCached == null || lastCachedReferencesHash != references.hashCode()) { lastCachedReferencesHash = references.hashCode(); referencesAfterCached = new ArrayList(); for (IASTName ref : references) { @@ -196,18 +195,17 @@ public class NodeContainer { return writer.write(declSpec); } - public boolean isDeclarationInScope() { + public boolean isDeclarationExtracted() { if (declaration != null && declaration.toCharArray().length > 0) { int declOffset = declaration.getFileLocation().getNodeOffset(); - return declOffset >= getStartOffset() - && declOffset <= getEndOffset(); + return declOffset >= getStartOffset() && declOffset <= getEndOffset(); } return true; } @Override public String toString() { - return Messages.NodeContainer_Name + name + ' ' + isDeclarationInScope(); + return name.toString() + ": " + (isDeclarationExtracted() ? "with declaration" : "without declaration"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ } public boolean isReference() { @@ -269,24 +267,24 @@ public class NodeContainer { public NodeContainer() { super(); - vec = new ArrayList(); + nodes = new ArrayList(); names = new ArrayList(); } public final int size() { - return vec.size(); + return nodes.size(); } public final boolean isEmpty() { - return vec.isEmpty(); + return nodes.isEmpty(); } public void add(IASTNode node) { - vec.add(node); + nodes.add(node); } public void findAllNames() { - for (IASTNode node : vec) { + for (IASTNode node : nodes) { node.accept(new ASTVisitor() { { shouldVisitNames = true; @@ -343,7 +341,7 @@ public class NodeContainer { * Returns all local names in the selection which will be used after the * selection expected the ones which are pointers */ - public ArrayList getAllAfterUsedNames() { + public List getAllAfterUsedNames() { ArrayList declarations = new ArrayList(); ArrayList usedAfter = new ArrayList(); @@ -364,13 +362,12 @@ public class NodeContainer { return usedAfter; } - public ArrayList getAllAfterUsedNamesChoosenByUser() { + public List getAllAfterUsedNamesChoosenByUser() { ArrayList declarations = new ArrayList(); ArrayList usedAfter = new ArrayList(); for (NameInformation nameInf : names) { if (!declarations.contains(nameInf.getDeclaration())) { - declarations.add(nameInf.getDeclaration()); if (nameInf.isUserSetIsReference() || nameInf.isUserSetIsReturnValue()) { usedAfter.add(nameInf); @@ -381,7 +378,7 @@ public class NodeContainer { return usedAfter; } - public ArrayList getUsedNamesUnique() { + public List getUsedNamesUnique() { ArrayList declarations = new ArrayList(); ArrayList usedAfter = new ArrayList(); @@ -411,18 +408,19 @@ public class NodeContainer { * selection expected the ones which are pointers * XXX Was soll dieser Kommentar aussagen? --Mirko */ - public ArrayList getAllDeclaredInScope() { + public List getAllDeclaredInScope() { ArrayList declarations = new ArrayList(); ArrayList usedAfter = new ArrayList(); - for (NameInformation nameInf : names) { - if (nameInf.isDeclarationInScope() - && !declarations.contains(nameInf.getDeclaration()) && nameInf.isUsedAfterReferences()) { - declarations.add(nameInf.getDeclaration()); - usedAfter.add(nameInf); - // is return value candidate, set return value to true and reference to false - nameInf.setReturnValue(true); - nameInf.setReference(false); + for (NameInformation nameInfo : names) { + if (nameInfo.isDeclarationExtracted() && + !declarations.contains(nameInfo.getDeclaration()) && + nameInfo.isUsedAfterReferences()) { + declarations.add(nameInfo.getDeclaration()); + usedAfter.add(nameInfo); + // Is return value candidate, set return value to true and reference to false + nameInfo.setReturnValue(true); + nameInfo.setReference(false); } } @@ -430,7 +428,7 @@ public class NodeContainer { } public List getNodesToWrite() { - return vec; + return nodes; } public int getStartOffset() { @@ -444,7 +442,7 @@ public class NodeContainer { private int getOffset(boolean includeComments) { int start = Integer.MAX_VALUE; - for (IASTNode node : vec) { + for (IASTNode node : nodes) { int nodeStart = Integer.MAX_VALUE; IASTNodeLocation[] nodeLocations = node.getNodeLocations(); @@ -483,7 +481,7 @@ public class NodeContainer { private int getEndOffset(boolean includeComments) { int end = 0; - for (IASTNode node : vec) { + for (IASTNode node : nodes) { int fileOffset = 0; int length = 0; @@ -514,7 +512,7 @@ public class NodeContainer { @Override public String toString() { - return vec.toString(); + return nodes.toString(); } public List getNames() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ChooserComposite.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ChooserComposite.java index 26f450d94c3..8ec5231fee4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ChooserComposite.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ChooserComposite.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.ui.refactoring.extractfunction; import java.util.ArrayList; +import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.TableEditor; @@ -38,13 +39,13 @@ public class ChooserComposite extends Composite { private Button voidReturn; - private final ExtractFunctionInputPage ip; + private final ExtractFunctionInputPage page; public ChooserComposite(Composite parent, final ExtractFunctionInformation info, - ExtractFunctionInputPage ip) { + ExtractFunctionInputPage page) { super(parent, SWT.NONE); - this.ip = ip; + this.page = page; GridLayout layout = new GridLayout(); setLayout(layout); @@ -75,7 +76,7 @@ public class ChooserComposite extends Composite { addColumnToTable(table, ""); //$NON-NLS-1$ for (int i = 0; i < info.getAllUsedNames().size(); i++) { - if (!info.getAllUsedNames().get(i).isDeclarationInScope()) { + if (!info.getAllUsedNames().get(i).isDeclarationExtracted()) { TableItem item = new TableItem(table, SWT.NONE); TableEditor editor = new TableEditor(table); @@ -212,15 +213,15 @@ public class ChooserComposite extends Composite { column.setWidth(100); } - void onVisibilityOrReturnChange(ArrayList name) { + void onVisibilityOrReturnChange(List name) { String variableUsedAfterBlock = null; for (NameInformation information : name) { - if (information.isUsedAfterReferences() - && !(information.isUserSetIsReference() || information.isUserSetIsReturnValue())) { + if (information.isUsedAfterReferences() && + !(information.isUserSetIsReference() || information.isUserSetIsReturnValue())) { variableUsedAfterBlock = information.getName().toString(); } } - ip.errorWithAfterUsedVariable(variableUsedAfterBlock); + page.errorWithAfterUsedVariable(variableUsedAfterBlock); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractExpression.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractExpression.java index c4555e77a57..5a93af1cab0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractExpression.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractExpression.java @@ -53,7 +53,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction; import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation; /** - * Handles the extraction of expression nodes, like return type determination. + * Handles the extraction of expression nodes, for example, return type determination. * * @author Mirko Stocker */ @@ -64,7 +64,8 @@ public class ExtractExpression extends ExtractedFunctionConstructionHelper { public void constructMethodBody(IASTCompoundStatement compound, List list, ASTRewrite rewrite, TextEditGroup group) { CPPASTReturnStatement statement = new CPPASTReturnStatement(); - IASTExpression nullReturnExp = new CPPASTLiteralExpression(IASTLiteralExpression.lk_integer_constant, ZERO); + IASTExpression nullReturnExp = + new CPPASTLiteralExpression(IASTLiteralExpression.lk_integer_constant, ZERO); statement.setReturnValue(nullReturnExp); ASTRewrite nestedRewrite = rewrite.insertBefore(compound, null, statement, group); @@ -72,11 +73,11 @@ public class ExtractExpression extends ExtractedFunctionConstructionHelper { } private IASTExpression getExpression(List list) { - if (list.size()> 1) { + if (list.size() > 1) { CPPASTBinaryExpression bExp = new CPPASTBinaryExpression(); bExp.setParent(list.get(0).getParent()); bExp.setOperand1((IASTExpression) list.get(0).copy(CopyStyle.withLocations)); - bExp.setOperator(((IASTBinaryExpression)list.get(1).getParent()).getOperator()); + bExp.setOperator(((IASTBinaryExpression) list.get(1).getParent()).getOperator()); bExp.setOperand2(getExpression(list.subList(1, list.size()))); return bExp; } else { @@ -154,7 +155,7 @@ public class ExtractExpression extends ExtractedFunctionConstructionHelper { } @Override - protected boolean isReturnTypeAPointer(IASTNode node) { + protected boolean hasPointerReturnType(IASTNode node) { if (node instanceof ICPPASTNewExpression) { return true; } else if (!(node instanceof IASTFunctionCallExpression)) { @@ -186,11 +187,13 @@ public class ExtractExpression extends ExtractedFunctionConstructionHelper { } private static boolean hasDeclaration(CPPFunction function) { - return function != null && function.getDeclarations() != null && function.getDeclarations().length > 0; + return function != null && function.getDeclarations() != null && + function.getDeclarations().length > 0; } @Override - public IASTNode createReturnAssignment(IASTNode node, IASTExpressionStatement stmt, IASTExpression callExpression) { + public IASTNode createReturnAssignment(IASTNode node, IASTExpressionStatement stmt, + IASTExpression callExpression) { return callExpression; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionInformation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionInformation.java index 64f9b8d8d24..14782828a76 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionInformation.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionInformation.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.ui.refactoring.extractfunction; import java.util.ArrayList; +import java.util.List; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; @@ -20,15 +21,11 @@ import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation; import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum; public class ExtractFunctionInformation { - public final int VISIBILITY_PRIVATE = 1; - public final int VISIBILITY_PROTECTED = 3; - public final int VISIBILITY_PUBLIC = 2; - private VisibilityEnum visibility = VisibilityEnum.v_private; private String methodName; private boolean replaceDuplicates; - private ArrayList allAfterUsedNames; - private ArrayList allUsedNames; + private List allAfterUsedNames; + private List allUsedNames; private NameInformation inScopeDeclaredVariable; private NameInformation returnVariable; private ICPPASTFunctionDeclarator declarator; @@ -65,7 +62,7 @@ public class ExtractFunctionInformation { this.replaceDuplicates = replaceDuplicates; } - public ArrayList getAllAfterUsedNames() { + public List getAllAfterUsedNames() { if (allAfterUsedNames == null) { allAfterUsedNames = new ArrayList(); for (NameInformation name : getAllUsedNames()) { @@ -101,11 +98,11 @@ public class ExtractFunctionInformation { this.inScopeDeclaredVariable = inScopeDeclaredVariable; } - public ArrayList getAllUsedNames() { + public List getAllUsedNames() { return allUsedNames; } - public void setAllUsedNames(ArrayList allUsedNames) { + public void setAllUsedNames(List allUsedNames) { this.allUsedNames = allUsedNames; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java index 74e5a965a32..99ccb7f08f7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java @@ -17,7 +17,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Vector; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.ResourcesPlugin; @@ -202,7 +201,7 @@ public class ExtractFunctionRefactoring extends CRefactoring { info.getInScopeDeclaredVariable().setUserSetIsReturnValue(true); } for (int i = 0; i < info.getAllUsedNames().size(); i++) { - if (!info.getAllUsedNames().get(i).isDeclarationInScope()) { + if (!info.getAllUsedNames().get(i).isDeclarationExtracted()) { NameInformation name = info.getAllUsedNames().get(i); if (!name.isReturnValue()) { name.setUserSetIsReference(name.isReference()); @@ -434,7 +433,7 @@ public class ExtractFunctionRefactoring extends CRefactoring { } } - final Vector initTrail = getTrail(nodesToRewriteWithoutComments); + final List initTrail = getTrail(nodesToRewriteWithoutComments); final String title; if (contextType == MethodContext.ContextType.METHOD) { title = Messages.ExtractFunctionRefactoring_CreateMethodCall; @@ -448,8 +447,8 @@ public class ExtractFunctionRefactoring extends CRefactoring { } } - protected Vector getTrail(List stmts) { - final Vector trail = new Vector(); + protected List getTrail(List stmts) { + final List trail = new ArrayList(); nameTrail = new HashMap(); final Container trailCounter = new Container(NULL_INTEGER); @@ -465,8 +464,9 @@ public class ExtractFunctionRefactoring extends CRefactoring { trail.add(node); return PROCESS_SKIP; } else if (node instanceof IASTName) { - if (node instanceof ICPPASTConversionName && node instanceof ICPPASTOperatorName - && node instanceof ICPPASTTemplateId) { + if (node instanceof ICPPASTConversionName && + node instanceof ICPPASTOperatorName && + node instanceof ICPPASTTemplateId) { trail.add(node); return super.visitAll(node); } else { @@ -483,8 +483,8 @@ public class ExtractFunctionRefactoring extends CRefactoring { } trailName.setNameNumber(actCount); - if (info.getReturnVariable() != null - && info.getReturnVariable().getName().getRawSignature().equals( + if (info.getReturnVariable() != null && + info.getReturnVariable().getName().getRawSignature().equals( name.getRawSignature())) { returnNumber.setObject(Integer.valueOf(actCount)); } @@ -498,13 +498,12 @@ public class ExtractFunctionRefactoring extends CRefactoring { } } }); - } return trail; } - protected boolean isStatementInTrail(IASTStatement stmt, final Vector trail, IIndex index) { + protected boolean isStatementInTrail(IASTStatement stmt, final List trail, IIndex index) { final Container same = new Container(Boolean.TRUE); final TrailNodeEqualityChecker equalityChecker = new TrailNodeEqualityChecker(names, namesCounter, index); @@ -591,8 +590,8 @@ public class ExtractFunctionRefactoring extends CRefactoring { return true; } - private void addMethod(IASTName astMethodName, MethodContext context, - ASTRewrite rewriter, IASTNode insertpoint, TextEditGroup group) { + private void addMethod(IASTName astMethodName, MethodContext context, ASTRewrite rewriter, + IASTNode insertpoint, TextEditGroup group) { ICPPASTQualifiedName qname = new CPPASTQualifiedName(); if (context.getType() == ContextType.METHOD) { if (context.getMethodQName() != null) { @@ -609,10 +608,10 @@ public class ExtractFunctionRefactoring extends CRefactoring { IASTDeclSpecifier returnType = getReturnType(); func.setDeclSpecifier(returnType); - IASTStandardFunctionDeclarator createdFunctionDeclarator = extractedFunctionConstructionHelper - .createFunctionDeclarator(qname, info.getDeclarator(), info - .getReturnVariable(), container.getNodesToWrite(), info - .getAllUsedNames(), ast.getASTNodeFactory()); + IASTStandardFunctionDeclarator createdFunctionDeclarator = + extractedFunctionConstructionHelper.createFunctionDeclarator(qname, + info.getDeclarator(), info.getReturnVariable(), container.getNodesToWrite(), + info.getAllUsedNames(), ast.getASTNodeFactory()); func.setDeclarator(createdFunctionDeclarator); IASTCompoundStatement compound = new CPPASTCompoundStatement(); @@ -623,8 +622,8 @@ public class ExtractFunctionRefactoring extends CRefactoring { CPPASTTemplateDeclaration templateDeclaration = new CPPASTTemplateDeclaration(); templateDeclaration.setParent(ast); - for (ICPPASTTemplateParameter templateParameter : ((ICPPASTTemplateDeclaration) insertpoint.getParent()).getTemplateParameters()) { - templateDeclaration.addTemplateParameter(templateParameter.copy(CopyStyle.withLocations)); + for (ICPPASTTemplateParameter param : ((ICPPASTTemplateDeclaration) insertpoint.getParent()).getTemplateParameters()) { + templateDeclaration.addTemplateParameter(param.copy(CopyStyle.withLocations)); } templateDeclaration.setDeclaration(func); @@ -664,8 +663,8 @@ public class ExtractFunctionRefactoring extends CRefactoring { private IASTDeclSpecifier getReturnType() { IASTNode firstNodeToWrite = container.getNodesToWrite().get(0); NameInformation returnVariable = info.getReturnVariable(); - - return extractedFunctionConstructionHelper.determineReturnType(firstNodeToWrite, returnVariable); + return extractedFunctionConstructionHelper.determineReturnType(firstNodeToWrite, + returnVariable); } protected IASTNode getMethodCall(IASTName astMethodName, @@ -678,30 +677,28 @@ public class ExtractFunctionRefactoring extends CRefactoring { idExpression.setName(astMethodName); List args = new ArrayList(); - Vector declarations = new Vector(); + List declarations = new ArrayList(); IASTName retName = null; boolean theRetName = false; for (NameInformation nameInfo : myContainer.getNames()) { Integer trailSeqNumber = trailNameTable.get(nameInfo.getDeclaration().getRawSignature()); - String orgName = null; + String origName = null; for (Entry entry : similarNameTable.entrySet()) { if (entry.getValue().equals(trailSeqNumber)) { - orgName = entry.getKey(); - if (info.getReturnVariable() != null - && trailSeqNumber.equals(returnNumber.getObject())) { + origName = entry.getKey(); + if (info.getReturnVariable() != null && + trailSeqNumber.equals(returnNumber.getObject())) { theRetName = true; } } } - if (orgName != null) { + if (origName != null) { boolean found = false; for (NameInformation simNameInfo : mySimilarContainer.getNames()) { - if (orgName.equals(simNameInfo.getDeclaration() - .getRawSignature())) { - addAParameterIfPossible(args, declarations, - simNameInfo); + if (origName.equals(simNameInfo.getDeclaration().getRawSignature())) { + addParameterIfPossible(args, declarations, simNameInfo); found = true; if (theRetName) { @@ -715,7 +712,7 @@ public class ExtractFunctionRefactoring extends CRefactoring { if (!found) { // should be a field, use the old name IASTIdExpression expression = new CPPASTIdExpression(); - CPPASTName fieldName = new CPPASTName(orgName.toCharArray()); + CPPASTName fieldName = new CPPASTName(origName.toCharArray()); expression.setName(fieldName); args.add(expression); @@ -763,7 +760,6 @@ public class ExtractFunctionRefactoring extends CRefactoring { decl.setDeclSpecifier(orgDecl.getDeclSpecifier().copy(CopyStyle.withLocations)); IASTDeclarator declarator = new CPPASTDeclarator(); - declarator.setName(retname); for (IASTPointerOperator pointer : orgDecl.getDeclarators()[0].getPointerOperators()) { @@ -792,31 +788,30 @@ public class ExtractFunctionRefactoring extends CRefactoring { private IASTNode getReturnAssignment(IASTExpressionStatement stmt, IASTExpression callExpression) { IASTNode node = container.getNodesToWrite().get(0); - return extractedFunctionConstructionHelper.createReturnAssignment(node, - stmt, callExpression); + return extractedFunctionConstructionHelper.createReturnAssignment(node, stmt, callExpression); } private IASTSimpleDeclaration getDeclaration(IASTName name) { IASTSimpleDeclaration simpleDecl = new CPPASTSimpleDeclaration(); IASTStandardFunctionDeclarator declarator = extractedFunctionConstructionHelper.createFunctionDeclarator(name, - info.getDeclarator(), info.getReturnVariable(), - container.getNodesToWrite(), info.getAllUsedNames(), ast.getASTNodeFactory()); + info.getDeclarator(), info.getReturnVariable(), container.getNodesToWrite(), + info.getAllUsedNames(), ast.getASTNodeFactory()); simpleDecl.addDeclarator(declarator); return simpleDecl; } - private IASTSimpleDeclaration getDeclaration(ModificationCollector collector,IASTName name) { + private IASTSimpleDeclaration getDeclaration(ModificationCollector collector, IASTName name) { IASTDeclSpecifier declSpec = getReturnType(); IASTSimpleDeclaration simpleDecl = factory.newSimpleDeclaration(declSpec); if (info.isVirtual() && declSpec instanceof ICPPASTDeclSpecifier) { - ((ICPPASTDeclSpecifier)declSpec).setVirtual(true); + ((ICPPASTDeclSpecifier) declSpec).setVirtual(true); } simpleDecl.setParent(ast); - IASTStandardFunctionDeclarator declarator = extractedFunctionConstructionHelper - .createFunctionDeclarator(name, info.getDeclarator(), info - .getReturnVariable(), container.getNodesToWrite(), info - .getAllUsedNames(), ast.getASTNodeFactory()); + IASTStandardFunctionDeclarator declarator = + extractedFunctionConstructionHelper.createFunctionDeclarator(name, + info.getDeclarator(), info.getReturnVariable(), container.getNodesToWrite(), + info.getAllUsedNames(), ast.getASTNodeFactory()); simpleDecl.addDeclarator(declarator); return simpleDecl; } @@ -852,17 +847,17 @@ public class ExtractFunctionRefactoring extends CRefactoring { public List getCallParameters() { List args = new ArrayList(); - Vector declarations = new Vector(); - for (NameInformation nameInf : container.getNames()) { - addAParameterIfPossible(args, declarations, nameInf); + List declarations = new ArrayList(); + for (NameInformation nameInfo : container.getNames()) { + addParameterIfPossible(args, declarations, nameInfo); } return args; } - private void addAParameterIfPossible(List args, - Vector declarations, NameInformation nameInf) { - if (!nameInf.isDeclarationInScope()) { - IASTName declaration = nameInf.getDeclaration(); + private void addParameterIfPossible(List args, + List declarations, NameInformation nameInfo) { + if (!nameInfo.isDeclarationExtracted()) { + IASTName declaration = nameInfo.getDeclaration(); if (!declarations.contains(declaration)) { declarations.add(declaration); IASTIdExpression expression = new CPPASTIdExpression(); @@ -875,7 +870,9 @@ public class ExtractFunctionRefactoring extends CRefactoring { @Override protected RefactoringDescriptor getRefactoringDescriptor() { Map arguments = getArgumentMap(); - RefactoringDescriptor desc = new ExtractFunctionRefactoringDescription(project.getProject().getName(), "Extract Method Refactoring", "Create method " + info.getMethodName(), arguments); //$NON-NLS-1$//$NON-NLS-2$ + RefactoringDescriptor desc = + new ExtractFunctionRefactoringDescription(project.getProject().getName(), + "Extract Method Refactoring", "Create method " + info.getMethodName(), arguments); //$NON-NLS-1$//$NON-NLS-2$ return desc; } @@ -884,8 +881,10 @@ public class ExtractFunctionRefactoring extends CRefactoring { arguments.put(CRefactoringDescription.FILE_NAME, file.getLocationURI().toString()); arguments.put(CRefactoringDescription.SELECTION, region.getOffset() + "," + region.getLength()); //$NON-NLS-1$ arguments.put(ExtractFunctionRefactoringDescription.NAME, info.getMethodName()); - arguments.put(ExtractFunctionRefactoringDescription.VISIBILITY, info.getVisibility().toString()); - arguments.put(ExtractFunctionRefactoringDescription.REPLACE_DUPLICATES, Boolean.toString(info.isReplaceDuplicates())); + arguments.put(ExtractFunctionRefactoringDescription.VISIBILITY, + info.getVisibility().toString()); + arguments.put(ExtractFunctionRefactoringDescription.REPLACE_DUPLICATES, + Boolean.toString(info.isReplaceDuplicates())); return arguments; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractStatement.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractStatement.java index 77c306e4db3..221b6a47bc8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractStatement.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractStatement.java @@ -36,13 +36,14 @@ public class ExtractStatement extends ExtractedFunctionConstructionHelper { @Override public void constructMethodBody(IASTCompoundStatement compound, List list, ASTRewrite rewrite, TextEditGroup group) { - for (IASTNode each : list) { - rewrite.insertBefore(compound, null, each, group); + for (IASTNode node : list) { + rewrite.insertBefore(compound, null, node, group); } } @Override - public IASTDeclSpecifier determineReturnType(IASTNode extractedNode, NameInformation returnVariable) { + public IASTDeclSpecifier determineReturnType(IASTNode extractedNode, + NameInformation returnVariable) { if (returnVariable != null) { IASTNode decl = ASTHelper.getDeclarationForNode(returnVariable.getDeclaration()); return ASTHelper.getDeclarationSpecifier(decl).copy(CopyStyle.withLocations); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractedFunctionConstructionHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractedFunctionConstructionHelper.java index 5b5543fa357..19b869c6124 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractedFunctionConstructionHelper.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractedFunctionConstructionHelper.java @@ -7,7 +7,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Institute for Software - initial API and implementation + * Institute for Software - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.extractfunction; @@ -55,13 +55,14 @@ public abstract class ExtractedFunctionConstructionHelper { public abstract IASTNode createReturnAssignment(IASTNode node, IASTExpressionStatement stmt, IASTExpression callExpression); - protected boolean isReturnTypeAPointer(IASTNode node) { + protected boolean hasPointerReturnType(IASTNode node) { return false; } IASTStandardFunctionDeclarator createFunctionDeclarator(IASTName name, IASTStandardFunctionDeclarator functionDeclarator, NameInformation returnVariable, - List nodesToWrite, Collection allUsedNames, INodeFactory nodeFactory) { + List nodesToWrite, Collection allUsedNames, + INodeFactory nodeFactory) { IASTStandardFunctionDeclarator declarator = nodeFactory.newFunctionDeclarator(name); if (functionDeclarator instanceof ICPPASTFunctionDeclarator && @@ -83,17 +84,18 @@ public abstract class ExtractedFunctionConstructionHelper { declarator.addParameterDeclaration(param); } - if (isReturnTypeAPointer(nodesToWrite.get(0))) { + if (hasPointerReturnType(nodesToWrite.get(0))) { declarator.addPointerOperator(nodeFactory.newPointer()); } return declarator; } - public Collection getParameterDeclarations(Collection allUsedNames, INodeFactory nodeFactory) { - Collection result = new ArrayList(); + public List getParameterDeclarations( + Collection allUsedNames, INodeFactory nodeFactory) { + List result = new ArrayList(); for (NameInformation name : allUsedNames) { - if (!name.isDeclarationInScope()) { + if (!name.isDeclarationExtracted()) { result.add(name.getParameterDeclaration(name.isUserSetIsReference(), nodeFactory)); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/SimilarFinderVisitor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/SimilarFinderVisitor.java index 4a557f11653..594fef8a01b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/SimilarFinderVisitor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/SimilarFinderVisitor.java @@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.ui.refactoring.extractfunction; import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; -import java.util.Vector; import org.eclipse.core.resources.IFile; import org.eclipse.text.edits.TextEditGroup; @@ -32,7 +31,7 @@ import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation; final class SimilarFinderVisitor extends ASTVisitor { private final ExtractFunctionRefactoring refactoring; - private final Vector trail; + private final List trail; private final IASTName name; private final List statements; private int statementCount; @@ -42,7 +41,7 @@ final class SimilarFinderVisitor extends ASTVisitor { private final ModificationCollector collector; SimilarFinderVisitor(ExtractFunctionRefactoring refactoring, ModificationCollector collector, - Vector trail, IFile file, IASTName name, List statements, + List trail, IFile file, IASTName name, List statements, String title) { this.refactoring = refactoring; this.trail = trail; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchElement.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElement.java similarity index 84% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchElement.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElement.java index 2bd312c7747..0d0afff9267 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchElement.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElement.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * QNX - Initial API and implementation - * Markus Schorn (Wind River Systems) + * QNX - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.ui.search; @@ -23,11 +23,11 @@ import org.eclipse.cdt.core.index.IIndexFileLocation; * * @author Doug Schaefer */ -public class PDOMSearchElement implements IAdaptable { +public class CSearchElement implements IAdaptable { private final IIndexFileLocation location; - public PDOMSearchElement(IIndexFileLocation loc) { + public CSearchElement(IIndexFileLocation loc) { this.location= loc; } @@ -38,9 +38,9 @@ public class PDOMSearchElement implements IAdaptable { @Override public boolean equals(Object obj) { - if (!(obj instanceof PDOMSearchElement)) + if (!(obj instanceof CSearchElement)) return false; - PDOMSearchElement other = (PDOMSearchElement)obj; + CSearchElement other = (CSearchElement)obj; return location.equals(other.location); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchElementQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElementQuery.java similarity index 91% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchElementQuery.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElementQuery.java index 70a19c5f747..8130288e2bd 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchElementQuery.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElementQuery.java @@ -10,7 +10,6 @@ * Markus Schorn (Wind River Systems) * Sergey Prigogin (Google) *******************************************************************************/ - package org.eclipse.cdt.internal.ui.search; import org.eclipse.core.runtime.CoreException; @@ -29,12 +28,11 @@ import org.eclipse.cdt.internal.ui.viewsupport.IndexUI; /** * @author Doug Schaefer */ -public class PDOMSearchElementQuery extends PDOMSearchQuery { - - private ISourceReference element; +public class CSearchElementQuery extends CSearchQuery { + private final ISourceReference element; private String label; - public PDOMSearchElementQuery(ICElement[] scope, ISourceReference element, int flags) { + public CSearchElementQuery(ICElement[] scope, ISourceReference element, int flags) { super(scope, flags | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES); this.element = element; this.label= (element instanceof ICElement) ? diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchLabelProvider.java similarity index 95% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchLabelProvider.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchLabelProvider.java index 8a66ebfae18..99dd322c622 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchLabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchLabelProvider.java @@ -50,15 +50,13 @@ import org.eclipse.cdt.internal.ui.viewsupport.ColoringLabelProvider; * URI - for IIndexFileLocations not resolvable to the local filesystem, under URI_CONTAINER
* @author Doug Schaefer * @author Ed Swartz - * */ -public class PDOMSearchLabelProvider extends LabelProvider implements IStyledLabelProvider { - - protected final PDOMSearchViewPage fPage; +public class CSearchLabelProvider extends LabelProvider implements IStyledLabelProvider { + protected final CSearchViewPage fPage; private final TypeInfoLabelProvider fTypeInfoLabelProvider; private final CUILabelProvider fCElementLabelProvider; - public PDOMSearchLabelProvider(PDOMSearchViewPage page) { + public CSearchLabelProvider(CSearchViewPage page) { fTypeInfoLabelProvider= new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_FULLY_QUALIFIED | TypeInfoLabelProvider.SHOW_PARAMETERS); fCElementLabelProvider= new CUILabelProvider(0, CElementImageProvider.SMALL_ICONS); fPage= page; @@ -152,8 +150,8 @@ public class PDOMSearchLabelProvider extends LabelProvider implements IStyledLab if (element instanceof TranslationUnit) { TranslationUnit translationUnit = (TranslationUnit) element; AbstractTextSearchResult searchResult = fPage.getInput(); - if (searchResult instanceof PDOMSearchResult) { - PDOMSearchResult pdomSearchResult = (PDOMSearchResult)searchResult; + if (searchResult instanceof CSearchResult) { + CSearchResult pdomSearchResult = (CSearchResult)searchResult; return pdomSearchResult.computeContainedMatches(searchResult, translationUnit.getFile()).length; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchListContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchListContentProvider.java similarity index 85% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchListContentProvider.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchListContentProvider.java index e775d26561b..606354f1c5a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchListContentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchListContentProvider.java @@ -6,10 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * QNX - Initial API and implementation - * Ed Swartz (Nokia) + * QNX - Initial API and implementation + * Ed Swartz (Nokia) *******************************************************************************/ - package org.eclipse.cdt.internal.ui.search; import java.util.ArrayList; @@ -32,16 +31,13 @@ import org.eclipse.cdt.ui.CUIPlugin; /** * @author Doug Schaefer - * */ -public class PDOMSearchListContentProvider implements - IStructuredContentProvider, IPDOMSearchContentProvider { - +public class CSearchListContentProvider implements IStructuredContentProvider, IPDOMSearchContentProvider { private TableViewer viewer; - private PDOMSearchResult result; - private final PDOMSearchViewPage fPage; + private CSearchResult result; + private final CSearchViewPage fPage; - PDOMSearchListContentProvider(PDOMSearchViewPage page) { + CSearchListContentProvider(CSearchViewPage page) { fPage= page; } @@ -49,15 +45,15 @@ public class PDOMSearchListContentProvider implements public Object[] getElements(Object inputElement) { Set uncoveredProjects = new HashSet(); - PDOMSearchResult result = (PDOMSearchResult) inputElement; + CSearchResult result = (CSearchResult) inputElement; Object[] results = result.getElements(); List resultList = new ArrayList(); // see which projects returned results for (int i = 0; i < results.length; i++) { - if (results[i] instanceof PDOMSearchElement) { - PDOMSearchElement searchElement = (PDOMSearchElement) results[i]; + if (results[i] instanceof CSearchElement) { + CSearchElement searchElement = (CSearchElement) results[i]; String path = searchElement.getLocation().getFullPath(); if (path != null) { uncoveredProjects.add(new Path(path).segment(0)); @@ -74,7 +70,7 @@ public class PDOMSearchListContentProvider implements } // add message for all the projects which have no results - ICProject[] projects = ((PDOMSearchQuery)result.getQuery()).getProjects(); + ICProject[] projects = ((CSearchQuery)result.getQuery()).getProjects(); for (int i = 0; i < projects.length; ++i) { ICProject project = projects[i]; boolean foundProject = uncoveredProjects.contains(project.getProject().getName()); @@ -113,7 +109,7 @@ public class PDOMSearchListContentProvider implements @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { this.viewer = (TableViewer)viewer; - result = (PDOMSearchResult)newInput; + result = (CSearchResult)newInput; viewer.refresh(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchListLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchListLabelProvider.java similarity index 85% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchListLabelProvider.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchListLabelProvider.java index 82002aa3e84..4ce221584c0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchListLabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchListLabelProvider.java @@ -25,12 +25,12 @@ import org.eclipse.cdt.internal.ui.viewsupport.ColoringLabelProvider; /** * @author Doug Schaefer */ -public class PDOMSearchListLabelProvider extends ColoringLabelProvider { - private final PDOMSearchViewPage fPage; +public class CSearchListLabelProvider extends ColoringLabelProvider { + private final CSearchViewPage fPage; private final int fColumnIndex; - public PDOMSearchListLabelProvider(PDOMSearchViewPage page, int columnIndex) { - super(new PDOMSearchLabelProvider(page)); + public CSearchListLabelProvider(CSearchViewPage page, int columnIndex) { + super(new CSearchLabelProvider(page)); fPage = page; fColumnIndex = columnIndex; } @@ -39,7 +39,7 @@ public class PDOMSearchListLabelProvider extends ColoringLabelProvider { public void update(ViewerCell cell) { Object element = cell.getElement(); switch (fColumnIndex) { - case PDOMSearchViewPage.LOCATION_COLUMN_INDEX: + case CSearchViewPage.LOCATION_COLUMN_INDEX: if (element instanceof LineSearchElement) { LineSearchElement lineElement = (LineSearchElement) element; String location = IndexLocationFactory.getPath(lineElement.getLocation()).toString(); @@ -48,7 +48,7 @@ public class PDOMSearchListLabelProvider extends ColoringLabelProvider { cell.setImage(CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_SEARCH_LINE)); } break; - case PDOMSearchViewPage.DEFINITION_COLUMN_INDEX: + case CSearchViewPage.DEFINITION_COLUMN_INDEX: if (element instanceof LineSearchElement) { LineSearchElement lineElement = (LineSearchElement) element; ICElement enclosingElement = lineElement.getMatches()[0].getEnclosingElement(); @@ -60,7 +60,7 @@ public class PDOMSearchListLabelProvider extends ColoringLabelProvider { } } break; - case PDOMSearchViewPage.MATCH_COLUMN_INDEX: + case CSearchViewPage.MATCH_COLUMN_INDEX: super.update(cell); cell.setImage(null); break; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchMatch.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMatch.java similarity index 77% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchMatch.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMatch.java index fe0fa3bc5cf..c5d25c66b02 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchMatch.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMatch.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * QNX - Initial API and implementation - * Markus Schorn (Wind River Systems) + * QNX - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.ui.search; @@ -18,25 +18,24 @@ import org.eclipse.cdt.core.index.IIndexFileLocation; /** * Base class for search matches found by various index searches. */ -public class PDOMSearchMatch extends Match { - +public class CSearchMatch extends Match { private boolean fIsPolymorphicCall; - public PDOMSearchMatch(PDOMSearchElement elem, int offset, int length) { + public CSearchMatch(CSearchElement elem, int offset, int length) { super(elem, offset, length); } IIndexFileLocation getLocation() { - return ((PDOMSearchElement)getElement()).getLocation(); + return ((CSearchElement)getElement()).getLocation(); } @Override public boolean equals(Object obj) { if (obj == this) return true; - if (!(obj instanceof PDOMSearchMatch)) + if (!(obj instanceof CSearchMatch)) return false; - PDOMSearchMatch other = (PDOMSearchMatch)obj; + CSearchMatch other = (CSearchMatch)obj; return getElement().equals(other.getElement()) && getOffset() == other.getOffset() && getLength() == other.getLength(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java similarity index 91% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPage.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java index 05fe00be13a..d74be81575f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java @@ -6,10 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (QNX) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Doug Schaefer (QNX) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ - package org.eclipse.cdt.internal.ui.search; import java.util.HashSet; @@ -72,10 +71,8 @@ import org.eclipse.cdt.internal.ui.util.RowLayouter; /** * @author Doug Schaefer - * */ -public class PDOMSearchPage extends DialogPage implements ISearchPage { - +public class CSearchPage extends DialogPage implements ISearchPage { public static final String EXTENSION_ID = CUIPlugin.PLUGIN_ID + ".pdomSearchPage"; //$NON-NLS-1$ //Dialog store id constants @@ -106,18 +103,18 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage { // These must be in the same order as the Text private static final Integer[] searchForData = { - new Integer(PDOMSearchPatternQuery.FIND_CLASS_STRUCT), - new Integer(PDOMSearchPatternQuery.FIND_FUNCTION), - new Integer(PDOMSearchPatternQuery.FIND_VARIABLE), - new Integer(PDOMSearchPatternQuery.FIND_UNION), - new Integer(PDOMSearchPatternQuery.FIND_METHOD), - new Integer(PDOMSearchPatternQuery.FIND_FIELD), - new Integer(PDOMSearchPatternQuery.FIND_ENUM), - new Integer(PDOMSearchPatternQuery.FIND_ENUMERATOR), - new Integer(PDOMSearchPatternQuery.FIND_NAMESPACE), - new Integer(PDOMSearchPatternQuery.FIND_TYPEDEF), - new Integer(PDOMSearchPatternQuery.FIND_MACRO), - new Integer(PDOMSearchPatternQuery.FIND_ALL_TYPES) + new Integer(CSearchPatternQuery.FIND_CLASS_STRUCT), + new Integer(CSearchPatternQuery.FIND_FUNCTION), + new Integer(CSearchPatternQuery.FIND_VARIABLE), + new Integer(CSearchPatternQuery.FIND_UNION), + new Integer(CSearchPatternQuery.FIND_METHOD), + new Integer(CSearchPatternQuery.FIND_FIELD), + new Integer(CSearchPatternQuery.FIND_ENUM), + new Integer(CSearchPatternQuery.FIND_ENUMERATOR), + new Integer(CSearchPatternQuery.FIND_NAMESPACE), + new Integer(CSearchPatternQuery.FIND_TYPEDEF), + new Integer(CSearchPatternQuery.FIND_MACRO), + new Integer(CSearchPatternQuery.FIND_ALL_TYPES) }; // the index of FIND_ALL_TYPES @@ -132,10 +129,10 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage { // Must be in the same order as the text private static Integer[] limitToData = { - new Integer(PDOMSearchQuery.FIND_DECLARATIONS), - new Integer(PDOMSearchQuery.FIND_DEFINITIONS), - new Integer(PDOMSearchQuery.FIND_REFERENCES), - new Integer(PDOMSearchQuery.FIND_ALL_OCCURRENCES), + new Integer(CSearchQuery.FIND_DECLARATIONS), + new Integer(CSearchQuery.FIND_DEFINITIONS), + new Integer(CSearchQuery.FIND_REFERENCES), + new Integer(CSearchQuery.FIND_ALL_OCCURRENCES), }; // The index of FIND_ALL_OCCURANCES @@ -189,7 +186,7 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage { // Get search flags int searchFlags = 0; if (searchForButtons[searchAllButtonIndex].getSelection()) { - searchFlags |= PDOMSearchPatternQuery.FIND_ALL_TYPES; + searchFlags |= CSearchPatternQuery.FIND_ALL_TYPES; } else { for (int i = 0; i < searchForButtons.length; ++i) { if (searchForButtons[i].getSelection()) @@ -277,7 +274,7 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage { null : elements.toArray(new ICElement[elements.size()]); try { - PDOMSearchPatternQuery job = new PDOMSearchPatternQuery(scope, scopeDescription, patternStr, + CSearchPatternQuery job = new CSearchPatternQuery(scope, scopeDescription, patternStr, isCaseSensitive, searchFlags); NewSearchUI.activateSearchResultView(); @@ -664,7 +661,7 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage { IDialogSettings settings = getDialogSettings(); - int searchFlags = PDOMSearchPatternQuery.FIND_ALL_TYPES | PDOMSearchQuery.FIND_ALL_OCCURRENCES; + int searchFlags = CSearchPatternQuery.FIND_ALL_TYPES | CSearchQuery.FIND_ALL_OCCURRENCES; try { searchFlags = settings.getInt(STORE_SEARCH_FLAGS); } catch (NumberFormatException e) { @@ -686,45 +683,45 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage { ICElement element = (ICElement)obj; patternCombo.setText(element.getElementName()); // Clear the type flags so we can set them correctly for what we have selected - searchFlags = searchFlags & ~PDOMSearchPatternQuery.FIND_ALL_TYPES; + searchFlags = searchFlags & ~CSearchPatternQuery.FIND_ALL_TYPES; switch (element.getElementType()) { case ICElement.C_CLASS: case ICElement.C_STRUCT: - searchFlags |= PDOMSearchPatternQuery.FIND_CLASS_STRUCT; + searchFlags |= CSearchPatternQuery.FIND_CLASS_STRUCT; break; case ICElement.C_FUNCTION: - searchFlags |= PDOMSearchPatternQuery.FIND_FUNCTION; + searchFlags |= CSearchPatternQuery.FIND_FUNCTION; break; case ICElement.C_VARIABLE: - searchFlags |= PDOMSearchPatternQuery.FIND_VARIABLE; + searchFlags |= CSearchPatternQuery.FIND_VARIABLE; break; case ICElement.C_UNION: - searchFlags |= PDOMSearchPatternQuery.FIND_UNION; + searchFlags |= CSearchPatternQuery.FIND_UNION; break; case ICElement.C_METHOD: - searchFlags |= PDOMSearchPatternQuery.FIND_METHOD; + searchFlags |= CSearchPatternQuery.FIND_METHOD; break; case ICElement.C_FIELD: - searchFlags |= PDOMSearchPatternQuery.FIND_FIELD; + searchFlags |= CSearchPatternQuery.FIND_FIELD; break; case ICElement.C_ENUMERATION: - searchFlags |= PDOMSearchPatternQuery.FIND_ENUM; + searchFlags |= CSearchPatternQuery.FIND_ENUM; break; case ICElement.C_ENUMERATOR: - searchFlags |= PDOMSearchPatternQuery.FIND_ENUMERATOR; + searchFlags |= CSearchPatternQuery.FIND_ENUMERATOR; break; case ICElement.C_NAMESPACE: - searchFlags |= PDOMSearchPatternQuery.FIND_NAMESPACE; + searchFlags |= CSearchPatternQuery.FIND_NAMESPACE; break; case ICElement.C_TYPEDEF: - searchFlags |= PDOMSearchPatternQuery.FIND_TYPEDEF; + searchFlags |= CSearchPatternQuery.FIND_TYPEDEF; break; case ICElement.C_MACRO: - searchFlags |= PDOMSearchPatternQuery.FIND_MACRO; + searchFlags |= CSearchPatternQuery.FIND_MACRO; break; default: // Not sure, set to all - searchFlags |= PDOMSearchPatternQuery.FIND_ALL_TYPES; + searchFlags |= CSearchPatternQuery.FIND_ALL_TYPES; patternCombo.setText(""); //$NON-NLS-1$ } } @@ -740,7 +737,7 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage { caseSensitiveButton.setSelection(settings.getBoolean(STORE_CASE_SENSITIVE)); - if ((searchFlags & PDOMSearchPatternQuery.FIND_ALL_TYPES) == PDOMSearchPatternQuery.FIND_ALL_TYPES) { + if ((searchFlags & CSearchPatternQuery.FIND_ALL_TYPES) == CSearchPatternQuery.FIND_ALL_TYPES) { searchForButtons[searchAllButtonIndex].setSelection(true); for (int i = 0; i < searchForButtons.length; ++i) { if (i != searchAllButtonIndex) { @@ -758,7 +755,7 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage { } } - if ((searchFlags & PDOMSearchQuery.FIND_ALL_OCCURRENCES) == PDOMSearchQuery.FIND_ALL_OCCURRENCES) { + if ((searchFlags & CSearchQuery.FIND_ALL_OCCURRENCES) == CSearchQuery.FIND_ALL_OCCURRENCES) { limitToButtons[limitToAllButtonIndex].setSelection(true); for (int i = 0; i < limitToButtons.length; ++i) { if (i != limitToAllButtonIndex) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPatternQuery.java similarity index 94% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPatternQuery.java index 20b5e4ad703..6294a000a3c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPatternQuery.java @@ -40,12 +40,10 @@ import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IndexFilter; import org.eclipse.cdt.core.model.ICElement; - /** * @author Doug Schaefer */ -public class PDOMSearchPatternQuery extends PDOMSearchQuery { - +public class CSearchPatternQuery extends CSearchQuery { // First bit after the FINDs in PDOMSearchQuery. public static final int FIND_CLASS_STRUCT = 0x10; public static final int FIND_FUNCTION = 0x20; @@ -58,16 +56,16 @@ public class PDOMSearchPatternQuery extends PDOMSearchQuery { public static final int FIND_NAMESPACE = 0x4000; public static final int FIND_TYPEDEF = 0x10000; public static final int FIND_MACRO = 0x20000; - public static final int FIND_ALL_TYPES - = FIND_CLASS_STRUCT | FIND_FUNCTION | FIND_VARIABLE - | FIND_UNION | FIND_METHOD | FIND_FIELD | FIND_ENUM - | FIND_ENUMERATOR | FIND_NAMESPACE | FIND_TYPEDEF | FIND_MACRO; + public static final int FIND_ALL_TYPES = + FIND_CLASS_STRUCT | FIND_FUNCTION | FIND_VARIABLE | + FIND_UNION | FIND_METHOD | FIND_FIELD | FIND_ENUM | + FIND_ENUMERATOR | FIND_NAMESPACE | FIND_TYPEDEF | FIND_MACRO; - private String scopeDesc; - private String patternStr; - private Pattern[] pattern; + private final String scopeDesc; + private final String patternStr; + private final Pattern[] pattern; - public PDOMSearchPatternQuery( + public CSearchPatternQuery( ICElement[] scope, String scopeDesc, String patternStr, diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java similarity index 97% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java index 2b72e25d3b0..e0c673ee6d0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java @@ -74,7 +74,7 @@ import org.eclipse.cdt.internal.ui.util.Messages; import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.internal.ui.viewsupport.IndexUI; -public abstract class PDOMSearchQuery implements ISearchQuery { +public abstract class CSearchQuery implements ISearchQuery { public static final int FIND_DECLARATIONS = IIndex.FIND_DECLARATIONS; public static final int FIND_DEFINITIONS = IIndex.FIND_DEFINITIONS; public static final int FIND_REFERENCES = IIndex.FIND_REFERENCES; @@ -86,15 +86,15 @@ public abstract class PDOMSearchQuery implements ISearchQuery { CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.TEMPLATE_ARGUMENTS; - protected PDOMSearchResult result; + protected CSearchResult result; protected int flags; protected ICElement[] scope; protected ICProject[] projects; private Set fullPathFilter; - protected PDOMSearchQuery(ICElement[] scope, int flags) { - result = new PDOMSearchResult(this); + protected CSearchQuery(ICElement[] scope, int flags) { + result = new CSearchResult(this); this.flags = flags; this.scope = scope; @@ -319,7 +319,7 @@ public abstract class PDOMSearchQuery implements ISearchQuery { for (Match lineMatch : searchElement.getMatches()) { int offset = lineMatch.getOffset(); int length = lineMatch.getLength(); - PDOMSearchMatch match = new PDOMSearchMatch(searchElement, offset, length); + CSearchMatch match = new CSearchMatch(searchElement, offset, length); if (lineMatch.isPolymorphicCall()) match.setIsPolymorphicCall(); result.addMatch(match); @@ -470,7 +470,7 @@ public abstract class PDOMSearchQuery implements ISearchQuery { for (Match lineMatch : searchElement.getMatches()) { int offset = lineMatch.getOffset(); int length = lineMatch.getLength(); - PDOMSearchMatch match = new PDOMSearchMatch(searchElement, offset, length); + CSearchMatch match = new CSearchMatch(searchElement, offset, length); result.addMatch(match); } } @@ -487,7 +487,7 @@ public abstract class PDOMSearchQuery implements ISearchQuery { @Override public final IStatus run(IProgressMonitor monitor) throws OperationCanceledException { - PDOMSearchResult result= (PDOMSearchResult) getSearchResult(); + CSearchResult result= (CSearchResult) getSearchResult(); result.removeAll(); result.setIndexerBusy(!CCorePlugin.getIndexManager().isIndexerIdle()); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchResult.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResult.java similarity index 92% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchResult.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResult.java index f11f954d978..bd3a4f0a4ee 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchResult.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResult.java @@ -46,15 +46,15 @@ import org.eclipse.cdt.internal.ui.util.ExternalEditorInput; /** * @author Doug Schaefer */ -public class PDOMSearchResult extends AbstractTextSearchResult implements IEditorMatchAdapter, IFileMatchAdapter { +public class CSearchResult extends AbstractTextSearchResult implements IEditorMatchAdapter, IFileMatchAdapter { private static final String KEY_SHOW_POLYMORPHIC_CALLS = "ShowPolymorphicCalls"; //$NON-NLS-1$ final static MatchFilter[] ALL_FILTERS = new MatchFilter[] {HidePolymorphicCalls.FILTER}; final static MatchFilter[] NO_FILTERS = {}; - private PDOMSearchQuery query; + private CSearchQuery query; private boolean indexerBusy; - public PDOMSearchResult(PDOMSearchQuery query) { + public CSearchResult(CSearchQuery query) { super(); this.query = query; } @@ -102,9 +102,9 @@ public class PDOMSearchResult extends AbstractTextSearchResult implements IEdito @Override public boolean isShownInEditor(Match match, IEditorPart editor) { final String fileName= getFileName(editor); - if (fileName != null && match instanceof PDOMSearchMatch) { + if (fileName != null && match instanceof CSearchMatch) { final IPath filePath= new Path(fileName); - return filePath.equals(IndexLocationFactory.getAbsolutePath(((PDOMSearchMatch)match).getLocation())); + return filePath.equals(IndexLocationFactory.getAbsolutePath(((CSearchMatch)match).getLocation())); } return false; } @@ -114,10 +114,10 @@ public class PDOMSearchResult extends AbstractTextSearchResult implements IEdito List list = new ArrayList(); Object[] elements = result.getElements(); for (int i = 0; i < elements.length; ++i) { - if (pfilename.equals(IndexLocationFactory.getAbsolutePath(((PDOMSearchElement)elements[i]).getLocation()))) { + if (pfilename.equals(IndexLocationFactory.getAbsolutePath(((CSearchElement)elements[i]).getLocation()))) { Match[] matches = result.getMatches(elements[i]); for (int j = 0; j < matches.length; ++j) { - if (matches[j] instanceof PDOMSearchMatch) { + if (matches[j] instanceof CSearchMatch) { list.add(matches[j]); } } @@ -159,8 +159,8 @@ public class PDOMSearchResult extends AbstractTextSearchResult implements IEdito return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(location.getFullPath())); } } catch(CoreException ce) { /* fall-through to return null */ } - } else if (element instanceof PDOMSearchElement) { - PDOMSearchElement searchElement = (PDOMSearchElement)element; + } else if (element instanceof CSearchElement) { + CSearchElement searchElement = (CSearchElement)element; IIndexFileLocation location = searchElement.getLocation(); if(location.getFullPath()!=null) { return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(location.getFullPath())); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTextSelectionQuery.java similarity index 94% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTextSelectionQuery.java index a8a7891ef56..442c44aef67 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTextSelectionQuery.java @@ -38,12 +38,12 @@ import org.eclipse.cdt.internal.ui.editor.ASTProvider; /** * Query for searching the index based on a text selection. */ -public class PDOMSearchTextSelectionQuery extends PDOMSearchQuery { +public class CSearchTextSelectionQuery extends CSearchQuery { private ITranslationUnit tu; private ITextSelection selection; private String label; - public PDOMSearchTextSelectionQuery(ICElement[] scope, ITranslationUnit tu, ITextSelection selection, int flags) { + public CSearchTextSelectionQuery(ICElement[] scope, ITranslationUnit tu, ITextSelection selection, int flags) { super(scope, flags | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES); this.tu = tu; this.selection = selection; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTreeContentProvider.java similarity index 89% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeContentProvider.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTreeContentProvider.java index c970020595d..dce2eb10467 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeContentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTreeContentProvider.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * QNX - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Ed Swartz (Nokia) + * QNX - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Ed Swartz (Nokia) *******************************************************************************/ package org.eclipse.cdt.internal.ui.search; @@ -42,16 +42,14 @@ import org.eclipse.cdt.internal.core.resources.ResourceLookup; /** * @author Doug Schaefer - * */ -public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDOMSearchContentProvider { - +public class CSearchTreeContentProvider implements ITreeContentProvider, IPDOMSearchContentProvider { private TreeViewer viewer; - private PDOMSearchResult result; - private Map> tree = new HashMap>(); - private final PDOMSearchViewPage fPage; + private CSearchResult result; + private final Map> tree = new HashMap>(); + private final CSearchViewPage fPage; - PDOMSearchTreeContentProvider(PDOMSearchViewPage page) { + CSearchTreeContentProvider(CSearchViewPage page) { fPage= page; } @@ -92,7 +90,7 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { this.viewer = (TreeViewer)viewer; - this.result = (PDOMSearchResult) newInput; + this.result = (CSearchResult) newInput; initialize(result); viewer.refresh(); } @@ -128,7 +126,7 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO return children.add(child); } - private void insertSearchElement(PDOMSearchElement element) { + private void insertSearchElement(CSearchElement element) { IIndexFileLocation location= element.getLocation(); IFile[] files; if(location.getFullPath()!=null) { @@ -181,7 +179,7 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO public void elementsChanged(Object[] elements) { if (elements != null) { for (int i = 0; i < elements.length; ++i) { - PDOMSearchElement element = (PDOMSearchElement)elements[i]; + CSearchElement element = (CSearchElement)elements[i]; if (fPage.getDisplayedMatchCount(element) > 0) { insertSearchElement(element); } else { @@ -219,7 +217,7 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO initialize(result); } - private void initialize(final PDOMSearchResult result) { + private void initialize(final CSearchResult result) { this.result = result; tree.clear(); if (result != null) { @@ -230,13 +228,13 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO Object[] elements = result.getElements(); for (int i = 0; i < elements.length; ++i) { - final PDOMSearchElement element = (PDOMSearchElement)elements[i]; + final CSearchElement element = (CSearchElement)elements[i]; if (fPage.getDisplayedMatchCount(element) > 0) insertSearchElement(element); } // add all the projects which have no results - ICProject[] projects = ((PDOMSearchQuery)result.getQuery()).getProjects(); + ICProject[] projects = ((CSearchQuery)result.getQuery()).getProjects(); for (int i = 0; i < projects.length; ++i) { ICProject project = projects[i]; Object projectResults = tree.get(project); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTreeLabelProvider.java similarity index 94% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeLabelProvider.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTreeLabelProvider.java index 9db94a74715..1bcb87b2f59 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeLabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTreeLabelProvider.java @@ -21,9 +21,9 @@ import org.eclipse.cdt.internal.core.model.TranslationUnit; import org.eclipse.cdt.internal.ui.util.Messages; -public class PDOMSearchTreeLabelProvider extends PDOMSearchLabelProvider { +public class CSearchTreeLabelProvider extends CSearchLabelProvider { - public PDOMSearchTreeLabelProvider(PDOMSearchViewPage page) { + public CSearchTreeLabelProvider(CSearchViewPage page) { super(page); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchUnresolvedIncludesQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUnresolvedIncludesQuery.java similarity index 89% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchUnresolvedIncludesQuery.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUnresolvedIncludesQuery.java index b519f3237ed..09a73b401b3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchUnresolvedIncludesQuery.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUnresolvedIncludesQuery.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.ui.search; @@ -28,9 +28,9 @@ import org.eclipse.cdt.internal.ui.util.Messages; * Query for searching unresolved includes in projects. * Could be extended to search resources selections. */ -public class PDOMSearchUnresolvedIncludesQuery extends PDOMSearchQuery { +public class CSearchUnresolvedIncludesQuery extends CSearchQuery { - public PDOMSearchUnresolvedIncludesQuery(ICElement[] scope) { + public CSearchUnresolvedIncludesQuery(ICElement[] scope) { super(scope, 0); } @@ -40,7 +40,7 @@ public class PDOMSearchUnresolvedIncludesQuery extends PDOMSearchQuery { for (IIndexFile file : index.getAllFiles()) { for (IIndexInclude include : file.getIncludes()) { if (include.isActive() && !include.isResolved()) { - result.addMatch(new PDOMSearchMatch(new ProblemSearchElement( + result.addMatch(new CSearchMatch(new ProblemSearchElement( IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND, include.getFullName(), include.getIncludedByLocation()), include.getNameOffset(), include.getNameLength())); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUtil.java index 0d839f76902..0995da90ff2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUtil.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUtil.java @@ -21,7 +21,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVariableReadWri import org.eclipse.cdt.internal.core.pdom.dom.PDOMName; public class CSearchUtil { - public static int LRU_WORKINGSET_LIST_SIZE= 3; private static LRUWorkingSets workingSetsCache; @@ -44,10 +43,10 @@ public class CSearchUtil { } public static String toString(IWorkingSet[] workingSets) { - if( workingSets != null && workingSets.length > 0 ){ + if (workingSets != null && workingSets.length > 0) { String string = new String(); - for( int i = 0; i < workingSets.length; i++ ){ - if( i > 0 ) + for (int i = 0; i < workingSets.length; i++) { + if (i > 0) string += ", "; //$NON-NLS-1$ string += workingSets[i].getName(); } @@ -62,8 +61,7 @@ public class CSearchUtil { boolean isWrite; if (binding instanceof ICPPVariable) { isWrite = ((CPPVariableReadWriteFlags.getReadWriteFlags(node) & PDOMName.WRITE_ACCESS) != 0); - } - else { + } else { isWrite = ((CVariableReadWriteFlags.getReadWriteFlags(node) & PDOMName.WRITE_ACCESS) != 0); } return isWrite; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchViewPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchViewPage.java similarity index 91% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchViewPage.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchViewPage.java index f2ae610fb2f..737f0051c84 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchViewPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchViewPage.java @@ -51,7 +51,7 @@ import org.eclipse.cdt.internal.ui.viewsupport.ColoringLabelProvider; /** * Implementation of the search view page for index based searches. */ -public class PDOMSearchViewPage extends AbstractTextSearchViewPage { +public class CSearchViewPage extends AbstractTextSearchViewPage { public static final int LOCATION_COLUMN_INDEX = 0; public static final int DEFINITION_COLUMN_INDEX = 1; public static final int MATCH_COLUMN_INDEX = 2; @@ -70,7 +70,7 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage { private IPDOMSearchContentProvider contentProvider; private boolean fShowEnclosingDefinitions; private ShowEnclosingDefinitionsAction fShowEnclosingDefinitionsAction; - private int[] fColumnWidths = { 300, 150, 300 }; + private final int[] fColumnWidths = { 300, 150, 300 }; private class ShowEnclosingDefinitionsAction extends Action { public ShowEnclosingDefinitionsAction() { @@ -84,11 +84,11 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage { } } - public PDOMSearchViewPage(int supportedLayouts) { + public CSearchViewPage(int supportedLayouts) { super(supportedLayouts); } - public PDOMSearchViewPage() { + public CSearchViewPage() { super(); } @@ -196,9 +196,6 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage { * */ private class SearchViewerComparator extends ViewerComparator { - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ @Override public int compare(Viewer viewer, Object e1, Object e2) { if (e1 instanceof LineSearchElement && e2 instanceof LineSearchElement) { @@ -216,9 +213,6 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage { return super.compare(viewer, e1, e2); } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ViewerComparator#category(java.lang.Object) - */ @Override public int category(Object element) { // place status messages first @@ -260,10 +254,10 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage { @Override protected void configureTreeViewer(TreeViewer viewer) { - contentProvider = new PDOMSearchTreeContentProvider(this); + contentProvider = new CSearchTreeContentProvider(this); viewer.setComparator(new SearchViewerComparator()); - viewer.setContentProvider((PDOMSearchTreeContentProvider)contentProvider); - PDOMSearchTreeLabelProvider innerLabelProvider = new PDOMSearchTreeLabelProvider(this); + viewer.setContentProvider((CSearchTreeContentProvider)contentProvider); + CSearchTreeLabelProvider innerLabelProvider = new CSearchTreeLabelProvider(this); ColoringLabelProvider labelProvider = new ColoringLabelProvider(innerLabelProvider); viewer.setLabelProvider(labelProvider); } @@ -271,9 +265,9 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage { @Override protected void configureTableViewer(TableViewer viewer) { createColumns(viewer); - contentProvider = new PDOMSearchListContentProvider(this); + contentProvider = new CSearchListContentProvider(this); viewer.setComparator(new SearchViewerComparator()); - viewer.setContentProvider((PDOMSearchListContentProvider)contentProvider); + viewer.setContentProvider((CSearchListContentProvider)contentProvider); } @Override @@ -303,7 +297,7 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage { private void createColumns(TableViewer viewer) { for (int i = 0; i < fColumnLabels.length; i++) { TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE); - viewerColumn.setLabelProvider(new PDOMSearchListLabelProvider(this, i)); + viewerColumn.setLabelProvider(new CSearchListLabelProvider(this, i)); TableColumn tableColumn = viewerColumn.getColumn(); tableColumn.setText(fColumnLabels[i]); tableColumn.setWidth(fColumnWidths[i]); @@ -321,16 +315,16 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage { @Override protected void showMatch(Match match, int currentOffset, int currentLength, boolean activate) throws PartInitException { - if (!(match instanceof PDOMSearchMatch)) + if (!(match instanceof CSearchMatch)) return; try { - Object element= ((PDOMSearchMatch)match).getElement(); - IIndexFileLocation ifl= ((PDOMSearchElement)element).getLocation(); + Object element= ((CSearchMatch) match).getElement(); + IIndexFileLocation ifl= ((CSearchElement) element).getLocation(); IPath path = IndexLocationFactory.getPath(ifl); IEditorPart editor = EditorUtility.openInEditor(path, null, activate); if (editor instanceof ITextEditor) { - ITextEditor textEditor = (ITextEditor)editor; + ITextEditor textEditor = (ITextEditor) editor; textEditor.selectAndReveal(currentOffset, currentLength); } } catch (CoreException e) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/HidePolymorphicCalls.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/HidePolymorphicCalls.java index ee64196afd1..281c96db6c0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/HidePolymorphicCalls.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/HidePolymorphicCalls.java @@ -19,7 +19,7 @@ public class HidePolymorphicCalls extends MatchFilter { @Override public boolean filters(Match match) { - return match instanceof PDOMSearchMatch && ((PDOMSearchMatch) match).isPolymorphicCall(); + return match instanceof CSearchMatch && ((CSearchMatch) match).isPolymorphicCall(); } @Override diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/IPDOMSearchContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/IPDOMSearchContentProvider.java index 0433048efb7..2568c41074b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/IPDOMSearchContentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/IPDOMSearchContentProvider.java @@ -41,7 +41,7 @@ public interface IPDOMSearchContentProvider { * TODO: it would be better if IIndexManager told us which projects specifically * were being indexed at the time, so we could annotate per-project whose results are suspicious * (which may be none at all for a given search). - * See the handling of {@link PDOMSearchResult#wasIndexerBusy()}. + * See the handling of {@link CSearchResult#wasIndexerBusy()}. */ static IStatus INCOMPLETE_RESULTS_NODE = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java index e2379e7edf4..75e6c9cb968 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java @@ -31,7 +31,7 @@ import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent; /** * Element representing a line with one ore more matches. */ -public class LineSearchElement extends PDOMSearchElement { +public class LineSearchElement extends CSearchElement { public static final class Match { private final int fOffset; private final int fLength; @@ -39,7 +39,8 @@ public class LineSearchElement extends PDOMSearchElement { private final ICElement fEnclosingElement; private final boolean fIsWriteAccess; - public Match(int offset, int length, boolean isPolymorphicCall, ICElement enclosingElement, boolean isWriteAccess) { + public Match(int offset, int length, boolean isPolymorphicCall, ICElement enclosingElement, + boolean isWriteAccess) { fOffset = offset; fLength = length; fIsPolymorphicCall = isPolymorphicCall; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OpenCSearchPageAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OpenCSearchPageAction.java index fc30d372ca4..fb69e61174e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OpenCSearchPageAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OpenCSearchPageAction.java @@ -44,7 +44,7 @@ public class OpenCSearchPageAction implements IWorkbenchWindowActionDelegate { beep(); return; } - NewSearchUI.openSearchDialog(fWindow, PDOMSearchPage.EXTENSION_ID); + NewSearchUI.openSearchDialog(fWindow, CSearchPage.EXTENSION_ID); } @Override diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ProblemSearchElement.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ProblemSearchElement.java index dcb16808650..d756e565ad4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ProblemSearchElement.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ProblemSearchElement.java @@ -15,7 +15,7 @@ import org.eclipse.cdt.core.index.IIndexFileLocation; /** * Represents a problem in a search. */ -public class ProblemSearchElement extends PDOMSearchElement { +public class ProblemSearchElement extends CSearchElement { private final int fProblemID; private final String fDetail; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/TypeInfoSearchElement.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/TypeInfoSearchElement.java index a9494c744ae..fbdc7e019ff 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/TypeInfoSearchElement.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/TypeInfoSearchElement.java @@ -23,7 +23,7 @@ import org.eclipse.cdt.internal.core.browser.ASTTypeInfo; /** * Represents a a c/c++-entity in a search. */ -public class TypeInfoSearchElement extends PDOMSearchElement { +public class TypeInfoSearchElement extends CSearchElement { private final ITypeInfo typeInfo; public TypeInfoSearchElement(IIndex index, IIndexName name, IIndexBinding binding) throws CoreException { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java index 702d14777e1..8ed815fc290 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java @@ -27,9 +27,9 @@ import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.search.CSearchMessages; -import org.eclipse.cdt.internal.ui.search.PDOMSearchElementQuery; -import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery; -import org.eclipse.cdt.internal.ui.search.PDOMSearchTextSelectionQuery; +import org.eclipse.cdt.internal.ui.search.CSearchElementQuery; +import org.eclipse.cdt.internal.ui.search.CSearchQuery; +import org.eclipse.cdt.internal.ui.search.CSearchTextSelectionQuery; import org.eclipse.cdt.internal.ui.text.CWordFinder; @@ -76,12 +76,12 @@ public abstract class FindAction extends SelectionParseAction { NewSearchUI.runQueryInBackground(searchJob); } - protected PDOMSearchQuery createQuery(ISourceReference object) { - return new PDOMSearchElementQuery(getScope(), object, getLimitTo()); + protected CSearchQuery createQuery(ISourceReference object) { + return new CSearchElementQuery(getScope(), object, getLimitTo()); } - protected PDOMSearchQuery createQuery(ICElement element, ITextSelection selNode) { - return new PDOMSearchTextSelectionQuery(getScope(), + protected CSearchQuery createQuery(ICElement element, ITextSelection selNode) { + return new CSearchTextSelectionQuery(getScope(), (ITranslationUnit) element, selNode, getLimitTo()); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsAction.java index db41f4fdb4e..9928a0f7866 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsAction.java @@ -14,7 +14,7 @@ package org.eclipse.cdt.internal.ui.search.actions; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.search.CSearchMessages; -import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery; +import org.eclipse.cdt.internal.ui.search.CSearchQuery; import org.eclipse.ui.IWorkbenchSite; @@ -56,6 +56,6 @@ public class FindDeclarationsAction extends FindAction { @Override protected int getLimitTo() { - return PDOMSearchQuery.FIND_DECLARATIONS_DEFINITIONS; + return CSearchQuery.FIND_DECLARATIONS_DEFINITIONS; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsInWorkingSetAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsInWorkingSetAction.java index 602a5600ef3..fa245ac2532 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsInWorkingSetAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsInWorkingSetAction.java @@ -16,7 +16,7 @@ import org.eclipse.ui.IWorkingSet; import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.search.CSearchMessages; -import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery; +import org.eclipse.cdt.internal.ui.search.CSearchQuery; public class FindDeclarationsInWorkingSetAction extends FindInWorkingSetAction { @@ -36,6 +36,6 @@ public class FindDeclarationsInWorkingSetAction extends FindInWorkingSetAction { @Override protected int getLimitTo() { - return PDOMSearchQuery.FIND_DECLARATIONS_DEFINITIONS; + return CSearchQuery.FIND_DECLARATIONS_DEFINITIONS; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsProjectAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsProjectAction.java index f5833ec80e9..b6d71e7c5eb 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsProjectAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsProjectAction.java @@ -15,7 +15,7 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.search.CSearchMessages; -import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery; +import org.eclipse.cdt.internal.ui.search.CSearchQuery; import org.eclipse.core.resources.IResource; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; @@ -73,7 +73,7 @@ public class FindDeclarationsProjectAction extends FindAction { @Override protected int getLimitTo() { - return PDOMSearchQuery.FIND_DECLARATIONS_DEFINITIONS; + return CSearchQuery.FIND_DECLARATIONS_DEFINITIONS; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsAction.java index 96f49241490..b1432f98eb3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsAction.java @@ -13,7 +13,7 @@ package org.eclipse.cdt.internal.ui.search.actions; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.search.CSearchMessages; -import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery; +import org.eclipse.cdt.internal.ui.search.CSearchQuery; import org.eclipse.ui.IWorkbenchSite; public class FindRefsAction extends FindAction { @@ -54,6 +54,6 @@ public class FindRefsAction extends FindAction { @Override protected int getLimitTo() { - return PDOMSearchQuery.FIND_REFERENCES; + return CSearchQuery.FIND_REFERENCES; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsInWorkingSetAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsInWorkingSetAction.java index 78516f9062d..4e1247b2395 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsInWorkingSetAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsInWorkingSetAction.java @@ -16,7 +16,7 @@ import org.eclipse.ui.IWorkingSet; import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.search.CSearchMessages; -import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery; +import org.eclipse.cdt.internal.ui.search.CSearchQuery; public class FindRefsInWorkingSetAction extends FindInWorkingSetAction { @@ -36,6 +36,6 @@ public class FindRefsInWorkingSetAction extends FindInWorkingSetAction { @Override protected int getLimitTo() { - return PDOMSearchQuery.FIND_REFERENCES; + return CSearchQuery.FIND_REFERENCES; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsProjectAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsProjectAction.java index 979813eeeb8..3c20aab994e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsProjectAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsProjectAction.java @@ -15,7 +15,7 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.search.CSearchMessages; -import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery; +import org.eclipse.cdt.internal.ui.search.CSearchQuery; import org.eclipse.core.resources.IResource; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; @@ -73,7 +73,7 @@ public class FindRefsProjectAction extends FindAction { @Override protected int getLimitTo() { - return PDOMSearchQuery.FIND_REFERENCES; + return CSearchQuery.FIND_REFERENCES; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesProjectAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesProjectAction.java index 38b6d50a599..e6c6f2ce55d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesProjectAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesProjectAction.java @@ -27,7 +27,7 @@ import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.internal.ui.actions.SelectionConverter; import org.eclipse.cdt.internal.ui.search.CSearchMessages; -import org.eclipse.cdt.internal.ui.search.PDOMSearchUnresolvedIncludesQuery; +import org.eclipse.cdt.internal.ui.search.CSearchUnresolvedIncludesQuery; import org.eclipse.cdt.internal.ui.util.StatusLineHandler; /** @@ -57,7 +57,7 @@ public class FindUnresolvedIncludesProjectAction implements IObjectActionDelegat return; } - ISearchQuery searchJob= new PDOMSearchUnresolvedIncludesQuery(projects.toArray(new ICProject[projects.size()])); + ISearchQuery searchJob= new CSearchUnresolvedIncludesQuery(projects.toArray(new ICProject[projects.size()])); StatusLineHandler.clearStatusLine(fSite); NewSearchUI.activateSearchResultView();