mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
This commit is contained in:
parent
daf8e95a4e
commit
fb0d913699
9 changed files with 47 additions and 26 deletions
|
@ -16,7 +16,7 @@ import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTEnumerator extends IASTOffsetableNamedElement, ISourceElementCallbackDelegate {
|
||||
public interface IASTEnumerator extends IASTOffsetableNamedElement, IASTNode, ISourceElementCallbackDelegate {
|
||||
|
||||
public IASTEnumerationSpecifier getOwnerEnumerationSpecifier();
|
||||
public IASTExpression getInitialValue();
|
||||
|
|
|
@ -107,7 +107,7 @@ public interface IASTFactory
|
|||
String name,
|
||||
int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine) throws ASTSemanticException;
|
||||
|
||||
public void addEnumerator(
|
||||
public IASTEnumerator addEnumerator(
|
||||
IASTEnumerationSpecifier enumeration,
|
||||
String string,
|
||||
int startingOffset,
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTDesignator;
|
||||
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.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
|
||||
|
@ -2449,13 +2450,14 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
{
|
||||
try
|
||||
{
|
||||
astFactory.addEnumerator(
|
||||
IASTEnumerator enumerator = astFactory.addEnumerator(
|
||||
enumeration,
|
||||
enumeratorIdentifier.getImage(),
|
||||
enumeratorIdentifier.getOffset(),
|
||||
enumeratorIdentifier.getLineNumber(),
|
||||
enumeratorIdentifier.getOffset(), enumeratorIdentifier.getEndOffset(),
|
||||
enumeratorIdentifier.getLineNumber(), lastToken.getEndOffset(), lastToken.getLineNumber(), initialValue);
|
||||
endEnumerator(enumerator);
|
||||
}
|
||||
catch (ASTSemanticException e1)
|
||||
{
|
||||
|
@ -2474,12 +2476,13 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
}
|
||||
try
|
||||
{
|
||||
astFactory.addEnumerator(
|
||||
IASTEnumerator enumerator = astFactory.addEnumerator(
|
||||
enumeration,
|
||||
enumeratorIdentifier.getImage(),
|
||||
enumeratorIdentifier.getOffset(),
|
||||
enumeratorIdentifier.getLineNumber(),
|
||||
enumeratorIdentifier.getOffset(), enumeratorIdentifier.getEndOffset(), enumeratorIdentifier.getLineNumber(), lastToken.getEndOffset(), lastToken.getLineNumber(), initialValue);
|
||||
endEnumerator(enumerator);
|
||||
}
|
||||
catch (ASTSemanticException e1)
|
||||
{
|
||||
|
@ -3134,7 +3137,13 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
{
|
||||
cleanupLastToken();
|
||||
if( declaration instanceof IASTOffsetableNamedElement )
|
||||
handleNode( (IASTOffsetableNamedElement) declaration );
|
||||
handleOffsetableNamedElement( (IASTOffsetableNamedElement) declaration );
|
||||
}
|
||||
|
||||
protected void endEnumerator( IASTEnumerator enumerator ) throws EndOfFileException
|
||||
{
|
||||
cleanupLastToken();
|
||||
handleOffsetableNamedElement(enumerator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3155,6 +3164,6 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
/**
|
||||
* @param expression
|
||||
*/
|
||||
protected void handleNode(IASTOffsetableNamedElement node ) {
|
||||
protected void handleOffsetableNamedElement(IASTOffsetableNamedElement node ) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
|||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
|
||||
|
@ -274,7 +275,7 @@ public class SelectionParser extends ContextualParser {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.Parser#handleNode(org.eclipse.cdt.core.parser.ast.IASTNode)
|
||||
*/
|
||||
protected void handleNode(IASTOffsetableNamedElement node) {
|
||||
protected void handleOffsetableNamedElement(IASTOffsetableNamedElement node) {
|
||||
if( node != null )
|
||||
nodeTable.put( node, new Integer( getCurrentFileIndex()) );
|
||||
}
|
||||
|
@ -306,4 +307,16 @@ public class SelectionParser extends ContextualParser {
|
|||
}
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.Parser#endEnumerator(org.eclipse.cdt.core.parser.ast.IASTEnumerator)
|
||||
*/
|
||||
protected void endEnumerator(IASTEnumerator enumerator) throws EndOfFileException {
|
||||
if( ! tokenDupleCompleted() )
|
||||
super.endEnumerator(enumerator);
|
||||
else
|
||||
{
|
||||
contextNode = enumerator;
|
||||
throw new EndOfFileException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1006,7 +1006,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#addEnumerator(org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier, java.lang.String, int, int, org.eclipse.cdt.core.parser.ast.IASTExpression)
|
||||
*/
|
||||
public void addEnumerator(
|
||||
public IASTEnumerator addEnumerator(
|
||||
IASTEnumerationSpecifier enumeration,
|
||||
String name,
|
||||
int startingOffset,
|
||||
|
@ -1029,7 +1029,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
ASTEnumerator enumerator = new ASTEnumerator( enumeratorSymbol, enumeration, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, endingOffset, endLine, initialValue );
|
||||
((ASTEnumerationSpecifier)enumeration).addEnumerator( enumerator );
|
||||
attachSymbolExtension( enumeratorSymbol, enumerator, true );
|
||||
|
||||
return enumerator;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createExpression(org.eclipse.cdt.core.parser.ast.IASTExpression.Kind, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTExpression, java.lang.String, java.lang.String, java.lang.String, org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor)
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTDesignator;
|
||||
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.IASTExceptionSpecification;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||
|
@ -339,7 +340,7 @@ public class ExpressionParseASTFactory extends BaseASTFactory implements IASTFac
|
|||
* java.lang.String, int, int, int, int, int, int, int,
|
||||
* org.eclipse.cdt.core.parser.ast.IASTExpression)
|
||||
*/
|
||||
public void addEnumerator(
|
||||
public IASTEnumerator addEnumerator(
|
||||
IASTEnumerationSpecifier enumeration,
|
||||
String string,
|
||||
int startingOffset,
|
||||
|
@ -351,7 +352,7 @@ public class ExpressionParseASTFactory extends BaseASTFactory implements IASTFac
|
|||
int endLine,
|
||||
IASTExpression initialValue)
|
||||
throws ASTSemanticException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -16,12 +16,13 @@ import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTNode;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTEnumerator
|
||||
public class ASTEnumerator extends ASTNode
|
||||
implements IASTEnumerator, IASTOffsetableNamedElement
|
||||
{
|
||||
private final IASTExpression initialValue;
|
||||
|
|
|
@ -148,10 +148,11 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#addEnumerator(org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier, java.lang.String, int, int)
|
||||
*/
|
||||
public void addEnumerator(IASTEnumerationSpecifier enumeration, String string, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, int endingOffset, int endLine, IASTExpression initialValue)
|
||||
public IASTEnumerator addEnumerator(IASTEnumerationSpecifier enumeration, String string, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, int endingOffset, int endLine, IASTExpression initialValue)
|
||||
{
|
||||
IASTEnumerator enumerator = new ASTEnumerator( enumeration, string, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, endingOffset, endLine, initialValue );
|
||||
((ASTEnumerationSpecifier)enumeration).addEnumerator( enumerator );
|
||||
return enumerator;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -15,10 +15,10 @@ import java.io.FileNotFoundException;
|
|||
import java.io.FileReader;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.ICLogConstants;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||
|
@ -40,6 +40,7 @@ import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||
|
@ -47,20 +48,16 @@ import org.eclipse.cdt.core.search.ICSearchConstants.LimitTo;
|
|||
import org.eclipse.cdt.core.search.ICSearchConstants.SearchFor;
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
import org.eclipse.cdt.internal.ui.search.CSearchMessages;
|
||||
import org.eclipse.cdt.internal.ui.search.CSearchOperation;
|
||||
import org.eclipse.cdt.internal.ui.search.CSearchQuery;
|
||||
import org.eclipse.cdt.internal.ui.search.CSearchResultCollector;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.text.ITextSelection;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.search.ui.NewSearchUI;
|
||||
import org.eclipse.search.ui.SearchUI;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IWorkbenchSite;
|
||||
|
||||
|
@ -92,7 +89,7 @@ public abstract class FindAction extends Action {
|
|||
}
|
||||
|
||||
//C or CPP?
|
||||
ParserLanguage language = CoreModel.getDefault().hasCCNature(currentProject) ? ParserLanguage.CPP : ParserLanguage.C;
|
||||
ParserLanguage language = CoreModel.hasCCNature(currentProject) ? ParserLanguage.CPP : ParserLanguage.C;
|
||||
|
||||
IParser parser = null;
|
||||
FileReader reader = null;
|
||||
|
@ -153,8 +150,6 @@ public abstract class FindAction extends Action {
|
|||
}
|
||||
|
||||
public void run(IStructuredSelection sel){
|
||||
ICElement tempElement = null;
|
||||
|
||||
IEditorPart temp = fSite.getPage().getActiveEditor();
|
||||
CEditor cTemp = null;
|
||||
if (temp instanceof CEditor){
|
||||
|
@ -205,13 +200,13 @@ public abstract class FindAction extends Action {
|
|||
return;
|
||||
}
|
||||
|
||||
CSearchQuery job = createSearchQuery(selectedText.getText(),getSearchForFromNode((IASTNode)node));
|
||||
CSearchQuery job = createSearchQuery(selectedText.getText(),getSearchForFromNode(node));
|
||||
NewSearchUI.activateSearchResultView();
|
||||
|
||||
NewSearchUI.runQuery(job);
|
||||
}
|
||||
|
||||
private SearchFor getSearchForFromNode(IASTNode node){
|
||||
private SearchFor getSearchForFromNode(IASTOffsetableNamedElement node){
|
||||
SearchFor searchFor = null;
|
||||
|
||||
if (node instanceof IASTClassSpecifier){
|
||||
|
@ -242,12 +237,13 @@ public abstract class FindAction extends Action {
|
|||
else if (node instanceof IASTEnumerationSpecifier){
|
||||
searchFor = ICSearchConstants.ENUM;
|
||||
}
|
||||
else if (node instanceof IASTEnumerator){
|
||||
searchFor = ICSearchConstants.FIELD;
|
||||
}
|
||||
else if (node instanceof IASTNamespaceDefinition){
|
||||
searchFor = ICSearchConstants.NAMESPACE;
|
||||
}
|
||||
else if( node instanceof IASTTypedefDeclaration)
|
||||
searchFor = ICSearchConstants.TYPEDEF;
|
||||
else if( node instanceof IASTEnumerator )
|
||||
searchFor = ICSearchConstants.ENUMTOR;
|
||||
|
||||
return searchFor;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue