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-Name: %pluginName
|
||||
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-Vendor: %providerName
|
||||
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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -12,7 +12,7 @@
|
|||
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
|
||||
*
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
|
|
|
@ -230,8 +230,12 @@ public interface IASTTranslationUnit extends IASTDeclarationListOwner, IAdaptabl
|
|||
* @param 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.
|
||||
|
|
|
@ -87,6 +87,7 @@ public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbig
|
|||
return CVisitor.getReferences(this, binding);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ParserLanguage getParserLanguage() {
|
||||
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.ast.IASTName;
|
||||
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.IMacroBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
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.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
|
@ -131,6 +131,7 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
|||
return fBinding;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ParserLanguage getParserLanguage() {
|
||||
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.IASTTranslationUnit;
|
||||
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.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.ICPPASTSimpleTypeTemplateParameter;
|
||||
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.parser.ParserLanguage;
|
||||
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.CPPASTParameterDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTReferenceOperator;
|
||||
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriter;
|
||||
|
||||
public class NodeContainer {
|
||||
|
@ -130,58 +125,48 @@ public class NodeContainer {
|
|||
return getReferencesAfterSelection().size() > 0;
|
||||
}
|
||||
|
||||
public ICPPASTParameterDeclaration getICPPASTParameterDeclaration(
|
||||
boolean isReference, ParserLanguage lang) {
|
||||
ICPPASTParameterDeclaration para = new CPPASTParameterDeclaration();
|
||||
IASTDeclarator sourceDeclarator = (IASTDeclarator) getDeclaration()
|
||||
.getParent();
|
||||
public IASTParameterDeclaration getParameterDeclaration(boolean isReference,
|
||||
INodeFactory nodeFactory) {
|
||||
IASTDeclarator sourceDeclarator = (IASTDeclarator) getDeclaration().getParent();
|
||||
|
||||
IASTDeclSpecifier declSpec= null;
|
||||
IASTDeclarator declarator= null;
|
||||
|
||||
if (sourceDeclarator.getParent() instanceof IASTSimpleDeclaration) {
|
||||
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) sourceDeclarator
|
||||
.getParent();
|
||||
para.setDeclSpecifier(decl.getDeclSpecifier().copy());
|
||||
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) sourceDeclarator.getParent();
|
||||
declSpec= decl.getDeclSpecifier().copy();
|
||||
} else if (sourceDeclarator.getParent() instanceof IASTParameterDeclaration) {
|
||||
IASTParameterDeclaration decl = (IASTParameterDeclaration) sourceDeclarator
|
||||
.getParent();
|
||||
para.setDeclSpecifier(decl.getDeclSpecifier().copy());
|
||||
IASTParameterDeclaration decl = (IASTParameterDeclaration) sourceDeclarator.getParent();
|
||||
declSpec= decl.getDeclSpecifier().copy();
|
||||
}
|
||||
|
||||
IASTDeclarator declarator;
|
||||
IASTName name= nodeFactory.newName(getDeclaration().toCharArray());
|
||||
if (sourceDeclarator instanceof IASTArrayDeclarator) {
|
||||
IASTArrayDeclarator arrDeclarator = (IASTArrayDeclarator) sourceDeclarator;
|
||||
declarator = new CPPASTArrayDeclarator();
|
||||
IASTArrayModifier[] arrayModifiers = arrDeclarator
|
||||
.getArrayModifiers();
|
||||
IASTArrayDeclarator arrayDtor = nodeFactory.newArrayDeclarator(name);
|
||||
IASTArrayModifier[] arrayModifiers = arrDeclarator.getArrayModifiers();
|
||||
for (IASTArrayModifier arrayModifier : arrayModifiers) {
|
||||
((IASTArrayDeclarator) declarator)
|
||||
.addArrayModifier(arrayModifier.copy());
|
||||
arrayDtor.addArrayModifier(arrayModifier.copy());
|
||||
}
|
||||
|
||||
declarator= arrayDtor;
|
||||
} 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());
|
||||
}
|
||||
|
||||
if (isReference && !hasReferenceOperartor(declarator)) {
|
||||
switch (lang) {
|
||||
case C:
|
||||
declarator.addPointerOperator(new CASTPointer());
|
||||
break;
|
||||
case CPP:
|
||||
declarator.addPointerOperator(new CPPASTReferenceOperator(false));
|
||||
break;
|
||||
if (nodeFactory instanceof ICPPNodeFactory) {
|
||||
declarator.addPointerOperator(((ICPPNodeFactory) nodeFactory).newReferenceOperator(false));
|
||||
} else {
|
||||
declarator.addPointerOperator(nodeFactory.newPointer());
|
||||
}
|
||||
}
|
||||
|
||||
declarator.setNestedDeclarator(sourceDeclarator
|
||||
.getNestedDeclarator());
|
||||
para.setDeclarator(declarator);
|
||||
declarator.setNestedDeclarator(sourceDeclarator.getNestedDeclarator());
|
||||
|
||||
return para;
|
||||
return nodeFactory.newParameterDeclaration(declSpec, 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.IASTUnaryExpression;
|
||||
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.ICPPASTCompositeTypeSpecifier;
|
||||
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.ICPPNodeFactory;
|
||||
import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
|
||||
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.CPPASTLiteralExpression;
|
||||
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.CPPASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethod;
|
||||
|
@ -407,9 +408,9 @@ public class ExtractConstantRefactoring extends CRefactoring {
|
|||
private IASTDeclaration getConstNodesGlobal(String newName){
|
||||
IASTSimpleDeclaration simple = getConstNodes(newName);
|
||||
|
||||
if(unit.getParserLanguage().isCPP()){
|
||||
ICPPASTNamespaceDefinition namespace = new CPPASTNamespaceDefinition();
|
||||
namespace.setName(new CPPASTName());
|
||||
INodeFactory factory= unit.getASTNodeFactory();
|
||||
if (factory instanceof ICPPNodeFactory) {
|
||||
ICPPASTNamespaceDefinition namespace = ((ICPPNodeFactory) factory).newNamespaceDefinition(new CPPASTName());
|
||||
namespace.addDeclaration(simple);
|
||||
return namespace;
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ import java.util.HashMap;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
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.Container;
|
||||
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.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.utils.ASTHelper;
|
||||
import org.eclipse.cdt.internal.ui.refactoring.utils.CPPASTAllVisitor;
|
||||
|
@ -660,7 +660,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
|
|||
IASTStandardFunctionDeclarator createdFunctionDeclarator = extractedFunctionConstructionHelper
|
||||
.createFunctionDeclarator(qname, info.getDeclarator(), info
|
||||
.getReturnVariable(), container.getNodesToWrite(), info
|
||||
.getAllUsedNames(), unit.getParserLanguage());
|
||||
.getAllUsedNames(), unit.getASTNodeFactory());
|
||||
func.setDeclarator(createdFunctionDeclarator);
|
||||
|
||||
IASTCompoundStatement compound = new CPPASTCompoundStatement();
|
||||
|
@ -863,7 +863,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
|
|||
IASTStandardFunctionDeclarator declarator = extractedFunctionConstructionHelper
|
||||
.createFunctionDeclarator(name, info.getDeclarator(), info
|
||||
.getReturnVariable(), container.getNodesToWrite(), info
|
||||
.getAllUsedNames(), unit.getParserLanguage());
|
||||
.getAllUsedNames(), unit.getASTNodeFactory());
|
||||
simpleDecl.addDeclarator(declarator);
|
||||
return simpleDecl;
|
||||
}
|
||||
|
@ -875,10 +875,10 @@ public class ExtractFunctionRefactoring extends CRefactoring {
|
|||
((ICPPASTDeclSpecifier)declSpec).setVirtual(true);
|
||||
}
|
||||
simpleDecl.setParent(unit);
|
||||
ICPPASTFunctionDeclarator declarator = extractedFunctionConstructionHelper
|
||||
IASTStandardFunctionDeclarator declarator = extractedFunctionConstructionHelper
|
||||
.createFunctionDeclarator(name, info.getDeclarator(), info
|
||||
.getReturnVariable(), container.getNodesToWrite(), info
|
||||
.getAllUsedNames(), unit.getParserLanguage());
|
||||
.getAllUsedNames(), unit.getASTNodeFactory());
|
||||
simpleDecl.addDeclarator(declarator);
|
||||
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.IASTName;
|
||||
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.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.ICPPASTParameterDeclaration;
|
||||
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;
|
||||
|
||||
|
@ -59,12 +57,13 @@ public abstract class ExtractedFunctionConstructionHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
ICPPASTFunctionDeclarator createFunctionDeclarator(IASTName name, ICPPASTFunctionDeclarator functionDeclarator, NameInformation returnVariable, List<IASTNode> nodesToWrite, Collection<NameInformation> allUsedNames, ParserLanguage lang) {
|
||||
ICPPASTFunctionDeclarator declarator = new CPPASTFunctionDeclarator();
|
||||
declarator.setName(name);
|
||||
IASTStandardFunctionDeclarator createFunctionDeclarator(IASTName name, IASTStandardFunctionDeclarator functionDeclarator, NameInformation returnVariable, List<IASTNode> nodesToWrite, Collection<NameInformation> allUsedNames, INodeFactory nodeFactory) {
|
||||
IASTStandardFunctionDeclarator declarator = nodeFactory.newFunctionDeclarator(name);
|
||||
|
||||
if(functionDeclarator != null && functionDeclarator.isConst()) {
|
||||
declarator.setConst(true);
|
||||
if (functionDeclarator instanceof ICPPASTFunctionDeclarator && declarator instanceof ICPPASTFunctionDeclarator) {
|
||||
if (((ICPPASTFunctionDeclarator) functionDeclarator).isConst()) {
|
||||
((ICPPASTFunctionDeclarator) declarator).setConst(true);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if(isReturnTypeAPointer(nodesToWrite.get(0))) {
|
||||
declarator.addPointerOperator(new CPPASTPointer());
|
||||
declarator.addPointerOperator(nodeFactory.newPointer());
|
||||
}
|
||||
|
||||
return declarator;
|
||||
}
|
||||
|
||||
public Collection<ICPPASTParameterDeclaration> getParameterDeclarations(Collection<NameInformation> allUsedNames, ParserLanguage lang) {
|
||||
Collection<ICPPASTParameterDeclaration> result = new ArrayList<ICPPASTParameterDeclaration>();
|
||||
public Collection<IASTParameterDeclaration> getParameterDeclarations(Collection<NameInformation> allUsedNames, INodeFactory nodeFactory) {
|
||||
Collection<IASTParameterDeclaration> result = new ArrayList<IASTParameterDeclaration>();
|
||||
for (NameInformation name : allUsedNames) {
|
||||
if(!name.isDeclarationInScope()){
|
||||
result.add(name.getICPPASTParameterDeclaration(name.isUserSetIsReference(), lang));
|
||||
result.add(name.getParameterDeclaration(name.isUserSetIsReference(), nodeFactory));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
Loading…
Add table
Reference in a new issue