mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-10 09:45:39 +02:00
Bug 162806: Deprecate IASTTranslationUnit.getParserLanguage().
This commit is contained in:
parent
9f1f076635
commit
4c8a4d2d74
9 changed files with 62 additions and 71 deletions
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %pluginName
|
Bundle-Name: %pluginName
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.core; singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.core; singleton:=true
|
||||||
Bundle-Version: 5.2.0.qualifier
|
Bundle-Version: 5.2.100.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.core.CCorePlugin
|
Bundle-Activator: org.eclipse.cdt.core.CCorePlugin
|
||||||
Bundle-Vendor: %providerName
|
Bundle-Vendor: %providerName
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
package org.eclipse.cdt.core.dom;
|
package org.eclipse.cdt.core.dom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a linkage in the AST or the index.
|
* Represents a linkage under which bindings are stored in the index.
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*
|
*
|
||||||
* @noextend This interface is not intended to be extended by clients.
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
|
|
|
@ -230,8 +230,12 @@ public interface IASTTranslationUnit extends IASTDeclarationListOwner, IAdaptabl
|
||||||
* @param offset
|
* @param offset
|
||||||
*/
|
*/
|
||||||
public String getContainingFilename(int offset);
|
public String getContainingFilename(int offset);
|
||||||
|
|
||||||
public ParserLanguage getParserLanguage();
|
/**
|
||||||
|
* @deprecated don't use it.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public ParserLanguage getParserLanguage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Index associated with this translation unit.
|
* Returns the Index associated with this translation unit.
|
||||||
|
|
|
@ -87,6 +87,7 @@ public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbig
|
||||||
return CVisitor.getReferences(this, binding);
|
return CVisitor.getReferences(this, binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public ParserLanguage getParserLanguage() {
|
public ParserLanguage getParserLanguage() {
|
||||||
return ParserLanguage.C;
|
return ParserLanguage.C;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,11 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
import org.eclipse.cdt.core.dom.ILinkage;
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
|
@ -131,6 +131,7 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
||||||
return fBinding;
|
return fBinding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public ParserLanguage getParserLanguage() {
|
public ParserLanguage getParserLanguage() {
|
||||||
return ParserLanguage.CPP;
|
return ParserLanguage.CPP;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,22 +33,17 @@ import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.INodeFactory;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.c.CASTPointer;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTArrayDeclarator;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarator;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTParameterDeclaration;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTReferenceOperator;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriter;
|
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriter;
|
||||||
|
|
||||||
public class NodeContainer {
|
public class NodeContainer {
|
||||||
|
@ -130,58 +125,48 @@ public class NodeContainer {
|
||||||
return getReferencesAfterSelection().size() > 0;
|
return getReferencesAfterSelection().size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPASTParameterDeclaration getICPPASTParameterDeclaration(
|
public IASTParameterDeclaration getParameterDeclaration(boolean isReference,
|
||||||
boolean isReference, ParserLanguage lang) {
|
INodeFactory nodeFactory) {
|
||||||
ICPPASTParameterDeclaration para = new CPPASTParameterDeclaration();
|
IASTDeclarator sourceDeclarator = (IASTDeclarator) getDeclaration().getParent();
|
||||||
IASTDeclarator sourceDeclarator = (IASTDeclarator) getDeclaration()
|
|
||||||
.getParent();
|
|
||||||
|
|
||||||
|
IASTDeclSpecifier declSpec= null;
|
||||||
|
IASTDeclarator declarator= null;
|
||||||
|
|
||||||
if (sourceDeclarator.getParent() instanceof IASTSimpleDeclaration) {
|
if (sourceDeclarator.getParent() instanceof IASTSimpleDeclaration) {
|
||||||
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) sourceDeclarator
|
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) sourceDeclarator.getParent();
|
||||||
.getParent();
|
declSpec= decl.getDeclSpecifier().copy();
|
||||||
para.setDeclSpecifier(decl.getDeclSpecifier().copy());
|
|
||||||
} else if (sourceDeclarator.getParent() instanceof IASTParameterDeclaration) {
|
} else if (sourceDeclarator.getParent() instanceof IASTParameterDeclaration) {
|
||||||
IASTParameterDeclaration decl = (IASTParameterDeclaration) sourceDeclarator
|
IASTParameterDeclaration decl = (IASTParameterDeclaration) sourceDeclarator.getParent();
|
||||||
.getParent();
|
declSpec= decl.getDeclSpecifier().copy();
|
||||||
para.setDeclSpecifier(decl.getDeclSpecifier().copy());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTDeclarator declarator;
|
IASTName name= nodeFactory.newName(getDeclaration().toCharArray());
|
||||||
if (sourceDeclarator instanceof IASTArrayDeclarator) {
|
if (sourceDeclarator instanceof IASTArrayDeclarator) {
|
||||||
IASTArrayDeclarator arrDeclarator = (IASTArrayDeclarator) sourceDeclarator;
|
IASTArrayDeclarator arrDeclarator = (IASTArrayDeclarator) sourceDeclarator;
|
||||||
declarator = new CPPASTArrayDeclarator();
|
IASTArrayDeclarator arrayDtor = nodeFactory.newArrayDeclarator(name);
|
||||||
IASTArrayModifier[] arrayModifiers = arrDeclarator
|
IASTArrayModifier[] arrayModifiers = arrDeclarator.getArrayModifiers();
|
||||||
.getArrayModifiers();
|
|
||||||
for (IASTArrayModifier arrayModifier : arrayModifiers) {
|
for (IASTArrayModifier arrayModifier : arrayModifiers) {
|
||||||
((IASTArrayDeclarator) declarator)
|
arrayDtor.addArrayModifier(arrayModifier.copy());
|
||||||
.addArrayModifier(arrayModifier.copy());
|
|
||||||
}
|
}
|
||||||
|
declarator= arrayDtor;
|
||||||
} else {
|
} else {
|
||||||
declarator = new CPPASTDeclarator();
|
declarator = nodeFactory.newDeclarator(name);
|
||||||
}
|
}
|
||||||
declarator.setName(new CPPASTName(getDeclaration().toCharArray()));
|
for (IASTPointerOperator pointerOp : sourceDeclarator.getPointerOperators()) {
|
||||||
for (IASTPointerOperator pointerOp : sourceDeclarator
|
|
||||||
.getPointerOperators()) {
|
|
||||||
declarator.addPointerOperator(pointerOp.copy());
|
declarator.addPointerOperator(pointerOp.copy());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isReference && !hasReferenceOperartor(declarator)) {
|
if (isReference && !hasReferenceOperartor(declarator)) {
|
||||||
switch (lang) {
|
if (nodeFactory instanceof ICPPNodeFactory) {
|
||||||
case C:
|
declarator.addPointerOperator(((ICPPNodeFactory) nodeFactory).newReferenceOperator(false));
|
||||||
declarator.addPointerOperator(new CASTPointer());
|
} else {
|
||||||
break;
|
declarator.addPointerOperator(nodeFactory.newPointer());
|
||||||
case CPP:
|
|
||||||
declarator.addPointerOperator(new CPPASTReferenceOperator(false));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declarator.setNestedDeclarator(sourceDeclarator
|
declarator.setNestedDeclarator(sourceDeclarator.getNestedDeclarator());
|
||||||
.getNestedDeclarator());
|
|
||||||
para.setDeclarator(declarator);
|
|
||||||
|
|
||||||
return para;
|
return nodeFactory.newParameterDeclaration(declSpec, declarator);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasReferenceOperartor(IASTDeclarator declarator) {
|
public boolean hasReferenceOperartor(IASTDeclarator declarator) {
|
||||||
|
|
|
@ -44,10 +44,12 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.INodeFactory;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
|
||||||
import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
|
import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
|
||||||
|
@ -56,7 +58,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTEqualsInitializer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNamespaceDefinition;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclSpecifier;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethod;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethod;
|
||||||
|
@ -407,9 +408,9 @@ public class ExtractConstantRefactoring extends CRefactoring {
|
||||||
private IASTDeclaration getConstNodesGlobal(String newName){
|
private IASTDeclaration getConstNodesGlobal(String newName){
|
||||||
IASTSimpleDeclaration simple = getConstNodes(newName);
|
IASTSimpleDeclaration simple = getConstNodes(newName);
|
||||||
|
|
||||||
if(unit.getParserLanguage().isCPP()){
|
INodeFactory factory= unit.getASTNodeFactory();
|
||||||
ICPPASTNamespaceDefinition namespace = new CPPASTNamespaceDefinition();
|
if (factory instanceof ICPPNodeFactory) {
|
||||||
namespace.setName(new CPPASTName());
|
ICPPASTNamespaceDefinition namespace = ((ICPPNodeFactory) factory).newNamespaceDefinition(new CPPASTName());
|
||||||
namespace.addDeclaration(simple);
|
namespace.addDeclaration(simple);
|
||||||
return namespace;
|
return namespace;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,8 @@ import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Vector;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
@ -104,9 +104,9 @@ import org.eclipse.cdt.internal.ui.refactoring.CRefactoring;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription;
|
import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.Container;
|
import org.eclipse.cdt.internal.ui.refactoring.Container;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.MethodContext;
|
import org.eclipse.cdt.internal.ui.refactoring.MethodContext;
|
||||||
|
import org.eclipse.cdt.internal.ui.refactoring.MethodContext.ContextType;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
|
import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.NodeContainer;
|
import org.eclipse.cdt.internal.ui.refactoring.NodeContainer;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.MethodContext.ContextType;
|
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation;
|
import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.utils.ASTHelper;
|
import org.eclipse.cdt.internal.ui.refactoring.utils.ASTHelper;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.utils.CPPASTAllVisitor;
|
import org.eclipse.cdt.internal.ui.refactoring.utils.CPPASTAllVisitor;
|
||||||
|
@ -660,7 +660,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
|
||||||
IASTStandardFunctionDeclarator createdFunctionDeclarator = extractedFunctionConstructionHelper
|
IASTStandardFunctionDeclarator createdFunctionDeclarator = extractedFunctionConstructionHelper
|
||||||
.createFunctionDeclarator(qname, info.getDeclarator(), info
|
.createFunctionDeclarator(qname, info.getDeclarator(), info
|
||||||
.getReturnVariable(), container.getNodesToWrite(), info
|
.getReturnVariable(), container.getNodesToWrite(), info
|
||||||
.getAllUsedNames(), unit.getParserLanguage());
|
.getAllUsedNames(), unit.getASTNodeFactory());
|
||||||
func.setDeclarator(createdFunctionDeclarator);
|
func.setDeclarator(createdFunctionDeclarator);
|
||||||
|
|
||||||
IASTCompoundStatement compound = new CPPASTCompoundStatement();
|
IASTCompoundStatement compound = new CPPASTCompoundStatement();
|
||||||
|
@ -863,7 +863,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
|
||||||
IASTStandardFunctionDeclarator declarator = extractedFunctionConstructionHelper
|
IASTStandardFunctionDeclarator declarator = extractedFunctionConstructionHelper
|
||||||
.createFunctionDeclarator(name, info.getDeclarator(), info
|
.createFunctionDeclarator(name, info.getDeclarator(), info
|
||||||
.getReturnVariable(), container.getNodesToWrite(), info
|
.getReturnVariable(), container.getNodesToWrite(), info
|
||||||
.getAllUsedNames(), unit.getParserLanguage());
|
.getAllUsedNames(), unit.getASTNodeFactory());
|
||||||
simpleDecl.addDeclarator(declarator);
|
simpleDecl.addDeclarator(declarator);
|
||||||
return simpleDecl;
|
return simpleDecl;
|
||||||
}
|
}
|
||||||
|
@ -875,10 +875,10 @@ public class ExtractFunctionRefactoring extends CRefactoring {
|
||||||
((ICPPASTDeclSpecifier)declSpec).setVirtual(true);
|
((ICPPASTDeclSpecifier)declSpec).setVirtual(true);
|
||||||
}
|
}
|
||||||
simpleDecl.setParent(unit);
|
simpleDecl.setParent(unit);
|
||||||
ICPPASTFunctionDeclarator declarator = extractedFunctionConstructionHelper
|
IASTStandardFunctionDeclarator declarator = extractedFunctionConstructionHelper
|
||||||
.createFunctionDeclarator(name, info.getDeclarator(), info
|
.createFunctionDeclarator(name, info.getDeclarator(), info
|
||||||
.getReturnVariable(), container.getNodesToWrite(), info
|
.getReturnVariable(), container.getNodesToWrite(), info
|
||||||
.getAllUsedNames(), unit.getParserLanguage());
|
.getAllUsedNames(), unit.getASTNodeFactory());
|
||||||
simpleDecl.addDeclarator(declarator);
|
simpleDecl.addDeclarator(declarator);
|
||||||
return simpleDecl;
|
return simpleDecl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,12 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.INodeFactory;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
|
|
||||||
import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
|
import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTPointer;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation;
|
import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation;
|
||||||
|
|
||||||
|
@ -59,12 +57,13 @@ public abstract class ExtractedFunctionConstructionHelper {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ICPPASTFunctionDeclarator createFunctionDeclarator(IASTName name, ICPPASTFunctionDeclarator functionDeclarator, NameInformation returnVariable, List<IASTNode> nodesToWrite, Collection<NameInformation> allUsedNames, ParserLanguage lang) {
|
IASTStandardFunctionDeclarator createFunctionDeclarator(IASTName name, IASTStandardFunctionDeclarator functionDeclarator, NameInformation returnVariable, List<IASTNode> nodesToWrite, Collection<NameInformation> allUsedNames, INodeFactory nodeFactory) {
|
||||||
ICPPASTFunctionDeclarator declarator = new CPPASTFunctionDeclarator();
|
IASTStandardFunctionDeclarator declarator = nodeFactory.newFunctionDeclarator(name);
|
||||||
declarator.setName(name);
|
|
||||||
|
|
||||||
if(functionDeclarator != null && functionDeclarator.isConst()) {
|
if (functionDeclarator instanceof ICPPASTFunctionDeclarator && declarator instanceof ICPPASTFunctionDeclarator) {
|
||||||
declarator.setConst(true);
|
if (((ICPPASTFunctionDeclarator) functionDeclarator).isConst()) {
|
||||||
|
((ICPPASTFunctionDeclarator) declarator).setConst(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(returnVariable != null) {
|
if(returnVariable != null) {
|
||||||
|
@ -75,22 +74,22 @@ public abstract class ExtractedFunctionConstructionHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ICPPASTParameterDeclaration param : getParameterDeclarations(allUsedNames, lang)) {
|
for (IASTParameterDeclaration param : getParameterDeclarations(allUsedNames, nodeFactory)) {
|
||||||
declarator.addParameterDeclaration(param);
|
declarator.addParameterDeclaration(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isReturnTypeAPointer(nodesToWrite.get(0))) {
|
if(isReturnTypeAPointer(nodesToWrite.get(0))) {
|
||||||
declarator.addPointerOperator(new CPPASTPointer());
|
declarator.addPointerOperator(nodeFactory.newPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
return declarator;
|
return declarator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<ICPPASTParameterDeclaration> getParameterDeclarations(Collection<NameInformation> allUsedNames, ParserLanguage lang) {
|
public Collection<IASTParameterDeclaration> getParameterDeclarations(Collection<NameInformation> allUsedNames, INodeFactory nodeFactory) {
|
||||||
Collection<ICPPASTParameterDeclaration> result = new ArrayList<ICPPASTParameterDeclaration>();
|
Collection<IASTParameterDeclaration> result = new ArrayList<IASTParameterDeclaration>();
|
||||||
for (NameInformation name : allUsedNames) {
|
for (NameInformation name : allUsedNames) {
|
||||||
if(!name.isDeclarationInScope()){
|
if(!name.isDeclarationInScope()){
|
||||||
result.add(name.getICPPASTParameterDeclaration(name.isUserSetIsReference(), lang));
|
result.add(name.getParameterDeclaration(name.isUserSetIsReference(), nodeFactory));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Add table
Reference in a new issue