mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 22:22:11 +02:00
Declare utility methods static.
This commit is contained in:
parent
99fa95b7cd
commit
ecd14f70f8
16 changed files with 61 additions and 79 deletions
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<ITranslationUnit, IASTTranslationUnit> cachedASTs = new HashMap<ITranslationUnit, IASTTranslationUnit>();
|
||||
HashMap<ITranslationUnit, ASTRewrite> cachedRewrites = new HashMap<ITranslationUnit, ASTRewrite>();
|
||||
for (IIndexName iname : declarations) {
|
||||
ITranslationUnit declTU = utils.getTranslationUnitFromIndexName(iname);
|
||||
ITranslationUnit declTU = CxxAstUtils.getTranslationUnitFromIndexName(iname);
|
||||
ASTRewrite rewrite;
|
||||
IASTTranslationUnit declAST;
|
||||
if (!cachedASTs.containsKey(declTU)) {
|
||||
|
|
|
@ -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<ICPPClassType, ICPPMethod[]> pureVirtualMethodsCache = new HashMap<ICPPClassType, ICPPMethod[]>();
|
||||
private final HashMap<ICPPClassType, ICPPMethod[]> pureVirtualMethodsCache = new HashMap<ICPPClassType, ICPPMethod[]>();
|
||||
|
||||
@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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<ITranslationUnit, IASTTranslationUnit> astCache = new HashMap<ITranslationUnit, IASTTranslationUnit>();
|
||||
|
@ -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$
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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++;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue