mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Refactoring &Content Assist bug fixes
This commit is contained in:
parent
e20be2336b
commit
df56f209bb
3 changed files with 52 additions and 23 deletions
|
@ -1,3 +1,7 @@
|
|||
2004-04-15 Hoda Amer
|
||||
Fix for bug#58566 : [Refactoring] renaming #define statements
|
||||
Fix for bug#58335 : [Content Assist] Class forward declarations not reported
|
||||
|
||||
2004-05-15 David Inglis
|
||||
|
||||
Work in Progress - start of new C Path Container Wizard
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.model.IEnumeration;
|
|||
import org.eclipse.cdt.core.model.IField;
|
||||
import org.eclipse.cdt.core.model.IFunction;
|
||||
import org.eclipse.cdt.core.model.IFunctionDeclaration;
|
||||
import org.eclipse.cdt.core.model.IMacro;
|
||||
import org.eclipse.cdt.core.model.IMethod;
|
||||
import org.eclipse.cdt.core.model.IMethodDeclaration;
|
||||
import org.eclipse.cdt.core.model.INamespace;
|
||||
|
@ -60,6 +61,7 @@ public class RenameElementProcessor extends RenameProcessor implements IReferenc
|
|||
private SearchResultGroup[] fReferences;
|
||||
private TextChangeManager fChangeManager;
|
||||
private final String QUALIFIER = "::"; //$NON-NLS-1$
|
||||
private final String TELTA = "~"; //$NON-NLS-1$
|
||||
|
||||
private boolean fUpdateReferences;
|
||||
|
||||
|
@ -148,7 +150,7 @@ public class RenameElementProcessor extends RenameProcessor implements IReferenc
|
|||
}
|
||||
|
||||
public String getElementQualifiedName(ICElement element){
|
||||
if(element instanceof ITranslationUnit){
|
||||
if(!eligibleForRefactoring(element)){
|
||||
return "";
|
||||
} else {
|
||||
StringBuffer name = new StringBuffer();
|
||||
|
@ -169,7 +171,7 @@ public class RenameElementProcessor extends RenameProcessor implements IReferenc
|
|||
}
|
||||
}
|
||||
public RefactoringStatus checkNewElementName(String newName){
|
||||
if ((fCElement == null) || (!(fCElement instanceof ISourceReference)) || (fCElement instanceof ITranslationUnit)) {
|
||||
if (!eligibleForRefactoring(fCElement)) {
|
||||
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.getString("RenameTypeRefactoring.wrong_element")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
@ -247,7 +249,7 @@ public class RenameElementProcessor extends RenameProcessor implements IReferenc
|
|||
*/
|
||||
public RefactoringStatus checkActivation() throws CoreException {
|
||||
RefactoringStatus result= null;
|
||||
if ((fCElement == null) || (!(fCElement instanceof ISourceReference)) || (fCElement instanceof ITranslationUnit)) {
|
||||
if (!eligibleForRefactoring(fCElement)) {
|
||||
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.getString("RenameTypeRefactoring.wrong_element")); //$NON-NLS-1$
|
||||
}
|
||||
return Checks.checkIfTuBroken(fCElement);
|
||||
|
@ -406,9 +408,9 @@ public class RenameElementProcessor extends RenameProcessor implements IReferenc
|
|||
ICSearchConstants.TYPE, ICSearchConstants.REFERENCES, false ));
|
||||
IStructure structure = (IStructure) fCElement;
|
||||
if(structure.getElementType() == ICElement.C_CLASS){
|
||||
orPattern.addPattern(SearchEngine.createSearchPattern( searchPrefix + "::" + structure.getElementName(), //$NON-NLS-1$
|
||||
orPattern.addPattern(SearchEngine.createSearchPattern( searchPrefix + QUALIFIER + structure.getElementName(),
|
||||
ICSearchConstants.METHOD, ICSearchConstants.ALL_OCCURRENCES, false ));
|
||||
orPattern.addPattern(SearchEngine.createSearchPattern( searchPrefix + "::~" + structure.getElementName(), //$NON-NLS-1$
|
||||
orPattern.addPattern(SearchEngine.createSearchPattern( searchPrefix + QUALIFIER + TELTA + structure.getElementName(),
|
||||
ICSearchConstants.METHOD, ICSearchConstants.ALL_OCCURRENCES, false ));
|
||||
}
|
||||
}
|
||||
|
@ -534,4 +536,15 @@ public class RenameElementProcessor extends RenameProcessor implements IReferenc
|
|||
return result;
|
||||
}
|
||||
|
||||
private boolean eligibleForRefactoring(ICElement element){
|
||||
if((element == null)
|
||||
|| (!(element instanceof ISourceReference))
|
||||
|| (element instanceof ITranslationUnit)
|
||||
|| (element instanceof IMacro)){
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTField;
|
||||
|
@ -318,6 +319,34 @@ public class CompletionEngine implements RelevanceConstants {
|
|||
|
||||
requestor.acceptTypedef(typedef.getName(), completionStart, completionLength, relevance);
|
||||
}
|
||||
else if(node instanceof IASTElaboratedTypeSpecifier){
|
||||
IASTElaboratedTypeSpecifier elaboratedTypeSpecifier = (IASTElaboratedTypeSpecifier)node;
|
||||
ASTClassKind classkind = elaboratedTypeSpecifier.getClassKind();
|
||||
if(classkind == ASTClassKind.CLASS){
|
||||
int relevance = computeRelevance(ICElement.C_CLASS, prefix, elaboratedTypeSpecifier.getName());
|
||||
|
||||
requestor.acceptClass(elaboratedTypeSpecifier.getName(),
|
||||
completionStart, completionLength, relevance);
|
||||
}
|
||||
else if(classkind == ASTClassKind.STRUCT){
|
||||
int relevance = computeRelevance(ICElement.C_STRUCT, prefix, elaboratedTypeSpecifier.getName());
|
||||
|
||||
requestor.acceptStruct(elaboratedTypeSpecifier.getName(),
|
||||
completionStart, completionLength, relevance);
|
||||
}
|
||||
else if(classkind == ASTClassKind.UNION){
|
||||
int relevance = computeRelevance(ICElement.C_UNION, prefix, elaboratedTypeSpecifier.getName());
|
||||
|
||||
requestor.acceptUnion(elaboratedTypeSpecifier.getName(),
|
||||
completionStart, completionLength, relevance);
|
||||
}
|
||||
else if(classkind == ASTClassKind.ENUM){
|
||||
int relevance = computeRelevance(ICElement.C_ENUMERATION, prefix, elaboratedTypeSpecifier.getName());
|
||||
|
||||
requestor.acceptEnumeration(elaboratedTypeSpecifier.getName(),
|
||||
completionStart, completionLength, relevance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addKeywordToCompletions (String keyword){
|
||||
|
@ -514,8 +543,6 @@ public class CompletionEngine implements RelevanceConstants {
|
|||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||
kinds[0] = IASTNode.LookupKind.ALL;
|
||||
String prefix = completionNode.getCompletionPrefix();
|
||||
// if(prefix.equals("(")) //$NON-NLS-1$
|
||||
// prefix = ""; //$NON-NLS-1$
|
||||
result = lookup(searchNode, prefix, kinds, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
|
||||
|
@ -582,13 +609,6 @@ public class CompletionEngine implements RelevanceConstants {
|
|||
IASTScope searchNode = completionNode.getCompletionScope();
|
||||
// look for the specific type being newed and the scope
|
||||
IASTNode context = completionNode.getCompletionContext();
|
||||
// if ((context != null) && (context instanceof IASTClassSpecifier)){
|
||||
// IASTClassSpecifier classContext = (IASTClassSpecifier) context;
|
||||
// IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||
// kinds[0] = IASTNode.LookupKind.STRUCTURES;
|
||||
// ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
// addToCompletions(result);
|
||||
// }
|
||||
// basic completion on all types
|
||||
completionOnTypeReference(completionNode);
|
||||
}
|
||||
|
@ -655,10 +675,6 @@ public class CompletionEngine implements RelevanceConstants {
|
|||
// completionOnMemberReference
|
||||
completionOnMemberReference(completionNode);
|
||||
}
|
||||
// else if(kind == CompletionKind.SCOPED_REFERENCE){
|
||||
// // completionOnMemberReference
|
||||
// completionOnScopedReference(completionNode);
|
||||
// }
|
||||
else if(kind == CompletionKind.FIELD_TYPE){
|
||||
// CompletionOnFieldType
|
||||
completionOnFieldType(completionNode);
|
||||
|
@ -713,9 +729,7 @@ public class CompletionEngine implements RelevanceConstants {
|
|||
}
|
||||
|
||||
// add keywords in all cases except for member and scoped reference cases.
|
||||
if((kind != CompletionKind.MEMBER_REFERENCE)
|
||||
// &&(kind != CompletionKind.SCOPED_REFERENCE)
|
||||
){
|
||||
if(kind != CompletionKind.MEMBER_REFERENCE){
|
||||
addKeywordsToCompletions( completionNode.getKeywords());
|
||||
}
|
||||
|
||||
|
@ -730,8 +744,6 @@ public class CompletionEngine implements RelevanceConstants {
|
|||
String kindStr = ""; //$NON-NLS-1$
|
||||
if(kind == IASTCompletionNode.CompletionKind.MEMBER_REFERENCE)
|
||||
kindStr = "MEMBER_REFERENCE"; //$NON-NLS-1$
|
||||
// else if(kind == IASTCompletionNode.CompletionKind.SCOPED_REFERENCE)
|
||||
// kindStr = "SCOPED_REFERENCE";
|
||||
else if(kind == IASTCompletionNode.CompletionKind.FIELD_TYPE)
|
||||
kindStr = "FIELD_TYPE Class Scope"; //$NON-NLS-1$
|
||||
else if(kind == IASTCompletionNode.CompletionKind.VARIABLE_TYPE)
|
||||
|
|
Loading…
Add table
Reference in a new issue