mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
Removed a redundant method.
This commit is contained in:
parent
68b5958f0c
commit
75e0f1868f
9 changed files with 72 additions and 79 deletions
|
@ -7,8 +7,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Schwab & Thomas Kallenberg - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
* Martin Schwab & Thomas Kallenberg - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
|
||||
|
||||
|
@ -26,6 +26,8 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* Given a selection and a translation unit, this class finds a
|
||||
* ICPPASTFunctionDeclarator if possible. Special case: Nested local functions
|
||||
|
@ -104,6 +106,6 @@ public class DeclaratorFinder {
|
|||
}
|
||||
|
||||
private boolean isPartOfAStatement(IASTNode node) {
|
||||
return ToggleNodeHelper.getAncestorOfType(node, IASTStatement.class) != null;
|
||||
return CPPVisitor.findAncestorWithType(node, IASTStatement.class) != null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Schwab & Thomas Kallenberg - initial API and implementation
|
||||
* Martin Schwab & Thomas Kallenberg - initial API and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
|
||||
|
||||
|
@ -27,18 +27,19 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
|||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.refactoring.Container;
|
||||
|
||||
public class InsertionPointFinder {
|
||||
|
||||
private static ArrayList<ICPPASTFunctionDeclarator> allafterdeclarations;
|
||||
private static ArrayList<ICPPASTFunctionDefinition> alldefinitionsoutside;
|
||||
private static IASTDeclaration position;
|
||||
|
||||
public static IASTDeclaration findInsertionPoint(IASTTranslationUnit classunit, IASTTranslationUnit functiondefunit, IASTFunctionDeclarator funcdecl) {
|
||||
public static IASTDeclaration findInsertionPoint(IASTTranslationUnit classunit,
|
||||
IASTTranslationUnit functiondefunit, IASTFunctionDeclarator funcDecl) {
|
||||
position = null;
|
||||
findAllDeclarationsAfterInClass(classunit, funcdecl);
|
||||
findAllDeclarationsAfterInClass(classunit, funcDecl);
|
||||
findAllDefinitionsoutSideClass(functiondefunit);
|
||||
findRightPlace();
|
||||
return position;
|
||||
|
@ -54,38 +55,39 @@ public class InsertionPointFinder {
|
|||
if (def.getDeclarator().getName() instanceof ICPPASTQualifiedName) {
|
||||
ICPPASTQualifiedName qname = (ICPPASTQualifiedName) def.getDeclarator().getName();
|
||||
def_name = qname.getNames()[1].toString();
|
||||
}
|
||||
else if (def.getDeclarator().getName() instanceof CPPASTName) {
|
||||
} else if (def.getDeclarator().getName() instanceof CPPASTName) {
|
||||
def_name = def.getDeclarator().getName().toString();
|
||||
}
|
||||
|
||||
if (decl_name.equals(def_name)) {
|
||||
if (def.getParent() != null && def.getParent() instanceof ICPPASTTemplateDeclaration)
|
||||
if (def.getParent() != null && def.getParent() instanceof ICPPASTTemplateDeclaration) {
|
||||
position = (IASTDeclaration) def.getParent();
|
||||
else
|
||||
} else {
|
||||
position = def;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void findAllDeclarationsAfterInClass(IASTTranslationUnit classunit, IASTFunctionDeclarator funcdecl) {
|
||||
private static void findAllDeclarationsAfterInClass(IASTTranslationUnit classunit,
|
||||
IASTFunctionDeclarator funcDecl) {
|
||||
ICPPASTCompositeTypeSpecifier klass = getklass(classunit);
|
||||
if (klass != null)
|
||||
allafterdeclarations = getDeclarationsInClass(klass, funcdecl);
|
||||
allafterdeclarations = getDeclarationsInClass(klass, funcDecl);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param unit the translation unit where to find the definitions
|
||||
* @param ast the translation unit where to find the definitions
|
||||
*/
|
||||
private static void findAllDefinitionsoutSideClass(IASTTranslationUnit unit) {
|
||||
private static void findAllDefinitionsoutSideClass(IASTTranslationUnit ast) {
|
||||
final ArrayList<ICPPASTFunctionDefinition> definitions = new ArrayList<ICPPASTFunctionDefinition>();
|
||||
if (unit == null) {
|
||||
if (ast == null) {
|
||||
alldefinitionsoutside = definitions;
|
||||
return;
|
||||
}
|
||||
unit.accept(
|
||||
ast.accept(
|
||||
new ASTVisitor() {
|
||||
{
|
||||
shouldVisitDeclarations = true;
|
||||
|
@ -94,8 +96,10 @@ public class InsertionPointFinder {
|
|||
@Override
|
||||
public int visit(IASTDeclaration declaration) {
|
||||
if (declaration instanceof ICPPASTFunctionDefinition) {
|
||||
if (declaration.getParent() != null && ToggleNodeHelper.getAncestorOfType(declaration, CPPASTCompositeTypeSpecifier.class) != null)
|
||||
return PROCESS_CONTINUE;
|
||||
if (declaration.getParent() != null &&
|
||||
CPPVisitor.findAncestorWithType(declaration, CPPASTCompositeTypeSpecifier.class) != null) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
definitions.add((ICPPASTFunctionDefinition) declaration);
|
||||
}
|
||||
return super.visit(declaration);
|
||||
|
@ -108,7 +112,7 @@ public class InsertionPointFinder {
|
|||
final ArrayList<ICPPASTFunctionDeclarator> declarations = new ArrayList<ICPPASTFunctionDeclarator>();
|
||||
|
||||
klass.accept(
|
||||
new ASTVisitor() {
|
||||
new ASTVisitor() {
|
||||
{
|
||||
shouldVisitDeclarators = true;
|
||||
}
|
||||
|
@ -126,7 +130,7 @@ public class InsertionPointFinder {
|
|||
}
|
||||
return super.visit(declarator);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return declarations;
|
||||
}
|
||||
|
@ -136,19 +140,19 @@ public class InsertionPointFinder {
|
|||
|
||||
unit.accept(
|
||||
new ASTVisitor() {
|
||||
{
|
||||
shouldVisitDeclSpecifiers = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(IASTDeclSpecifier declSpec) {
|
||||
if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
|
||||
result.setObject((ICPPASTCompositeTypeSpecifier) declSpec);
|
||||
return PROCESS_ABORT;
|
||||
{
|
||||
shouldVisitDeclSpecifiers = true;
|
||||
}
|
||||
return super.visit(declSpec);
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public int visit(IASTDeclSpecifier declSpec) {
|
||||
if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
|
||||
result.setObject((ICPPASTCompositeTypeSpecifier) declSpec);
|
||||
return PROCESS_ABORT;
|
||||
}
|
||||
return super.visit(declSpec);
|
||||
}
|
||||
});
|
||||
return result.getObject();
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Schwab & Thomas Kallenberg - initial API and implementation
|
||||
* Martin Schwab & Thomas Kallenberg - initial API and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
|
||||
|
||||
|
@ -28,6 +28,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
|
||||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
|
||||
|
||||
public class ToggleFromClassToInHeaderStrategy implements IToggleRefactoringStrategy {
|
||||
|
@ -42,8 +44,7 @@ public class ToggleFromClassToInHeaderStrategy implements IToggleRefactoringStra
|
|||
}
|
||||
|
||||
private boolean isInClass(IASTNode node) {
|
||||
return ToggleNodeHelper.getAncestorOfType(node,
|
||||
ICPPASTCompositeTypeSpecifier.class) != null;
|
||||
return CPPVisitor.findAncestorWithType(node, ICPPASTCompositeTypeSpecifier.class) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -79,8 +80,7 @@ public class ToggleFromClassToInHeaderStrategy implements IToggleRefactoringStra
|
|||
}
|
||||
|
||||
private IASTNode getParentNamespace() {
|
||||
IASTNode parentNamespace = ToggleNodeHelper.getAncestorOfType(
|
||||
context.getDefinition(), ICPPASTNamespaceDefinition.class);
|
||||
IASTNode parentNamespace = CPPVisitor.findAncestorWithType(context.getDefinition(), ICPPASTNamespaceDefinition.class);
|
||||
if (parentNamespace == null)
|
||||
parentNamespace = context.getDefinitionUnit();
|
||||
return parentNamespace;
|
||||
|
|
|
@ -28,20 +28,19 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
|||
import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
|
||||
import org.eclipse.cdt.core.dom.rewrite.ASTRewrite.CommentPosition;
|
||||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTLiteralNode;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
|
||||
import org.eclipse.cdt.internal.ui.refactoring.utils.CPPASTAllVisitor;
|
||||
|
||||
public class ToggleFromImplementationToHeaderOrClassStrategy implements IToggleRefactoringStrategy {
|
||||
|
||||
private ToggleRefactoringContext context;
|
||||
private TextEditGroup infoText;
|
||||
private IASTTranslationUnit other_tu;
|
||||
private ASTLiteralNode includenode;
|
||||
|
||||
public ToggleFromImplementationToHeaderOrClassStrategy(
|
||||
ToggleRefactoringContext context) {
|
||||
public ToggleFromImplementationToHeaderOrClassStrategy(ToggleRefactoringContext context) {
|
||||
this.context = context;
|
||||
this.infoText = new TextEditGroup(Messages.EditGroupName);
|
||||
}
|
||||
|
@ -89,9 +88,8 @@ public class ToggleFromImplementationToHeaderOrClassStrategy implements IToggleR
|
|||
private void addDefinitionToHeader(ModificationCollector modifications, List<IASTComment> leadingComments) {
|
||||
ASTRewrite headerRewrite = modifications.rewriterForTranslationUnit(other_tu);
|
||||
IASTFunctionDefinition newDefinition = ToggleNodeHelper.createFunctionSignatureWithEmptyBody(
|
||||
context
|
||||
.getDefinition().getDeclSpecifier().copy(CopyStyle.withLocations), context.getDefinition()
|
||||
.getDeclarator().copy(CopyStyle.withLocations),
|
||||
context.getDefinition().getDeclSpecifier().copy(CopyStyle.withLocations),
|
||||
context.getDefinition().getDeclarator().copy(CopyStyle.withLocations),
|
||||
context.getDefinition().copy(CopyStyle.withLocations));
|
||||
newDefinition.setParent(other_tu);
|
||||
headerRewrite.insertBefore(other_tu.getTranslationUnit(), null, newDefinition, infoText);
|
||||
|
@ -105,8 +103,7 @@ context
|
|||
ASTRewrite headerRewrite = modifications.rewriterForTranslationUnit(
|
||||
context.getDeclarationUnit());
|
||||
IASTFunctionDefinition newDefinition = ToggleNodeHelper.createInClassDefinition(
|
||||
context.getDeclaration(), context.getDefinition(),
|
||||
context.getDeclarationUnit());
|
||||
context.getDeclaration(), context.getDefinition(), context.getDeclarationUnit());
|
||||
newDefinition.setParent(getParent());
|
||||
restoreBody(headerRewrite, newDefinition, modifications);
|
||||
headerRewrite.replace(context.getDeclaration().getParent(), newDefinition, infoText);
|
||||
|
@ -116,13 +113,12 @@ context
|
|||
}
|
||||
|
||||
private IASTNode getParent() {
|
||||
IASTNode parent = ToggleNodeHelper.getAncestorOfType(context.getDefinition(),
|
||||
IASTNode parent = CPPVisitor.findAncestorWithType(context.getDefinition(),
|
||||
ICPPASTCompositeTypeSpecifier.class);
|
||||
IASTNode parentnode = null;
|
||||
if (parent != null) {
|
||||
parentnode = parent;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
parentnode =context.getDeclarationUnit();
|
||||
}
|
||||
return parentnode;
|
||||
|
@ -133,7 +129,8 @@ context
|
|||
IASTFunctionDefinition oldDefinition = context.getDefinition();
|
||||
newDefinition.setBody(oldDefinition.getBody().copy(CopyStyle.withLocations));
|
||||
|
||||
if (newDefinition instanceof ICPPASTFunctionWithTryBlock && oldDefinition instanceof ICPPASTFunctionWithTryBlock) {
|
||||
if (newDefinition instanceof ICPPASTFunctionWithTryBlock &&
|
||||
oldDefinition instanceof ICPPASTFunctionWithTryBlock) {
|
||||
ICPPASTFunctionWithTryBlock newTryDef = (ICPPASTFunctionWithTryBlock) newDefinition;
|
||||
ICPPASTFunctionWithTryBlock oldTryDef = (ICPPASTFunctionWithTryBlock) oldDefinition;
|
||||
for (ICPPASTCatchHandler handler : oldTryDef.getCatchHandlers()) {
|
||||
|
@ -161,12 +158,11 @@ context
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void removeDefinitionFromImplementation(ASTRewrite implast) {
|
||||
ICPPASTNamespaceDefinition ns = ToggleNodeHelper.getAncestorOfType(
|
||||
context.getDefinition(), ICPPASTNamespaceDefinition.class);
|
||||
ICPPASTNamespaceDefinition ns =
|
||||
CPPVisitor.findAncestorWithType(context.getDefinition(), ICPPASTNamespaceDefinition.class);
|
||||
if (ns != null && isSingleElementInNamespace(ns, context.getDefinition())) {
|
||||
implast.remove(ns, infoText);
|
||||
} else {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Schwab & Thomas Kallenberg - initial API and implementation
|
||||
* Martin Schwab & Thomas Kallenberg - initial API and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
|
||||
|
||||
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
|
|||
import org.eclipse.cdt.core.dom.rewrite.ASTRewrite.CommentPosition;
|
||||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
|
||||
|
||||
|
@ -55,8 +56,7 @@ public class ToggleFromInHeaderToClassStrategy implements IToggleRefactoringStra
|
|||
if (declarator.getName() instanceof ICPPASTQualifiedName) {
|
||||
declarator = backup;
|
||||
}
|
||||
return (ToggleNodeHelper.getAncestorOfType(declarator,
|
||||
IASTCompositeTypeSpecifier.class) == null);
|
||||
return (CPPVisitor.findAncestorWithType(declarator, IASTCompositeTypeSpecifier.class) == null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -102,8 +102,7 @@ public class ToggleFromInHeaderToClassStrategy implements IToggleRefactoringStra
|
|||
}
|
||||
}
|
||||
|
||||
IASTNode parent = ToggleNodeHelper.getAncestorOfType(context.getDefinition(),
|
||||
ICPPASTCompositeTypeSpecifier.class);
|
||||
IASTNode parent = CPPVisitor.findAncestorWithType(context.getDefinition(), ICPPASTCompositeTypeSpecifier.class);
|
||||
if (parent != null) {
|
||||
newDefinition.setParent(parent);
|
||||
}
|
||||
|
@ -115,8 +114,7 @@ public class ToggleFromInHeaderToClassStrategy implements IToggleRefactoringStra
|
|||
|
||||
private ASTRewrite replaceDeclarationWithDefinition(ASTRewrite rewriter,
|
||||
IASTFunctionDefinition newDefinition) {
|
||||
IASTSimpleDeclaration fullDeclaration = ToggleNodeHelper.getAncestorOfType(
|
||||
context.getDeclaration(), CPPASTSimpleDeclaration.class);
|
||||
IASTSimpleDeclaration fullDeclaration = CPPVisitor.findAncestorWithType(context.getDeclaration(), CPPASTSimpleDeclaration.class);
|
||||
ASTRewrite newRewriter = rewriter.replace(fullDeclaration, newDefinition, infoText);
|
||||
return newRewriter;
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.eclipse.cdt.core.dom.rewrite.ASTRewrite.CommentPosition;
|
|||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTLiteralNode;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.refactoring.Container;
|
||||
|
@ -261,7 +262,7 @@ public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefact
|
|||
if (toquery == null) {
|
||||
toquery = context.getDefinition();
|
||||
}
|
||||
return ToggleNodeHelper.getAncestorOfType(toquery, ICPPASTNamespaceDefinition.class);
|
||||
return CPPVisitor.findAncestorWithType(toquery, ICPPASTNamespaceDefinition.class);
|
||||
}
|
||||
|
||||
private IASTNode findInsertionPoint(IASTNode insertionParent, IASTTranslationUnit unit) {
|
||||
|
|
|
@ -64,6 +64,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateId;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTypeId;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.model.TranslationUnit;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
|
||||
|
@ -461,15 +462,4 @@ public class ToggleNodeHelper extends NodeHelper {
|
|||
}
|
||||
return comments;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getAncestorOfType(IASTNode node, Class<?> T) {
|
||||
while (node != null) {
|
||||
if (T.isInstance(node)) {
|
||||
return (T) node;
|
||||
}
|
||||
node = node.getParent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ import org.eclipse.cdt.core.index.IIndexName;
|
|||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.refactoring.IndexToASTNameHelper;
|
||||
import org.eclipse.cdt.internal.ui.refactoring.utils.TranslationUnitHelper;
|
||||
|
||||
|
@ -173,11 +175,11 @@ public class ToggleRefactoringContext {
|
|||
if (node instanceof IASTSimpleDeclaration) {
|
||||
return (IASTFunctionDeclarator) ((IASTSimpleDeclaration) node).getDeclarators()[0];
|
||||
}
|
||||
return ToggleNodeHelper.getAncestorOfType(node, IASTFunctionDeclarator.class);
|
||||
return CPPVisitor.findAncestorWithType(node, IASTFunctionDeclarator.class);
|
||||
}
|
||||
|
||||
private IASTFunctionDefinition findFunctionDefinition(IASTNode node) {
|
||||
return ToggleNodeHelper.getAncestorOfType(node, IASTFunctionDefinition.class);
|
||||
return CPPVisitor.findAncestorWithType(node, IASTFunctionDefinition.class);
|
||||
}
|
||||
|
||||
public void setDefaultAnswer(boolean defaultAnswer) {
|
||||
|
|
|
@ -7,13 +7,15 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Schwab & Thomas Kallenberg - initial API and implementation
|
||||
* Martin Schwab & Thomas Kallenberg - initial API and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
public class ToggleStrategyFactory {
|
||||
|
||||
private ToggleRefactoringContext context;
|
||||
|
@ -43,12 +45,10 @@ public class ToggleStrategyFactory {
|
|||
|
||||
private boolean isInClassSituation() {
|
||||
return (context.getDeclaration() == null) &&
|
||||
(ToggleNodeHelper.getAncestorOfType(context.getDefinition(),
|
||||
IASTCompositeTypeSpecifier.class) != null);
|
||||
(CPPVisitor.findAncestorWithType(context.getDefinition(), IASTCompositeTypeSpecifier.class) != null);
|
||||
}
|
||||
|
||||
private boolean isTemplateSituation() {
|
||||
return (ToggleNodeHelper.getAncestorOfType(context.getDefinition(),
|
||||
ICPPASTTemplateDeclaration.class) != null);
|
||||
return (CPPVisitor.findAncestorWithType(context.getDefinition(), ICPPASTTemplateDeclaration.class) != null);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue