Lines 7-12
Link Here
|
7 |
* |
7 |
* |
8 |
* Contributors: |
8 |
* Contributors: |
9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
|
|
10 |
* Sergey Prigogin (Google) - initial API and implementation |
10 |
*******************************************************************************/ |
11 |
*******************************************************************************/ |
11 |
package org.eclipse.cdt.internal.core.parser; |
12 |
package org.eclipse.cdt.internal.core.parser; |
12 |
import java.util.ArrayList; |
13 |
import java.util.ArrayList; |
Lines 95-103
Link Here
|
95 |
* |
96 |
* |
96 |
* @author jcamelon |
97 |
* @author jcamelon |
97 |
*/ |
98 |
*/ |
98 |
public class Parser implements IParserData, IParser |
99 |
public class Parser implements IParserData, IParser { |
99 |
{ |
|
|
100 |
protected final ParserMode mode; |
100 |
protected final ParserMode mode; |
|
|
101 |
private static final String[] EMPTY_STRING_ARRAY = new String[0]; |
101 |
protected static final char[] EMPTY_STRING = "".toCharArray(); //$NON-NLS-1$ |
102 |
protected static final char[] EMPTY_STRING = "".toCharArray(); //$NON-NLS-1$ |
102 |
private static int FIRST_ERROR_UNSET = -1; |
103 |
private static int FIRST_ERROR_UNSET = -1; |
103 |
protected boolean parsePassed = true; |
104 |
protected boolean parsePassed = true; |
Lines 107-121
Link Here
|
107 |
private int backtrackCount = 0; |
108 |
private int backtrackCount = 0; |
108 |
private char[] parserStartFilename = null; |
109 |
private char[] parserStartFilename = null; |
109 |
|
110 |
|
110 |
protected final void throwBacktrack( IProblem problem ) throws BacktrackException { |
111 |
protected final void throwBacktrack(IProblem problem) throws BacktrackException { |
111 |
++backtrackCount; |
112 |
++backtrackCount; |
112 |
backtrack.initialize( problem ); |
113 |
backtrack.initialize(problem); |
113 |
throw backtrack; |
114 |
throw backtrack; |
114 |
} |
115 |
} |
115 |
|
116 |
|
116 |
protected final void throwBacktrack( int startingOffset, int endingOffset, int lineNumber, char[] f ) throws BacktrackException { |
117 |
protected final void throwBacktrack(int startingOffset, int endingOffset, int lineNumber, char[] f) throws BacktrackException { |
117 |
++backtrackCount; |
118 |
++backtrackCount; |
118 |
backtrack.initialize( startingOffset, ( endingOffset == 0 ) ? startingOffset + 1 : endingOffset, lineNumber, f ); |
119 |
backtrack.initialize(startingOffset, (endingOffset == 0) ? startingOffset + 1 : endingOffset, lineNumber, f); |
119 |
throw backtrack; |
120 |
throw backtrack; |
120 |
} |
121 |
} |
121 |
|
122 |
|
Lines 142-163
Link Here
|
142 |
|
143 |
|
143 |
private void grow(){ |
144 |
private void grow(){ |
144 |
int [] newStack = new int[ stack.length << 1 ]; |
145 |
int [] newStack = new int[ stack.length << 1 ]; |
145 |
System.arraycopy( stack, 0, newStack, 0, stack.length ); |
146 |
System.arraycopy(stack, 0, newStack, 0, stack.length); |
146 |
stack = newStack; |
147 |
stack = newStack; |
147 |
} |
148 |
} |
148 |
|
149 |
|
149 |
final public void push( int i ){ |
150 |
final public void push(int i){ |
150 |
if( ++index == stack.length ) |
151 |
if (++index == stack.length) |
151 |
grow(); |
152 |
grow(); |
152 |
stack[index] = i; |
153 |
stack[index] = i; |
153 |
} |
154 |
} |
|
|
155 |
|
154 |
final public int pop(){ |
156 |
final public int pop(){ |
155 |
if( index >= 0 ) |
157 |
if (index >= 0) |
156 |
return stack[index--]; |
158 |
return stack[index--]; |
157 |
return -1; |
159 |
return -1; |
158 |
} |
160 |
} |
|
|
161 |
|
159 |
final public int peek(){ |
162 |
final public int peek(){ |
160 |
if( index >= 0 ) |
163 |
if (index >= 0) |
161 |
return stack[index]; |
164 |
return stack[index]; |
162 |
return -1; |
165 |
return -1; |
163 |
} |
166 |
} |
Lines 165-176
Link Here
|
165 |
return index + 1; |
168 |
return index + 1; |
166 |
} |
169 |
} |
167 |
} |
170 |
} |
|
|
171 |
|
168 |
/** |
172 |
/** |
169 |
* @return Returns the astFactory. |
173 |
* @return Returns the astFactory. |
170 |
*/ |
174 |
*/ |
171 |
public IASTFactory getAstFactory() { |
175 |
public IASTFactory getAstFactory() { |
172 |
return astFactory; |
176 |
return astFactory; |
173 |
} |
177 |
} |
|
|
178 |
|
174 |
/** |
179 |
/** |
175 |
* @return Returns the log. |
180 |
* @return Returns the log. |
176 |
*/ |
181 |
*/ |
Lines 186-192
Link Here
|
186 |
* @throws EndOfFileException if looking ahead encounters EOF, throw EndOfFile |
191 |
* @throws EndOfFileException if looking ahead encounters EOF, throw EndOfFile |
187 |
*/ |
192 |
*/ |
188 |
public IToken LA(int i) throws EndOfFileException { |
193 |
public IToken LA(int i) throws EndOfFileException { |
189 |
|
|
|
190 |
if (isCancelled) { |
194 |
if (isCancelled) { |
191 |
throw new ParseError(ParseError.ParseErrorKind.TIMEOUT_OR_CANCELLED); |
195 |
throw new ParseError(ParseError.ParseErrorKind.TIMEOUT_OR_CANCELLED); |
192 |
} |
196 |
} |
Lines 222-228
Link Here
|
222 |
* @throws EndOfFileException If there is no token to consume. |
226 |
* @throws EndOfFileException If there is no token to consume. |
223 |
*/ |
227 |
*/ |
224 |
public IToken consume() throws EndOfFileException { |
228 |
public IToken consume() throws EndOfFileException { |
225 |
|
|
|
226 |
if (currToken == null) |
229 |
if (currToken == null) |
227 |
currToken = fetchToken(); |
230 |
currToken = fetchToken(); |
228 |
if (currToken != null) |
231 |
if (currToken != null) |
Lines 279-285
Link Here
|
279 |
*/ |
282 |
*/ |
280 |
protected void failParse() { |
283 |
protected void failParse() { |
281 |
try { |
284 |
try { |
282 |
if (firstErrorOffset == FIRST_ERROR_UNSET){ |
285 |
if (firstErrorOffset == FIRST_ERROR_UNSET) { |
283 |
firstErrorOffset = LA(1).getOffset(); |
286 |
firstErrorOffset = LA(1).getOffset(); |
284 |
firstErrorLine = LA(1).getLineNumber(); |
287 |
firstErrorLine = LA(1).getLineNumber(); |
285 |
} |
288 |
} |
Lines 362-368
Link Here
|
362 |
boolean completedArg = false; |
365 |
boolean completedArg = false; |
363 |
boolean failed = false; |
366 |
boolean failed = false; |
364 |
|
367 |
|
365 |
templateIdScopes.push( IToken.tLT ); |
368 |
templateIdScopes.push(IToken.tLT); |
366 |
|
369 |
|
367 |
while (LT(1) != IToken.tGT) { |
370 |
while (LT(1) != IToken.tGT) { |
368 |
completedArg = false; |
371 |
completedArg = false; |
Lines 393-399
Link Here
|
393 |
KeywordSetKey.EXPRESSION); |
396 |
KeywordSetKey.EXPRESSION); |
394 |
|
397 |
|
395 |
if (expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_EMPTY) { |
398 |
if (expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_EMPTY) { |
396 |
throwBacktrack(so, ( lastToken != null ) ? lastToken.getEndOffset() : 0, ln, fn ); |
399 |
throwBacktrack(so, (lastToken != null) ? lastToken.getEndOffset() : 0, ln, fn); |
397 |
} |
400 |
} |
398 |
list.add(expression); |
401 |
list.add(expression); |
399 |
completedArg = true; |
402 |
completedArg = true; |
Lines 436-442
Link Here
|
436 |
if (failed) { |
439 |
if (failed) { |
437 |
if (expression != null) |
440 |
if (expression != null) |
438 |
expression.freeReferences(); |
441 |
expression.freeReferences(); |
439 |
throwBacktrack(startingOffset, 0, startingLineNumber, fn ); |
442 |
throwBacktrack(startingOffset, 0, startingLineNumber, fn); |
440 |
} |
443 |
} |
441 |
|
444 |
|
442 |
return list; |
445 |
return list; |
Lines 476-483
Link Here
|
476 |
IASTCompletionNode.CompletionKind kind, KeywordSetKey key) |
479 |
IASTCompletionNode.CompletionKind kind, KeywordSetKey key) |
477 |
throws BacktrackException, EndOfFileException { |
480 |
throws BacktrackException, EndOfFileException { |
478 |
|
481 |
|
479 |
TemplateParameterManager argumentList = TemplateParameterManager |
482 |
TemplateParameterManager argumentList = TemplateParameterManager.getInstance(); |
480 |
.getInstance(); |
|
|
481 |
|
483 |
|
482 |
try { |
484 |
try { |
483 |
IToken first = LA(1); |
485 |
IToken first = LA(1); |
Lines 502-515
Link Here
|
502 |
case IToken.tIDENTIFIER : |
504 |
case IToken.tIDENTIFIER : |
503 |
IToken prev = last; |
505 |
IToken prev = last; |
504 |
last = consume(IToken.tIDENTIFIER); |
506 |
last = consume(IToken.tIDENTIFIER); |
505 |
if (startsWithColonColon) |
507 |
if (startsWithColonColon) { |
506 |
setCompletionValues(scope, kind, getCompliationUnit()); |
508 |
setCompletionValues(scope, kind, getCompliationUnit()); |
507 |
else if (prev != null) |
509 |
} else if (prev != null) { |
508 |
setCompletionValues(scope, kind, first, prev, |
510 |
setCompletionValues(scope, kind, first, prev, |
509 |
argumentList.getTemplateArgumentsList(), KeywordSetKey.EMPTY); |
511 |
argumentList.getTemplateArgumentsList(), KeywordSetKey.EMPTY); |
510 |
else |
512 |
} else { |
511 |
setCompletionValuesNoContext(scope, kind, key); |
513 |
setCompletionValuesNoContext(scope, kind, key); |
512 |
|
514 |
} |
513 |
last = consumeTemplateArguments(scope, last, argumentList, kind); |
515 |
last = consumeTemplateArguments(scope, last, argumentList, kind); |
514 |
if (last.getType() == IToken.tGT) |
516 |
if (last.getType() == IToken.tGT) |
515 |
hasTemplateId = true; |
517 |
hasTemplateId = true; |
Lines 559-565
Link Here
|
559 |
} finally { |
561 |
} finally { |
560 |
TemplateParameterManager.returnInstance(argumentList); |
562 |
TemplateParameterManager.returnInstance(argumentList); |
561 |
} |
563 |
} |
562 |
|
|
|
563 |
} |
564 |
} |
564 |
|
565 |
|
565 |
/** |
566 |
/** |
Lines 695-701
Link Here
|
695 |
} else if (LA(1).isOperator()) |
696 |
} else if (LA(1).isOperator()) |
696 |
toSend = consume(); |
697 |
toSend = consume(); |
697 |
else |
698 |
else |
698 |
throwBacktrack(operatorToken.getOffset(), toSend != null ? toSend.getEndOffset() : 0, operatorToken.getLineNumber(), operatorToken.getFilename() ); |
699 |
throwBacktrack(operatorToken.getOffset(), toSend != null ? toSend.getEndOffset() : 0, operatorToken.getLineNumber(), operatorToken.getFilename()); |
699 |
} else { |
700 |
} else { |
700 |
// must be a conversion function |
701 |
// must be a conversion function |
701 |
typeId(d.getDeclarationWrapper().getScope(), true, |
702 |
typeId(d.getDeclarationWrapper().getScope(), true, |
Lines 809-820
Link Here
|
809 |
|
810 |
|
810 |
//moved to primary expression |
811 |
//moved to primary expression |
811 |
// IASTExpression resultExpression = null; |
812 |
// IASTExpression resultExpression = null; |
812 |
// if( la.getType() == IToken.tLPAREN && LT(2) == IToken.tLBRACE && extension.supportsStatementsInExpressions() ) |
813 |
// if (la.getType() == IToken.tLPAREN && LT(2) == IToken.tLBRACE && extension.supportsStatementsInExpressions()) |
813 |
// { |
814 |
// { |
814 |
// resultExpression = compoundStatementExpression(scope, la, resultExpression); |
815 |
// resultExpression = compoundStatementExpression(scope, la, resultExpression); |
815 |
// } |
816 |
// } |
816 |
// |
817 |
// |
817 |
// if( resultExpression != null ) |
818 |
// if (resultExpression != null) |
818 |
// return resultExpression; |
819 |
// return resultExpression; |
819 |
|
820 |
|
820 |
IASTExpression assignmentExpression = assignmentExpression(scope, kind, |
821 |
IASTExpression assignmentExpression = assignmentExpression(scope, kind, |
Lines 852-888
Link Here
|
852 |
private IASTExpression compoundStatementExpression(IASTScope scope, IToken la, IASTExpression resultExpression) throws EndOfFileException, BacktrackException { |
853 |
private IASTExpression compoundStatementExpression(IASTScope scope, IToken la, IASTExpression resultExpression) throws EndOfFileException, BacktrackException { |
853 |
int startingOffset = la.getOffset(); |
854 |
int startingOffset = la.getOffset(); |
854 |
int ln = la.getLineNumber(); |
855 |
int ln = la.getLineNumber(); |
855 |
char [] fn = la.getFilename(); |
856 |
char[] fn = la.getFilename(); |
856 |
consume( IToken.tLPAREN ); |
857 |
consume(IToken.tLPAREN); |
857 |
try |
858 |
try { |
858 |
{ |
859 |
if (mode == ParserMode.QUICK_PARSE || mode == ParserMode.STRUCTURAL_PARSE) { |
859 |
if( mode == ParserMode.QUICK_PARSE || mode == ParserMode.STRUCTURAL_PARSE ) |
|
|
860 |
skipOverCompoundStatement(); |
860 |
skipOverCompoundStatement(); |
861 |
else if( mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE ) |
861 |
} else if (mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE) { |
862 |
{ |
862 |
if (scanner.isOnTopContext()) |
863 |
if( scanner.isOnTopContext() ) |
|
|
864 |
compoundStatement(scope, true); |
863 |
compoundStatement(scope, true); |
865 |
else |
864 |
else |
866 |
skipOverCompoundStatement(); |
865 |
skipOverCompoundStatement(); |
867 |
} |
866 |
} else if (mode == ParserMode.COMPLETE_PARSE) { |
868 |
else if( mode == ParserMode.COMPLETE_PARSE ) |
|
|
869 |
compoundStatement(scope, true); |
867 |
compoundStatement(scope, true); |
870 |
|
|
|
871 |
consume( IToken.tRPAREN ); |
872 |
try |
873 |
{ |
874 |
resultExpression = astFactory.createExpression( scope, extension.getExpressionKindForStatement(), null, null, null, null, null,EMPTY_STRING, null, (ITokenDuple)la ); |
875 |
} |
868 |
} |
876 |
catch (ASTSemanticException e) { |
869 |
|
|
|
870 |
consume(IToken.tRPAREN); |
871 |
try { |
872 |
resultExpression = astFactory.createExpression(scope, extension.getExpressionKindForStatement(), null, null, null, null, null,EMPTY_STRING, null, (ITokenDuple)la); |
873 |
} catch (ASTSemanticException e) { |
877 |
throwBacktrack(e.getProblem()); |
874 |
throwBacktrack(e.getProblem()); |
878 |
} catch (Exception e) { |
875 |
} catch (Exception e) { |
879 |
logException("expression::createExpression()", e); //$NON-NLS-1$ |
876 |
logException("expression::createExpression()", e); //$NON-NLS-1$ |
880 |
throwBacktrack(startingOffset, lastToken != null ? lastToken.getEndOffset() : 0 , ln, fn); |
877 |
throwBacktrack(startingOffset, lastToken != null ? lastToken.getEndOffset() : 0 , ln, fn); |
881 |
} |
878 |
} |
882 |
} |
879 |
} catch (BacktrackException bte) { |
883 |
catch( BacktrackException bte ) |
880 |
backup(la); |
884 |
{ |
|
|
885 |
backup( la ); |
886 |
} |
881 |
} |
887 |
return resultExpression; |
882 |
return resultExpression; |
888 |
} |
883 |
} |
Lines 969-975
Link Here
|
969 |
CompletionKind.SINGLE_NAME_REFERENCE, key); |
964 |
CompletionKind.SINGLE_NAME_REFERENCE, key); |
970 |
} catch (BacktrackException b) { |
965 |
} catch (BacktrackException b) { |
971 |
} |
966 |
} |
972 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
967 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
973 |
try { |
968 |
try { |
974 |
return astFactory.createExpression(scope, |
969 |
return astFactory.createExpression(scope, |
975 |
IASTExpression.Kind.THROWEXPRESSION, throwExpression, null, |
970 |
IASTExpression.Kind.THROWEXPRESSION, throwExpression, null, |
Lines 978-984
Link Here
|
978 |
throwBacktrack(e.getProblem()); |
973 |
throwBacktrack(e.getProblem()); |
979 |
} catch (Exception e) { |
974 |
} catch (Exception e) { |
980 |
logException("throwExpression::createExpression()", e); //$NON-NLS-1$ |
975 |
logException("throwExpression::createExpression()", e); //$NON-NLS-1$ |
981 |
throwBacktrack(throwToken.getOffset(), endOffset, throwToken.getLineNumber(), throwToken.getFilename() ); |
976 |
throwBacktrack(throwToken.getOffset(), endOffset, throwToken.getLineNumber(), throwToken.getFilename()); |
982 |
|
977 |
|
983 |
} |
978 |
} |
984 |
return null; |
979 |
return null; |
Lines 1004-1010
Link Here
|
1004 |
consume(IToken.tCOLON); |
999 |
consume(IToken.tCOLON); |
1005 |
IASTExpression thirdExpression = assignmentExpression(scope, kind, |
1000 |
IASTExpression thirdExpression = assignmentExpression(scope, kind, |
1006 |
key); |
1001 |
key); |
1007 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
1002 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
1008 |
try { |
1003 |
try { |
1009 |
return astFactory.createExpression(scope, |
1004 |
return astFactory.createExpression(scope, |
1010 |
IASTExpression.Kind.CONDITIONALEXPRESSION, |
1005 |
IASTExpression.Kind.CONDITIONALEXPRESSION, |
Lines 1036-1042
Link Here
|
1036 |
consume(IToken.tOR); |
1031 |
consume(IToken.tOR); |
1037 |
IASTExpression secondExpression = logicalAndExpression(scope, kind, |
1032 |
IASTExpression secondExpression = logicalAndExpression(scope, kind, |
1038 |
key); |
1033 |
key); |
1039 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
1034 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
1040 |
try { |
1035 |
try { |
1041 |
firstExpression = astFactory.createExpression(scope, |
1036 |
firstExpression = astFactory.createExpression(scope, |
1042 |
IASTExpression.Kind.LOGICALOREXPRESSION, |
1037 |
IASTExpression.Kind.LOGICALOREXPRESSION, |
Lines 1068-1074
Link Here
|
1068 |
consume(IToken.tAND); |
1063 |
consume(IToken.tAND); |
1069 |
IASTExpression secondExpression = inclusiveOrExpression(scope, |
1064 |
IASTExpression secondExpression = inclusiveOrExpression(scope, |
1070 |
kind, key); |
1065 |
kind, key); |
1071 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
1066 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
1072 |
try { |
1067 |
try { |
1073 |
firstExpression = astFactory.createExpression(scope, |
1068 |
firstExpression = astFactory.createExpression(scope, |
1074 |
IASTExpression.Kind.LOGICALANDEXPRESSION, |
1069 |
IASTExpression.Kind.LOGICALANDEXPRESSION, |
Lines 1101-1107
Link Here
|
1101 |
consume(); |
1096 |
consume(); |
1102 |
IASTExpression secondExpression = exclusiveOrExpression(scope, |
1097 |
IASTExpression secondExpression = exclusiveOrExpression(scope, |
1103 |
kind, key); |
1098 |
kind, key); |
1104 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
1099 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
1105 |
try { |
1100 |
try { |
1106 |
firstExpression = astFactory.createExpression(scope, |
1101 |
firstExpression = astFactory.createExpression(scope, |
1107 |
IASTExpression.Kind.INCLUSIVEOREXPRESSION, |
1102 |
IASTExpression.Kind.INCLUSIVEOREXPRESSION, |
Lines 1134-1140
Link Here
|
1134 |
consume(); |
1129 |
consume(); |
1135 |
|
1130 |
|
1136 |
IASTExpression secondExpression = andExpression(scope, kind, key); |
1131 |
IASTExpression secondExpression = andExpression(scope, kind, key); |
1137 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
1132 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
1138 |
try { |
1133 |
try { |
1139 |
firstExpression = astFactory.createExpression(scope, |
1134 |
firstExpression = astFactory.createExpression(scope, |
1140 |
IASTExpression.Kind.EXCLUSIVEOREXPRESSION, |
1135 |
IASTExpression.Kind.EXCLUSIVEOREXPRESSION, |
Lines 1167-1173
Link Here
|
1167 |
consume(); |
1162 |
consume(); |
1168 |
IASTExpression secondExpression = equalityExpression(scope, kind, |
1163 |
IASTExpression secondExpression = equalityExpression(scope, kind, |
1169 |
key); |
1164 |
key); |
1170 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
1165 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
1171 |
try { |
1166 |
try { |
1172 |
firstExpression = astFactory.createExpression(scope, |
1167 |
firstExpression = astFactory.createExpression(scope, |
1173 |
IASTExpression.Kind.ANDEXPRESSION, firstExpression, |
1168 |
IASTExpression.Kind.ANDEXPRESSION, firstExpression, |
Lines 1222-1228
Link Here
|
1222 |
IToken t = consume(); |
1217 |
IToken t = consume(); |
1223 |
IASTExpression secondExpression = relationalExpression( |
1218 |
IASTExpression secondExpression = relationalExpression( |
1224 |
scope, kind, key); |
1219 |
scope, kind, key); |
1225 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
1220 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
1226 |
try { |
1221 |
try { |
1227 |
firstExpression = astFactory.createExpression(scope, (t |
1222 |
firstExpression = astFactory.createExpression(scope, (t |
1228 |
.getType() == IToken.tEQUAL) |
1223 |
.getType() == IToken.tEQUAL) |
Lines 1291-1297
Link Here
|
1291 |
expressionKind = IASTExpression.Kind.RELATIONAL_GREATERTHANEQUALTO; |
1286 |
expressionKind = IASTExpression.Kind.RELATIONAL_GREATERTHANEQUALTO; |
1292 |
break; |
1287 |
break; |
1293 |
} |
1288 |
} |
1294 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
1289 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
1295 |
try { |
1290 |
try { |
1296 |
firstExpression = astFactory.createExpression(scope, |
1291 |
firstExpression = astFactory.createExpression(scope, |
1297 |
expressionKind, firstExpression, |
1292 |
expressionKind, firstExpression, |
Lines 1337-1343
Link Here
|
1337 |
IToken t = consume(); |
1332 |
IToken t = consume(); |
1338 |
IASTExpression secondExpression = additiveExpression(scope, |
1333 |
IASTExpression secondExpression = additiveExpression(scope, |
1339 |
kind, key); |
1334 |
kind, key); |
1340 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
1335 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
1341 |
try { |
1336 |
try { |
1342 |
firstExpression = astFactory.createExpression(scope, |
1337 |
firstExpression = astFactory.createExpression(scope, |
1343 |
((t.getType() == IToken.tSHIFTL) |
1338 |
((t.getType() == IToken.tSHIFTL) |
Lines 1378-1384
Link Here
|
1378 |
IToken t = consume(); |
1373 |
IToken t = consume(); |
1379 |
IASTExpression secondExpression = multiplicativeExpression( |
1374 |
IASTExpression secondExpression = multiplicativeExpression( |
1380 |
scope, kind, key); |
1375 |
scope, kind, key); |
1381 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
1376 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
1382 |
try { |
1377 |
try { |
1383 |
firstExpression = astFactory.createExpression(scope, |
1378 |
firstExpression = astFactory.createExpression(scope, |
1384 |
((t.getType() == IToken.tPLUS) |
1379 |
((t.getType() == IToken.tPLUS) |
Lines 1432-1438
Link Here
|
1432 |
expressionKind = IASTExpression.Kind.MULTIPLICATIVE_MODULUS; |
1427 |
expressionKind = IASTExpression.Kind.MULTIPLICATIVE_MODULUS; |
1433 |
break; |
1428 |
break; |
1434 |
} |
1429 |
} |
1435 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
1430 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
1436 |
try { |
1431 |
try { |
1437 |
firstExpression = astFactory.createExpression(scope, |
1432 |
firstExpression = astFactory.createExpression(scope, |
1438 |
expressionKind, firstExpression, |
1433 |
expressionKind, firstExpression, |
Lines 1472-1478
Link Here
|
1472 |
IToken t = consume(); |
1467 |
IToken t = consume(); |
1473 |
IASTExpression secondExpression = castExpression(scope, |
1468 |
IASTExpression secondExpression = castExpression(scope, |
1474 |
kind, key); |
1469 |
kind, key); |
1475 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
1470 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
1476 |
try { |
1471 |
try { |
1477 |
firstExpression = astFactory.createExpression(scope, |
1472 |
firstExpression = astFactory.createExpression(scope, |
1478 |
((t.getType() == IToken.tDOTSTAR) |
1473 |
((t.getType() == IToken.tDOTSTAR) |
Lines 1510-1516
Link Here
|
1510 |
IToken mark = mark(); |
1505 |
IToken mark = mark(); |
1511 |
consume(); |
1506 |
consume(); |
1512 |
if (templateIdScopes.size() > 0) { |
1507 |
if (templateIdScopes.size() > 0) { |
1513 |
templateIdScopes.push( IToken.tLPAREN ); |
1508 |
templateIdScopes.push(IToken.tLPAREN); |
1514 |
} |
1509 |
} |
1515 |
boolean popped = false; |
1510 |
boolean popped = false; |
1516 |
IASTTypeId typeId = null; |
1511 |
IASTTypeId typeId = null; |
Lines 1531-1544
Link Here
|
1531 |
popped = true; |
1526 |
popped = true; |
1532 |
} |
1527 |
} |
1533 |
IASTExpression castExpression = castExpression(scope, kind, key); |
1528 |
IASTExpression castExpression = castExpression(scope, kind, key); |
1534 |
if( castExpression != null && castExpression.getExpressionKind() == IASTExpression.Kind.PRIMARY_EMPTY ) |
1529 |
if (castExpression != null && castExpression.getExpressionKind() == IASTExpression.Kind.PRIMARY_EMPTY) |
1535 |
{ |
1530 |
{ |
1536 |
backup( mark ); |
1531 |
backup(mark); |
1537 |
if (typeId != null) |
1532 |
if (typeId != null) |
1538 |
typeId.freeReferences(); |
1533 |
typeId.freeReferences(); |
1539 |
return unaryExpression(scope, kind, key); |
1534 |
return unaryExpression(scope, kind, key); |
1540 |
} |
1535 |
} |
1541 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
1536 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
1542 |
mark = null; // clean up mark so that we can garbage collect |
1537 |
mark = null; // clean up mark so that we can garbage collect |
1543 |
try { |
1538 |
try { |
1544 |
return astFactory.createExpression(scope, |
1539 |
return astFactory.createExpression(scope, |
Lines 1728-1734
Link Here
|
1728 |
|
1723 |
|
1729 |
} while (false); |
1724 |
} while (false); |
1730 |
|
1725 |
|
1731 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
1726 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
1732 |
if (kind == null) |
1727 |
if (kind == null) |
1733 |
throwBacktrack(mark.getOffset(), endOffset, mark.getLineNumber(), mark.getFilename()); |
1728 |
throwBacktrack(mark.getOffset(), endOffset, mark.getLineNumber(), mark.getFilename()); |
1734 |
|
1729 |
|
Lines 1737-1744
Link Here
|
1737 |
IToken temp = last; |
1732 |
IToken temp = last; |
1738 |
|
1733 |
|
1739 |
//template parameters are consumed as part of name |
1734 |
//template parameters are consumed as part of name |
1740 |
//lastToken = consumeTemplateParameters( last ); |
1735 |
//lastToken = consumeTemplateParameters(last); |
1741 |
//if( lastToken == null ) lastToken = last; |
1736 |
//if (lastToken == null) lastToken = last; |
1742 |
|
1737 |
|
1743 |
temp = consumePointerOperators(id); |
1738 |
temp = consumePointerOperators(id); |
1744 |
if (temp != null) |
1739 |
if (temp != null) |
Lines 1750-1761
Link Here
|
1750 |
last = temp; |
1745 |
last = temp; |
1751 |
} |
1746 |
} |
1752 |
|
1747 |
|
1753 |
endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
1748 |
endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
1754 |
try { |
1749 |
try { |
1755 |
char[] signature = EMPTY_STRING; |
1750 |
char[] signature = EMPTY_STRING; |
1756 |
if (last != null) |
1751 |
if (last != null) |
1757 |
{ |
1752 |
{ |
1758 |
if( lastToken == null ) |
1753 |
if (lastToken == null) |
1759 |
lastToken = last; |
1754 |
lastToken = last; |
1760 |
signature = TokenFactory.createCharArrayRepresentation(mark, last); |
1755 |
signature = TokenFactory.createCharArrayRepresentation(mark, last); |
1761 |
} |
1756 |
} |
Lines 1807-1813
Link Here
|
1807 |
vectored = true; |
1802 |
vectored = true; |
1808 |
} |
1803 |
} |
1809 |
IASTExpression castExpression = castExpression(scope, kind, key); |
1804 |
IASTExpression castExpression = castExpression(scope, kind, key); |
1810 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
1805 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
1811 |
try { |
1806 |
try { |
1812 |
return astFactory.createExpression(scope, (vectored |
1807 |
return astFactory.createExpression(scope, (vectored |
1813 |
? IASTExpression.Kind.DELETE_VECTORCASTEXPRESSION |
1808 |
? IASTExpression.Kind.DELETE_VECTORCASTEXPRESSION |
Lines 1830-1842
Link Here
|
1830 |
* |
1825 |
* |
1831 |
* |
1826 |
* |
1832 |
* newexpression: ::? new newplacement? newtypeid newinitializer? |
1827 |
* newexpression: ::? new newplacement? newtypeid newinitializer? |
1833 |
* ::? new newplacement? ( typeid ) newinitializer? |
1828 |
* ::? new newplacement? (typeid) newinitializer? |
1834 |
* newplacement: ( expressionlist ) |
1829 |
* newplacement: (expressionlist) |
1835 |
* newtypeid: typespecifierseq newdeclarator? |
1830 |
* newtypeid: typespecifierseq newdeclarator? |
1836 |
* newdeclarator: ptroperator newdeclarator? | directnewdeclarator |
1831 |
* newdeclarator: ptroperator newdeclarator? | directnewdeclarator |
1837 |
* directnewdeclarator: [ expression ] |
1832 |
* directnewdeclarator: [ expression ] |
1838 |
* directnewdeclarator [ constantexpression ] |
1833 |
* directnewdeclarator [ constantexpression ] |
1839 |
* newinitializer: ( expressionlist? ) |
1834 |
* newinitializer: (expressionlist?) |
1840 |
*/ |
1835 |
*/ |
1841 |
protected IASTExpression newExpression(IASTScope scope, KeywordSetKey key) |
1836 |
protected IASTExpression newExpression(IASTScope scope, KeywordSetKey key) |
1842 |
throws BacktrackException, EndOfFileException { |
1837 |
throws BacktrackException, EndOfFileException { |
Lines 1945-1951
Link Here
|
1945 |
// Worst-case scenario - this cannot be resolved w/o more semantic information. |
1940 |
// Worst-case scenario - this cannot be resolved w/o more semantic information. |
1946 |
// Luckily, we don't need to know what was that - we only know that |
1941 |
// Luckily, we don't need to know what was that - we only know that |
1947 |
// new-expression ends here. |
1942 |
// new-expression ends here. |
1948 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
1943 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
1949 |
try { |
1944 |
try { |
1950 |
setCompletionValues(scope, |
1945 |
setCompletionValues(scope, |
1951 |
CompletionKind.NO_SUCH_KIND, |
1946 |
CompletionKind.NO_SUCH_KIND, |
Lines 2020-2026
Link Here
|
2020 |
} |
2015 |
} |
2021 |
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND, |
2016 |
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND, |
2022 |
KeywordSetKey.EMPTY); |
2017 |
KeywordSetKey.EMPTY); |
2023 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
2018 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
2024 |
try { |
2019 |
try { |
2025 |
return astFactory.createExpression(scope, |
2020 |
return astFactory.createExpression(scope, |
2026 |
IASTExpression.Kind.NEW_TYPEID, null, null, null, typeId, |
2021 |
IASTExpression.Kind.NEW_TYPEID, null, null, null, typeId, |
Lines 2103-2109
Link Here
|
2103 |
} else { |
2098 |
} else { |
2104 |
unaryExpression = unaryExpression(scope, kind, key); |
2099 |
unaryExpression = unaryExpression(scope, kind, key); |
2105 |
} |
2100 |
} |
2106 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
2101 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
2107 |
if (unaryExpression == null) |
2102 |
if (unaryExpression == null) |
2108 |
try { |
2103 |
try { |
2109 |
return astFactory.createExpression(scope, |
2104 |
return astFactory.createExpression(scope, |
Lines 2206-2212
Link Here
|
2206 |
throwBacktrack(startingOffset, endOffset, line, fn); |
2201 |
throwBacktrack(startingOffset, endOffset, line, fn); |
2207 |
} |
2202 |
} |
2208 |
break; |
2203 |
break; |
2209 |
// simple-type-specifier ( assignment-expression , .. ) |
2204 |
// simple-type-specifier (assignment-expression , ..) |
2210 |
case IToken.t_char : |
2205 |
case IToken.t_char : |
2211 |
firstExpression = simpleTypeConstructorExpression(scope, |
2206 |
firstExpression = simpleTypeConstructorExpression(scope, |
2212 |
IASTExpression.Kind.POSTFIX_SIMPLETYPE_CHAR, key); |
2207 |
IASTExpression.Kind.POSTFIX_SIMPLETYPE_CHAR, key); |
Lines 2422-2431
Link Here
|
2422 |
memberCompletionKind); |
2417 |
memberCompletionKind); |
2423 |
secondExpression = primaryExpression(scope, |
2418 |
secondExpression = primaryExpression(scope, |
2424 |
CompletionKind.MEMBER_REFERENCE, key); |
2419 |
CompletionKind.MEMBER_REFERENCE, key); |
2425 |
endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
2420 |
endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
2426 |
if (secondExpression != null |
2421 |
if (secondExpression != null |
2427 |
&& secondExpression.getExpressionKind() == Kind.ID_EXPRESSION |
2422 |
&& secondExpression.getExpressionKind() == Kind.ID_EXPRESSION |
2428 |
&& CharArrayUtils.indexOf( '~', secondExpression.getIdExpressionCharArray() ) != -1) |
2423 |
&& CharArrayUtils.indexOf('~', secondExpression.getIdExpressionCharArray()) != -1) |
2429 |
memberCompletionKind = Kind.POSTFIX_DOT_DESTRUCTOR; |
2424 |
memberCompletionKind = Kind.POSTFIX_DOT_DESTRUCTOR; |
2430 |
|
2425 |
|
2431 |
try { |
2426 |
try { |
Lines 2460-2469
Link Here
|
2460 |
arrowCompletionKind); |
2455 |
arrowCompletionKind); |
2461 |
secondExpression = primaryExpression(scope, |
2456 |
secondExpression = primaryExpression(scope, |
2462 |
CompletionKind.MEMBER_REFERENCE, key); |
2457 |
CompletionKind.MEMBER_REFERENCE, key); |
2463 |
endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
2458 |
endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
2464 |
if (secondExpression != null |
2459 |
if (secondExpression != null |
2465 |
&& secondExpression.getExpressionKind() == Kind.ID_EXPRESSION |
2460 |
&& secondExpression.getExpressionKind() == Kind.ID_EXPRESSION |
2466 |
&& CharArrayUtils.indexOf( '~', secondExpression.getIdExpressionCharArray() ) != -1) |
2461 |
&& CharArrayUtils.indexOf('~', secondExpression.getIdExpressionCharArray()) != -1) |
2467 |
arrowCompletionKind = Kind.POSTFIX_ARROW_DESTRUCTOR; |
2462 |
arrowCompletionKind = Kind.POSTFIX_ARROW_DESTRUCTOR; |
2468 |
try { |
2463 |
try { |
2469 |
firstExpression = astFactory.createExpression(scope, |
2464 |
firstExpression = astFactory.createExpression(scope, |
Lines 2505-2511
Link Here
|
2505 |
} |
2500 |
} |
2506 |
|
2501 |
|
2507 |
protected void checkEndOfFile() throws EndOfFileException { |
2502 |
protected void checkEndOfFile() throws EndOfFileException { |
2508 |
if( mode != ParserMode.SELECTION_PARSE ) |
2503 |
if (mode != ParserMode.SELECTION_PARSE) |
2509 |
LA(1); |
2504 |
LA(1); |
2510 |
} |
2505 |
} |
2511 |
|
2506 |
|
Lines 2595-2601
Link Here
|
2595 |
throwBacktrack(e3.getProblem()); |
2590 |
throwBacktrack(e3.getProblem()); |
2596 |
} catch (Exception e) { |
2591 |
} catch (Exception e) { |
2597 |
logException("primaryExpression_4::createExpression()", e); //$NON-NLS-1$ |
2592 |
logException("primaryExpression_4::createExpression()", e); //$NON-NLS-1$ |
2598 |
throwBacktrack(t.getOffset(), t.getEndOffset(), t.getLineNumber(), t.getFilename() ); |
2593 |
throwBacktrack(t.getOffset(), t.getEndOffset(), t.getLineNumber(), t.getFilename()); |
2599 |
} |
2594 |
} |
2600 |
|
2595 |
|
2601 |
case IToken.tCHAR : |
2596 |
case IToken.tCHAR : |
Lines 2626-2635
Link Here
|
2626 |
throwBacktrack(t.getOffset(), t.getEndOffset(), t.getLineNumber(), t.getFilename()); |
2621 |
throwBacktrack(t.getOffset(), t.getEndOffset(), t.getLineNumber(), t.getFilename()); |
2627 |
} |
2622 |
} |
2628 |
case IToken.tLPAREN : |
2623 |
case IToken.tLPAREN : |
2629 |
if( LT(2) == IToken.tLBRACE && extension.supportsStatementsInExpressions() ) |
2624 |
if (LT(2) == IToken.tLBRACE && extension.supportsStatementsInExpressions()) |
2630 |
{ |
2625 |
{ |
2631 |
IASTExpression resultExpression = compoundStatementExpression(scope, LA(1), null); |
2626 |
IASTExpression resultExpression = compoundStatementExpression(scope, LA(1), null); |
2632 |
if( resultExpression != null ) |
2627 |
if (resultExpression != null) |
2633 |
return resultExpression; |
2628 |
return resultExpression; |
2634 |
} |
2629 |
} |
2635 |
t = consume(); |
2630 |
t = consume(); |
Lines 2649-2655
Link Here
|
2649 |
throwBacktrack(e6.getProblem()); |
2644 |
throwBacktrack(e6.getProblem()); |
2650 |
} catch (Exception e) { |
2645 |
} catch (Exception e) { |
2651 |
logException("primaryExpression_7::createExpression()", e); //$NON-NLS-1$ |
2646 |
logException("primaryExpression_7::createExpression()", e); //$NON-NLS-1$ |
2652 |
throwBacktrack(t.getOffset(), endOffset, t.getLineNumber(), t.getFilename() ); |
2647 |
throwBacktrack(t.getOffset(), endOffset, t.getLineNumber(), t.getFilename()); |
2653 |
} |
2648 |
} |
2654 |
case IToken.tIDENTIFIER : |
2649 |
case IToken.tIDENTIFIER : |
2655 |
case IToken.tCOLONCOLON : |
2650 |
case IToken.tCOLONCOLON : |
Lines 2689-2695
Link Here
|
2689 |
duple = d.getNameDuple(); |
2684 |
duple = d.getNameDuple(); |
2690 |
} |
2685 |
} |
2691 |
|
2686 |
|
2692 |
endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
2687 |
endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
2693 |
try { |
2688 |
try { |
2694 |
return astFactory.createExpression(scope, |
2689 |
return astFactory.createExpression(scope, |
2695 |
IASTExpression.Kind.ID_EXPRESSION, null, null, |
2690 |
IASTExpression.Kind.ID_EXPRESSION, null, null, |
Lines 2717-2723
Link Here
|
2717 |
IASTExpression.Kind.PRIMARY_EMPTY, null, null, |
2712 |
IASTExpression.Kind.PRIMARY_EMPTY, null, null, |
2718 |
null, null, null, EMPTY_STRING, null, (ITokenDuple)la); |
2713 |
null, null, null, EMPTY_STRING, null, (ITokenDuple)la); |
2719 |
} catch (ASTSemanticException e9) { |
2714 |
} catch (ASTSemanticException e9) { |
2720 |
throwBacktrack( e9.getProblem() ); |
2715 |
throwBacktrack(e9.getProblem()); |
2721 |
return null; |
2716 |
return null; |
2722 |
} catch (Exception e) { |
2717 |
} catch (Exception e) { |
2723 |
logException("primaryExpression_9::createExpression()", e); //$NON-NLS-1$ |
2718 |
logException("primaryExpression_9::createExpression()", e); //$NON-NLS-1$ |
Lines 2755-2761
Link Here
|
2755 |
IToken t = consume(); |
2750 |
IToken t = consume(); |
2756 |
IASTExpression assignmentExpression = assignmentExpression(scope, |
2751 |
IASTExpression assignmentExpression = assignmentExpression(scope, |
2757 |
completionKind, key); |
2752 |
completionKind, key); |
2758 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
2753 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
2759 |
try { |
2754 |
try { |
2760 |
return astFactory.createExpression(scope, kind, lhs, |
2755 |
return astFactory.createExpression(scope, kind, lhs, |
2761 |
assignmentExpression, null, null, null, EMPTY_STRING, null, (ITokenDuple)t); |
2756 |
assignmentExpression, null, null, null, EMPTY_STRING, null, (ITokenDuple)t); |
Lines 2778-2784
Link Here
|
2778 |
char [] fn = la.getFilename(); |
2773 |
char [] fn = la.getFilename(); |
2779 |
IASTExpression castExpression = castExpression(scope, completionKind, |
2774 |
IASTExpression castExpression = castExpression(scope, completionKind, |
2780 |
key); |
2775 |
key); |
2781 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
2776 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
2782 |
try { |
2777 |
try { |
2783 |
return astFactory.createExpression(scope, kind, castExpression, |
2778 |
return astFactory.createExpression(scope, kind, castExpression, |
2784 |
null, null, null, null, EMPTY_STRING, null, (ITokenDuple)la); |
2779 |
null, null, null, null, EMPTY_STRING, null, (ITokenDuple)la); |
Lines 2814-2820
Link Here
|
2814 |
throwBacktrack(e.getProblem()); |
2809 |
throwBacktrack(e.getProblem()); |
2815 |
} catch (Exception e) { |
2810 |
} catch (Exception e) { |
2816 |
logException("specialCastExpression::createExpression()", e); //$NON-NLS-1$ |
2811 |
logException("specialCastExpression::createExpression()", e); //$NON-NLS-1$ |
2817 |
throwBacktrack(startingOffset, endOffset, line, fn ); |
2812 |
throwBacktrack(startingOffset, endOffset, line, fn); |
2818 |
} |
2813 |
} |
2819 |
return null; |
2814 |
return null; |
2820 |
} |
2815 |
} |
Lines 2841-2847
Link Here
|
2841 |
*/ |
2836 |
*/ |
2842 |
public IToken identifier() throws EndOfFileException, BacktrackException { |
2837 |
public IToken identifier() throws EndOfFileException, BacktrackException { |
2843 |
IToken first = consume(IToken.tIDENTIFIER); // throws backtrack if its not that |
2838 |
IToken first = consume(IToken.tIDENTIFIER); // throws backtrack if its not that |
2844 |
if( first instanceof ITokenDuple ) setGreaterNameContext((ITokenDuple) first); |
2839 |
if (first instanceof ITokenDuple) setGreaterNameContext((ITokenDuple) first); |
2845 |
return first; |
2840 |
return first; |
2846 |
} |
2841 |
} |
2847 |
|
2842 |
|
Lines 2870-2878
Link Here
|
2870 |
* @throws EndOfFileException |
2865 |
* @throws EndOfFileException |
2871 |
*/ |
2866 |
*/ |
2872 |
protected void errorHandling() throws EndOfFileException { |
2867 |
protected void errorHandling() throws EndOfFileException { |
2873 |
int depth = ( LT(1) == IToken.tLBRACE ) ? 1 : 0; |
2868 |
int depth = (LT(1) == IToken.tLBRACE) ? 1 : 0; |
2874 |
int type = consume().getType(); |
2869 |
int type = consume().getType(); |
2875 |
if( type == IToken.tSEMI ) return; |
2870 |
if (type == IToken.tSEMI) return; |
2876 |
while (!((LT(1) == IToken.tSEMI && depth == 0) |
2871 |
while (!((LT(1) == IToken.tSEMI && depth == 0) |
2877 |
|| (LT(1) == IToken.tRBRACE && depth == 1))) |
2872 |
|| (LT(1) == IToken.tRBRACE && depth == 1))) |
2878 |
{ |
2873 |
{ |
Lines 2885-2891
Link Here
|
2885 |
--depth; |
2880 |
--depth; |
2886 |
break; |
2881 |
break; |
2887 |
} |
2882 |
} |
2888 |
if( depth < 0 ) |
2883 |
if (depth < 0) |
2889 |
return; |
2884 |
return; |
2890 |
|
2885 |
|
2891 |
consume(); |
2886 |
consume(); |
Lines 2907-2913
Link Here
|
2907 |
IScanner scanner, |
2902 |
IScanner scanner, |
2908 |
ParserMode mode, |
2903 |
ParserMode mode, |
2909 |
ISourceElementRequestor callback, |
2904 |
ISourceElementRequestor callback, |
2910 |
ParserLanguage language, IParserLogService log, IParserExtension extension ) |
2905 |
ParserLanguage language, IParserLogService log, IParserExtension extension) |
2911 |
{ |
2906 |
{ |
2912 |
this.parserStartFilename = scanner.getMainFilename(); |
2907 |
this.parserStartFilename = scanner.getMainFilename(); |
2913 |
this.scanner = scanner; |
2908 |
this.scanner = scanner; |
Lines 2917-2923
Link Here
|
2917 |
this.mode = mode; |
2912 |
this.mode = mode; |
2918 |
setupASTFactory(scanner, language); |
2913 |
setupASTFactory(scanner, language); |
2919 |
requestor = callback; |
2914 |
requestor = callback; |
2920 |
if( this.mode == ParserMode.QUICK_PARSE ) |
2915 |
if (this.mode == ParserMode.QUICK_PARSE) |
2921 |
constructInitializersInDeclarations = false; |
2916 |
constructInitializersInDeclarations = false; |
2922 |
} |
2917 |
} |
2923 |
|
2918 |
|
Lines 2928-2957
Link Here
|
2928 |
* |
2923 |
* |
2929 |
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#failParse() |
2924 |
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#failParse() |
2930 |
*/ |
2925 |
*/ |
2931 |
protected void failParse( BacktrackException bt ) { |
2926 |
protected void failParse(BacktrackException bt) { |
2932 |
if( bt.getProblem() == null ) |
2927 |
if (bt.getProblem() == null) |
2933 |
{ |
2928 |
{ |
2934 |
IProblem problem = problemFactory.createProblem( |
2929 |
IProblem problem = problemFactory.createProblem( |
2935 |
IProblem.SYNTAX_ERROR, |
2930 |
IProblem.SYNTAX_ERROR, |
2936 |
bt.getStartingOffset(), |
2931 |
bt.getStartingOffset(), |
2937 |
bt.getEndOffset(), |
2932 |
bt.getEndOffset(), |
2938 |
bt.getLineNumber(), |
2933 |
bt.getLineNumber(), |
2939 |
bt.getFilename(), |
2934 |
bt.getFilename(), |
2940 |
EMPTY_STRING, |
2935 |
EMPTY_STRING_ARRAY, |
2941 |
false, |
2936 |
false, |
2942 |
true ); |
2937 |
true); |
2943 |
requestor.acceptProblem( problem ); |
2938 |
requestor.acceptProblem(problem); |
2944 |
} |
2939 |
} |
2945 |
else |
2940 |
else |
2946 |
{ |
2941 |
{ |
2947 |
requestor.acceptProblem( bt.getProblem() ); |
2942 |
requestor.acceptProblem(bt.getProblem()); |
2948 |
} |
2943 |
} |
2949 |
failParse(); |
2944 |
failParse(); |
2950 |
} |
2945 |
} |
2951 |
|
2946 |
|
2952 |
protected void failParse( IProblem problem ){ |
2947 |
protected void failParse(IProblem problem){ |
2953 |
if( problem != null ){ |
2948 |
if (problem != null){ |
2954 |
requestor.acceptProblem( problem ); |
2949 |
requestor.acceptProblem(problem); |
2955 |
} |
2950 |
} |
2956 |
failParse(); |
2951 |
failParse(); |
2957 |
} |
2952 |
} |
Lines 2977-2983
Link Here
|
2977 |
+ ": " //$NON-NLS-1$ |
2972 |
+ ": " //$NON-NLS-1$ |
2978 |
+ (System.currentTimeMillis() - startTime) |
2973 |
+ (System.currentTimeMillis() - startTime) |
2979 |
+ "ms" //$NON-NLS-1$ |
2974 |
+ "ms" //$NON-NLS-1$ |
2980 |
+ (parsePassed ? "" : " - parse failure") ); //$NON-NLS-1$ //$NON-NLS-2$ |
2975 |
+ (parsePassed ? "" : " - parse failure")); //$NON-NLS-1$ //$NON-NLS-2$ |
2981 |
return parsePassed; |
2976 |
return parsePassed; |
2982 |
} |
2977 |
} |
2983 |
|
2978 |
|
Lines 2995-3009
Link Here
|
2995 |
} |
2990 |
} |
2996 |
catch (Exception e2) |
2991 |
catch (Exception e2) |
2997 |
{ |
2992 |
{ |
2998 |
logException( "translationUnit::createCompilationUnit()", e2 ); //$NON-NLS-1$ |
2993 |
logException("translationUnit::createCompilationUnit()", e2); //$NON-NLS-1$ |
2999 |
return; |
2994 |
return; |
3000 |
} |
2995 |
} |
3001 |
|
2996 |
|
3002 |
compilationUnit.enterScope( requestor ); |
2997 |
compilationUnit.enterScope(requestor); |
3003 |
try { |
2998 |
try { |
3004 |
setCompletionValues(compilationUnit, CompletionKind.VARIABLE_TYPE, KeywordSetKey.DECLARATION ); |
2999 |
setCompletionValues(compilationUnit, CompletionKind.VARIABLE_TYPE, KeywordSetKey.DECLARATION); |
3005 |
} catch (EndOfFileException e1) { |
3000 |
} catch (EndOfFileException e1) { |
3006 |
compilationUnit.exitScope( requestor ); |
3001 |
compilationUnit.exitScope(requestor); |
3007 |
return; |
3002 |
return; |
3008 |
} |
3003 |
} |
3009 |
|
3004 |
|
Lines 3047-3098
Link Here
|
3047 |
break; |
3042 |
break; |
3048 |
} |
3043 |
} |
3049 |
} |
3044 |
} |
3050 |
catch( OutOfMemoryError oome ) |
3045 |
catch (OutOfMemoryError oome) |
3051 |
{ |
3046 |
{ |
3052 |
logThrowable( "translationUnit", oome ); //$NON-NLS-1$ |
3047 |
logThrowable("translationUnit", oome); //$NON-NLS-1$ |
3053 |
throw oome; |
3048 |
throw oome; |
3054 |
} |
3049 |
} |
3055 |
catch( Exception e ) |
3050 |
catch (Exception e) |
3056 |
{ |
3051 |
{ |
3057 |
logException( "translationUnit", e ); //$NON-NLS-1$ |
3052 |
logException("translationUnit", e); //$NON-NLS-1$ |
3058 |
try { |
3053 |
try { |
3059 |
failParseWithErrorHandling(); |
3054 |
failParseWithErrorHandling(); |
3060 |
} catch (EndOfFileException e3) { |
3055 |
} catch (EndOfFileException e3) { |
3061 |
} |
3056 |
} |
3062 |
} |
3057 |
} |
3063 |
catch( ParseError perr ) |
3058 |
catch (ParseError perr) |
3064 |
{ |
3059 |
{ |
3065 |
throw perr; |
3060 |
throw perr; |
3066 |
} |
3061 |
} |
3067 |
catch (Throwable e) |
3062 |
catch (Throwable e) |
3068 |
{ |
3063 |
{ |
3069 |
logThrowable( "translationUnit", e ); //$NON-NLS-1$ |
3064 |
logThrowable("translationUnit", e); //$NON-NLS-1$ |
3070 |
try { |
3065 |
try { |
3071 |
failParseWithErrorHandling(); |
3066 |
failParseWithErrorHandling(); |
3072 |
} catch (EndOfFileException e3) { |
3067 |
} catch (EndOfFileException e3) { |
3073 |
} |
3068 |
} |
3074 |
} |
3069 |
} |
3075 |
} |
3070 |
} |
3076 |
compilationUnit.exitScope( requestor ); |
3071 |
compilationUnit.exitScope(requestor); |
3077 |
} |
3072 |
} |
3078 |
/** |
3073 |
/** |
3079 |
* @param string |
3074 |
* @param string |
3080 |
* @param e |
3075 |
* @param e |
3081 |
*/ |
3076 |
*/ |
3082 |
private void logThrowable(String methodName, Throwable e) { |
3077 |
private void logThrowable(String methodName, Throwable e) { |
3083 |
if( e != null && log.isTracing()) |
3078 |
if (e != null && log.isTracing()) |
3084 |
{ |
3079 |
{ |
3085 |
StringBuffer buffer = new StringBuffer(); |
3080 |
StringBuffer buffer = new StringBuffer(); |
3086 |
buffer.append( "Parser: Unexpected throwable in "); //$NON-NLS-1$ |
3081 |
buffer.append("Parser: Unexpected throwable in "); //$NON-NLS-1$ |
3087 |
buffer.append( methodName ); |
3082 |
buffer.append(methodName); |
3088 |
buffer.append( ":"); //$NON-NLS-1$ |
3083 |
buffer.append(":"); //$NON-NLS-1$ |
3089 |
buffer.append( e.getClass().getName() ); |
3084 |
buffer.append(e.getClass().getName()); |
3090 |
buffer.append( "::"); //$NON-NLS-1$ |
3085 |
buffer.append("::"); //$NON-NLS-1$ |
3091 |
buffer.append( e.getMessage() ); |
3086 |
buffer.append(e.getMessage()); |
3092 |
buffer.append( ". w/"); //$NON-NLS-1$ |
3087 |
buffer.append(". w/"); //$NON-NLS-1$ |
3093 |
buffer.append( scanner.toString() ); |
3088 |
buffer.append(scanner.toString()); |
3094 |
log.traceLog( buffer.toString() ); |
3089 |
log.traceLog(buffer.toString()); |
3095 |
// log.errorLog( buffer.toString() ); |
3090 |
// log.errorLog(buffer.toString()); |
3096 |
} |
3091 |
} |
3097 |
} |
3092 |
} |
3098 |
|
3093 |
|
Lines 3130-3146
Link Here
|
3130 |
throws EndOfFileException, BacktrackException |
3125 |
throws EndOfFileException, BacktrackException |
3131 |
{ |
3126 |
{ |
3132 |
IToken firstToken = consume(IToken.t_using); |
3127 |
IToken firstToken = consume(IToken.t_using); |
3133 |
setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, KeywordSetKey.POST_USING ); |
3128 |
setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, KeywordSetKey.POST_USING); |
3134 |
|
3129 |
|
3135 |
if (LT(1) == IToken.t_namespace) |
3130 |
if (LT(1) == IToken.t_namespace) |
3136 |
{ |
3131 |
{ |
3137 |
// using-directive |
3132 |
// using-directive |
3138 |
consume(IToken.t_namespace); |
3133 |
consume(IToken.t_namespace); |
3139 |
|
3134 |
|
3140 |
setCompletionValues(scope, CompletionKind.NAMESPACE_REFERENCE, KeywordSetKey.EMPTY ); |
3135 |
setCompletionValues(scope, CompletionKind.NAMESPACE_REFERENCE, KeywordSetKey.EMPTY); |
3141 |
// optional :: and nested classes handled in name |
3136 |
// optional :: and nested classes handled in name |
3142 |
ITokenDuple duple = null; |
3137 |
ITokenDuple duple = null; |
3143 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
3138 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
3144 |
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON) |
3139 |
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON) |
3145 |
duple = name(scope, CompletionKind.NAMESPACE_REFERENCE, KeywordSetKey.EMPTY); |
3140 |
duple = name(scope, CompletionKind.NAMESPACE_REFERENCE, KeywordSetKey.EMPTY); |
3146 |
else |
3141 |
else |
Lines 3154-3177
Link Here
|
3154 |
{ |
3149 |
{ |
3155 |
astUD = astFactory.createUsingDirective(scope, duple, firstToken.getOffset(), firstToken.getLineNumber(), last.getEndOffset(), last.getLineNumber()); |
3150 |
astUD = astFactory.createUsingDirective(scope, duple, firstToken.getOffset(), firstToken.getLineNumber(), last.getEndOffset(), last.getLineNumber()); |
3156 |
} |
3151 |
} |
3157 |
catch( ASTSemanticException ase ) |
3152 |
catch (ASTSemanticException ase) |
3158 |
{ |
3153 |
{ |
3159 |
backup( last ); |
3154 |
backup(last); |
3160 |
throwBacktrack( ase.getProblem() ); |
3155 |
throwBacktrack(ase.getProblem()); |
3161 |
} |
3156 |
} |
3162 |
catch (Exception e1) |
3157 |
catch (Exception e1) |
3163 |
{ |
3158 |
{ |
3164 |
logException( "usingClause:createUsingDirective", e1 ); //$NON-NLS-1$ |
3159 |
logException("usingClause:createUsingDirective", e1); //$NON-NLS-1$ |
3165 |
throwBacktrack(firstToken.getOffset(), last.getEndOffset(), firstToken.getLineNumber(), last.getFilename()); |
3160 |
throwBacktrack(firstToken.getOffset(), last.getEndOffset(), firstToken.getLineNumber(), last.getFilename()); |
3166 |
} |
3161 |
} |
3167 |
astUD.acceptElement(requestor ); |
3162 |
astUD.acceptElement(requestor); |
3168 |
return astUD; |
3163 |
return astUD; |
3169 |
} |
3164 |
} |
3170 |
endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
3165 |
endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
3171 |
throwBacktrack(firstToken.getOffset(), endOffset, firstToken.getLineNumber(), firstToken.getFilename()); |
3166 |
throwBacktrack(firstToken.getOffset(), endOffset, firstToken.getLineNumber(), firstToken.getFilename()); |
3172 |
} |
3167 |
} |
3173 |
boolean typeName = false; |
3168 |
boolean typeName = false; |
3174 |
setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, KeywordSetKey.POST_USING ); |
3169 |
setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, KeywordSetKey.POST_USING); |
3175 |
|
3170 |
|
3176 |
if (LT(1) == IToken.t_typename) |
3171 |
if (LT(1) == IToken.t_typename) |
3177 |
{ |
3172 |
{ |
Lines 3179-3185
Link Here
|
3179 |
consume(IToken.t_typename); |
3174 |
consume(IToken.t_typename); |
3180 |
} |
3175 |
} |
3181 |
|
3176 |
|
3182 |
setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, KeywordSetKey.NAMESPACE_ONLY ); |
3177 |
setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, KeywordSetKey.NAMESPACE_ONLY); |
3183 |
ITokenDuple name = null; |
3178 |
ITokenDuple name = null; |
3184 |
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON) |
3179 |
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON) |
3185 |
{ |
3180 |
{ |
Lines 3188-3194
Link Here
|
3188 |
} |
3183 |
} |
3189 |
else |
3184 |
else |
3190 |
{ |
3185 |
{ |
3191 |
throwBacktrack(firstToken.getOffset(), ( lastToken != null ) ? lastToken.getEndOffset() : 0, firstToken.getLineNumber(), firstToken.getFilename()); |
3186 |
throwBacktrack(firstToken.getOffset(), (lastToken != null) ? lastToken.getEndOffset() : 0, firstToken.getLineNumber(), firstToken.getFilename()); |
3192 |
} |
3187 |
} |
3193 |
if (LT(1) == IToken.tSEMI) |
3188 |
if (LT(1) == IToken.tSEMI) |
3194 |
{ |
3189 |
{ |
Lines 3206-3222
Link Here
|
3206 |
} |
3201 |
} |
3207 |
catch (Exception e1) |
3202 |
catch (Exception e1) |
3208 |
{ |
3203 |
{ |
3209 |
logException( "usingClause:createUsingDeclaration", e1 ); //$NON-NLS-1$ |
3204 |
logException("usingClause:createUsingDeclaration", e1); //$NON-NLS-1$ |
3210 |
if( e1 instanceof ASTSemanticException && ((ASTSemanticException)e1).getProblem() != null ) |
3205 |
if (e1 instanceof ASTSemanticException && ((ASTSemanticException)e1).getProblem() != null) |
3211 |
throwBacktrack(((ASTSemanticException)e1).getProblem()); |
3206 |
throwBacktrack(((ASTSemanticException)e1).getProblem()); |
3212 |
else |
3207 |
else |
3213 |
throwBacktrack(firstToken.getOffset(), last.getEndOffset(), firstToken.getLineNumber(), firstToken.getFilename()); |
3208 |
throwBacktrack(firstToken.getOffset(), last.getEndOffset(), firstToken.getLineNumber(), firstToken.getFilename()); |
3214 |
} |
3209 |
} |
3215 |
declaration.acceptElement( requestor ); |
3210 |
declaration.acceptElement(requestor); |
3216 |
setCompletionValues(scope, getCompletionKindForDeclaration(scope, null), KeywordSetKey.DECLARATION ); |
3211 |
setCompletionValues(scope, getCompletionKindForDeclaration(scope, null), KeywordSetKey.DECLARATION); |
3217 |
return declaration; |
3212 |
return declaration; |
3218 |
} |
3213 |
} |
3219 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
3214 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
3220 |
throwBacktrack(firstToken.getOffset(), endOffset, firstToken.getLineNumber(), firstToken.getFilename()); |
3215 |
throwBacktrack(firstToken.getOffset(), endOffset, firstToken.getLineNumber(), firstToken.getFilename()); |
3221 |
return null; |
3216 |
return null; |
3222 |
} |
3217 |
} |
Lines 3255-3265
Link Here
|
3255 |
} |
3250 |
} |
3256 |
catch (Exception e) |
3251 |
catch (Exception e) |
3257 |
{ |
3252 |
{ |
3258 |
logException( "linkageSpecification_1:createLinkageSpecification", e ); //$NON-NLS-1$ |
3253 |
logException("linkageSpecification_1:createLinkageSpecification", e); //$NON-NLS-1$ |
3259 |
throwBacktrack(firstToken.getOffset(), lbrace.getEndOffset(), lbrace.getLineNumber(), lbrace.getFilename()); |
3254 |
throwBacktrack(firstToken.getOffset(), lbrace.getEndOffset(), lbrace.getLineNumber(), lbrace.getFilename()); |
3260 |
} |
3255 |
} |
3261 |
|
3256 |
|
3262 |
linkage.enterScope( requestor ); |
3257 |
linkage.enterScope(requestor); |
3263 |
try |
3258 |
try |
3264 |
{ |
3259 |
{ |
3265 |
linkageDeclarationLoop : while (LT(1) != IToken.tRBRACE) |
3260 |
linkageDeclarationLoop : while (LT(1) != IToken.tRBRACE) |
Lines 3291-3303
Link Here
|
3291 |
} |
3286 |
} |
3292 |
finally |
3287 |
finally |
3293 |
{ |
3288 |
{ |
3294 |
linkage.exitScope( requestor ); |
3289 |
linkage.exitScope(requestor); |
3295 |
} |
3290 |
} |
3296 |
return linkage; |
3291 |
return linkage; |
3297 |
} |
3292 |
} |
3298 |
// single declaration |
3293 |
// single declaration |
3299 |
|
3294 |
|
3300 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0; |
3295 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0; |
3301 |
IASTLinkageSpecification linkage; |
3296 |
IASTLinkageSpecification linkage; |
3302 |
try |
3297 |
try |
3303 |
{ |
3298 |
{ |
Lines 3309-3326
Link Here
|
3309 |
} |
3304 |
} |
3310 |
catch (Exception e) |
3305 |
catch (Exception e) |
3311 |
{ |
3306 |
{ |
3312 |
logException( "linkageSpecification_2:createLinkageSpecification", e ); //$NON-NLS-1$ |
3307 |
logException("linkageSpecification_2:createLinkageSpecification", e); //$NON-NLS-1$ |
3313 |
throwBacktrack(firstToken.getOffset(), endOffset, firstToken.getLineNumber(), firstToken.getFilename()); |
3308 |
throwBacktrack(firstToken.getOffset(), endOffset, firstToken.getLineNumber(), firstToken.getFilename()); |
3314 |
return null; |
3309 |
return null; |
3315 |
} |
3310 |
} |
3316 |
linkage.enterScope( requestor ); |
3311 |
linkage.enterScope(requestor); |
3317 |
try |
3312 |
try |
3318 |
{ |
3313 |
{ |
3319 |
declaration(linkage, null, null, KeywordSetKey.DECLARATION); |
3314 |
declaration(linkage, null, null, KeywordSetKey.DECLARATION); |
3320 |
} |
3315 |
} |
3321 |
finally |
3316 |
finally |
3322 |
{ |
3317 |
{ |
3323 |
linkage.exitScope( requestor ); |
3318 |
linkage.exitScope(requestor); |
3324 |
} |
3319 |
} |
3325 |
return linkage; |
3320 |
return linkage; |
3326 |
|
3321 |
|
Lines 3355-3364
Link Here
|
3355 |
} |
3350 |
} |
3356 |
else |
3351 |
else |
3357 |
{ |
3352 |
{ |
3358 |
if( extension.supportsExtendedTemplateInstantiationSyntax() && extension.isValidModifierForInstantiation(LA(1))) |
3353 |
if (extension.supportsExtendedTemplateInstantiationSyntax() && extension.isValidModifierForInstantiation(LA(1))) |
3359 |
{ |
3354 |
{ |
3360 |
firstToken = consume(); // consume the modifier |
3355 |
firstToken = consume(); // consume the modifier |
3361 |
consume( IToken.t_template ); |
3356 |
consume(IToken.t_template); |
3362 |
} |
3357 |
} |
3363 |
else |
3358 |
else |
3364 |
firstToken = consume(IToken.t_template); |
3359 |
firstToken = consume(IToken.t_template); |
Lines 3376-3394
Link Here
|
3376 |
} |
3371 |
} |
3377 |
catch (Exception e) |
3372 |
catch (Exception e) |
3378 |
{ |
3373 |
{ |
3379 |
logException( "templateDeclaration:createTemplateInstantiation", e ); //$NON-NLS-1$ |
3374 |
logException("templateDeclaration:createTemplateInstantiation", e); //$NON-NLS-1$ |
3380 |
backup( mark ); |
3375 |
backup(mark); |
3381 |
throwBacktrack(firstToken.getOffset(), firstToken.getEndOffset(), firstToken.getLineNumber(), firstToken.getFilename()); |
3376 |
throwBacktrack(firstToken.getOffset(), firstToken.getEndOffset(), firstToken.getLineNumber(), firstToken.getFilename()); |
3382 |
return null; |
3377 |
return null; |
3383 |
} |
3378 |
} |
3384 |
templateInstantiation.enterScope( requestor ); |
3379 |
templateInstantiation.enterScope(requestor); |
3385 |
try |
3380 |
try |
3386 |
{ |
3381 |
{ |
3387 |
declaration(templateInstantiation, templateInstantiation, null, KeywordSetKey.DECLARATION); |
3382 |
declaration(templateInstantiation, templateInstantiation, null, KeywordSetKey.DECLARATION); |
3388 |
templateInstantiation.setEndingOffsetAndLineNumber(lastToken.getEndOffset(), lastToken.getLineNumber()); |
3383 |
templateInstantiation.setEndingOffsetAndLineNumber(lastToken.getEndOffset(), lastToken.getLineNumber()); |
3389 |
} finally |
3384 |
} finally |
3390 |
{ |
3385 |
{ |
3391 |
templateInstantiation.exitScope( requestor ); |
3386 |
templateInstantiation.exitScope(requestor); |
3392 |
} |
3387 |
} |
3393 |
|
3388 |
|
3394 |
return templateInstantiation; |
3389 |
return templateInstantiation; |
Lines 3409-3416
Link Here
|
3409 |
} |
3404 |
} |
3410 |
catch (Exception e) |
3405 |
catch (Exception e) |
3411 |
{ |
3406 |
{ |
3412 |
logException( "templateDeclaration:createTemplateSpecialization", e ); //$NON-NLS-1$ |
3407 |
logException("templateDeclaration:createTemplateSpecialization", e); //$NON-NLS-1$ |
3413 |
backup( mark ); |
3408 |
backup(mark); |
3414 |
throwBacktrack(firstToken.getOffset(), gt.getEndOffset(), gt.getLineNumber(), gt.getFilename()); |
3409 |
throwBacktrack(firstToken.getOffset(), gt.getEndOffset(), gt.getLineNumber(), gt.getFilename()); |
3415 |
return null; |
3410 |
return null; |
3416 |
} |
3411 |
} |
Lines 3445-3467
Link Here
|
3445 |
} |
3440 |
} |
3446 |
catch (Exception e) |
3441 |
catch (Exception e) |
3447 |
{ |
3442 |
{ |
3448 |
logException( "templateDeclaration:createTemplateDeclaration", e ); //$NON-NLS-1$ |
3443 |
logException("templateDeclaration:createTemplateDeclaration", e); //$NON-NLS-1$ |
3449 |
throwBacktrack(firstToken.getOffset(), gt.getEndOffset(), gt.getLineNumber(), gt.getFilename()); |
3444 |
throwBacktrack(firstToken.getOffset(), gt.getEndOffset(), gt.getLineNumber(), gt.getFilename()); |
3450 |
return null; |
3445 |
return null; |
3451 |
} |
3446 |
} |
3452 |
templateDecl.enterScope( requestor ); |
3447 |
templateDecl.enterScope(requestor); |
3453 |
try{ |
3448 |
try{ |
3454 |
declaration(templateDecl, templateDecl, null, KeywordSetKey.DECLARATION ); |
3449 |
declaration(templateDecl, templateDecl, null, KeywordSetKey.DECLARATION); |
3455 |
templateDecl.setEndingOffsetAndLineNumber( lastToken.getEndOffset(), lastToken.getLineNumber() ); |
3450 |
templateDecl.setEndingOffsetAndLineNumber(lastToken.getEndOffset(), lastToken.getLineNumber()); |
3456 |
} finally |
3451 |
} finally |
3457 |
{ |
3452 |
{ |
3458 |
templateDecl.exitScope( requestor ); |
3453 |
templateDecl.exitScope(requestor); |
3459 |
} |
3454 |
} |
3460 |
return templateDecl; |
3455 |
return templateDecl; |
3461 |
} |
3456 |
} |
3462 |
catch (BacktrackException bt) |
3457 |
catch (BacktrackException bt) |
3463 |
{ |
3458 |
{ |
3464 |
backup( mark ); |
3459 |
backup(mark); |
3465 |
throw bt; |
3460 |
throw bt; |
3466 |
} |
3461 |
} |
3467 |
} |
3462 |
} |
Lines 3493-3500
Link Here
|
3493 |
// iterate through the template parameter list |
3488 |
// iterate through the template parameter list |
3494 |
List returnValue = new ArrayList(); |
3489 |
List returnValue = new ArrayList(); |
3495 |
|
3490 |
|
3496 |
IASTScope parameterScope = astFactory.createNewCodeBlock( scope ); |
3491 |
IASTScope parameterScope = astFactory.createNewCodeBlock(scope); |
3497 |
if( parameterScope == null ) |
3492 |
if (parameterScope == null) |
3498 |
parameterScope = scope; |
3493 |
parameterScope = scope; |
3499 |
|
3494 |
|
3500 |
IToken la = LA(1); |
3495 |
IToken la = LA(1); |
Lines 3540-3563
Link Here
|
3540 |
returnValue.add( |
3535 |
returnValue.add( |
3541 |
astFactory.createTemplateParameter( |
3536 |
astFactory.createTemplateParameter( |
3542 |
kind, |
3537 |
kind, |
3543 |
( id == null )? EMPTY_STRING : id.getCharImage(), //$NON-NLS-1$ |
3538 |
(id == null)? EMPTY_STRING : id.getCharImage(), //$NON-NLS-1$ |
3544 |
typeId, |
3539 |
typeId, |
3545 |
null, |
3540 |
null, |
3546 |
null, |
3541 |
null, |
3547 |
( parameterScope instanceof IASTCodeScope ) ? (IASTCodeScope) parameterScope : null, |
3542 |
(parameterScope instanceof IASTCodeScope) ? (IASTCodeScope) parameterScope : null, |
3548 |
startingToken.getOffset(), startingToken.getLineNumber(), |
3543 |
startingToken.getOffset(), startingToken.getLineNumber(), |
3549 |
nameStart, nameEnd, nameLine, |
3544 |
nameStart, nameEnd, nameLine, |
3550 |
(lastToken != null ) ? lastToken.getEndOffset() : nameEnd, |
3545 |
(lastToken != null) ? lastToken.getEndOffset() : nameEnd, |
3551 |
(lastToken != null ) ? lastToken.getLineNumber() : nameLine, startingToken.getFilename() )); |
3546 |
(lastToken != null) ? lastToken.getLineNumber() : nameLine, startingToken.getFilename())); |
3552 |
} |
3547 |
} |
3553 |
catch( ASTSemanticException ase ) |
3548 |
catch (ASTSemanticException ase) |
3554 |
{ |
3549 |
{ |
3555 |
throwBacktrack(ase.getProblem()); |
3550 |
throwBacktrack(ase.getProblem()); |
3556 |
} |
3551 |
} |
3557 |
catch (Exception e) |
3552 |
catch (Exception e) |
3558 |
{ |
3553 |
{ |
3559 |
logException( "templateParameterList_1:createTemplateParameter", e ); //$NON-NLS-1$ |
3554 |
logException("templateParameterList_1:createTemplateParameter", e); //$NON-NLS-1$ |
3560 |
throwBacktrack(startingOffset, ( lastToken != null ) ? lastToken.getEndOffset() : 0, lnum, fn); |
3555 |
throwBacktrack(startingOffset, (lastToken != null) ? lastToken.getEndOffset() : 0, lnum, fn); |
3561 |
} |
3556 |
} |
3562 |
|
3557 |
|
3563 |
} |
3558 |
} |
Lines 3589-3613
Link Here
|
3589 |
returnValue.add( |
3584 |
returnValue.add( |
3590 |
astFactory.createTemplateParameter( |
3585 |
astFactory.createTemplateParameter( |
3591 |
IASTTemplateParameter.ParamKind.TEMPLATE_LIST, |
3586 |
IASTTemplateParameter.ParamKind.TEMPLATE_LIST, |
3592 |
( optionalId == null )? EMPTY_STRING : optionalId.getCharImage(), //$NON-NLS-1$ |
3587 |
(optionalId == null)? EMPTY_STRING : optionalId.getCharImage(), //$NON-NLS-1$ |
3593 |
optionalTypeId, |
3588 |
optionalTypeId, |
3594 |
null, |
3589 |
null, |
3595 |
subResult, |
3590 |
subResult, |
3596 |
( parameterScope instanceof IASTCodeScope ) ? (IASTCodeScope) parameterScope : null, |
3591 |
(parameterScope instanceof IASTCodeScope) ? (IASTCodeScope) parameterScope : null, |
3597 |
startingToken.getOffset(), startingToken.getLineNumber(), |
3592 |
startingToken.getOffset(), startingToken.getLineNumber(), |
3598 |
(optionalId != null) ? optionalId.getOffset() : 0, |
3593 |
(optionalId != null) ? optionalId.getOffset() : 0, |
3599 |
(optionalId != null) ? optionalId.getEndOffset() : 0, |
3594 |
(optionalId != null) ? optionalId.getEndOffset() : 0, |
3600 |
(optionalId != null) ? optionalId.getLineNumber() : 0, |
3595 |
(optionalId != null) ? optionalId.getLineNumber() : 0, |
3601 |
lastToken.getEndOffset(), lastToken.getLineNumber(), lastToken.getFilename() )); |
3596 |
lastToken.getEndOffset(), lastToken.getLineNumber(), lastToken.getFilename())); |
3602 |
} |
3597 |
} |
3603 |
catch( ASTSemanticException ase ) |
3598 |
catch (ASTSemanticException ase) |
3604 |
{ |
3599 |
{ |
3605 |
throwBacktrack(ase.getProblem()); |
3600 |
throwBacktrack(ase.getProblem()); |
3606 |
} |
3601 |
} |
3607 |
catch (Exception e) |
3602 |
catch (Exception e) |
3608 |
{ |
3603 |
{ |
3609 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
3604 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
3610 |
logException( "templateParameterList_2:createTemplateParameter", e ); //$NON-NLS-1$ |
3605 |
logException("templateParameterList_2:createTemplateParameter", e); //$NON-NLS-1$ |
3611 |
throwBacktrack(startingOffset, endOffset, lnum, fn); |
3606 |
throwBacktrack(startingOffset, endOffset, lnum, fn); |
3612 |
} |
3607 |
} |
3613 |
} |
3608 |
} |
Lines 3640-3660
Link Here
|
3640 |
declarator.getInitializerClause(), |
3635 |
declarator.getInitializerClause(), |
3641 |
wrapper.getStartingOffset(), wrapper.getStartingLine(), |
3636 |
wrapper.getStartingOffset(), wrapper.getStartingLine(), |
3642 |
declarator.getNameStartOffset(), declarator.getNameEndOffset(), declarator.getNameLine(), |
3637 |
declarator.getNameStartOffset(), declarator.getNameEndOffset(), declarator.getNameLine(), |
3643 |
wrapper.getEndOffset(), wrapper.getEndLine(), fn ), |
3638 |
wrapper.getEndOffset(), wrapper.getEndLine(), fn), |
3644 |
null, |
3639 |
null, |
3645 |
( parameterScope instanceof IASTCodeScope ) ? (IASTCodeScope) parameterScope : null, |
3640 |
(parameterScope instanceof IASTCodeScope) ? (IASTCodeScope) parameterScope : null, |
3646 |
wrapper.getStartingOffset(), wrapper.getStartingLine(), |
3641 |
wrapper.getStartingOffset(), wrapper.getStartingLine(), |
3647 |
declarator.getNameStartOffset(), declarator.getNameEndOffset(), declarator.getNameLine(), |
3642 |
declarator.getNameStartOffset(), declarator.getNameEndOffset(), declarator.getNameLine(), |
3648 |
wrapper.getEndOffset(), wrapper.getEndLine(), fn )); |
3643 |
wrapper.getEndOffset(), wrapper.getEndLine(), fn)); |
3649 |
} |
3644 |
} |
3650 |
catch( ASTSemanticException ase ) |
3645 |
catch (ASTSemanticException ase) |
3651 |
{ |
3646 |
{ |
3652 |
throwBacktrack(ase.getProblem()); |
3647 |
throwBacktrack(ase.getProblem()); |
3653 |
} |
3648 |
} |
3654 |
catch (Exception e) |
3649 |
catch (Exception e) |
3655 |
{ |
3650 |
{ |
3656 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
3651 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
3657 |
logException( "templateParameterList:createParameterDeclaration", e ); //$NON-NLS-1$ |
3652 |
logException("templateParameterList:createParameterDeclaration", e); //$NON-NLS-1$ |
3658 |
throwBacktrack(startingOffset, endOffset, lnum, fn); |
3653 |
throwBacktrack(startingOffset, endOffset, lnum, fn); |
3659 |
} |
3654 |
} |
3660 |
} |
3655 |
} |
Lines 3695-3701
Link Here
|
3695 |
{ |
3690 |
{ |
3696 |
case IToken.t_asm : |
3691 |
case IToken.t_asm : |
3697 |
IToken first = consume(IToken.t_asm); |
3692 |
IToken first = consume(IToken.t_asm); |
3698 |
setCompletionValues( scope, CompletionKind.NO_SUCH_KIND, KeywordSetKey.EMPTY ); |
3693 |
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND, KeywordSetKey.EMPTY); |
3699 |
consume(IToken.tLPAREN); |
3694 |
consume(IToken.tLPAREN); |
3700 |
char[] assembly = consume(IToken.tSTRING).getCharImage(); |
3695 |
char[] assembly = consume(IToken.tSTRING).getCharImage(); |
3701 |
consume(IToken.tRPAREN); |
3696 |
consume(IToken.tRPAREN); |
Lines 3712-3724
Link Here
|
3712 |
} |
3707 |
} |
3713 |
catch (Exception e) |
3708 |
catch (Exception e) |
3714 |
{ |
3709 |
{ |
3715 |
logException( "declaration:createASMDefinition", e ); //$NON-NLS-1$ |
3710 |
logException("declaration:createASMDefinition", e); //$NON-NLS-1$ |
3716 |
throwBacktrack(first.getOffset(), last.getEndOffset(), first.getLineNumber(), first.getFilename()); |
3711 |
throwBacktrack(first.getOffset(), last.getEndOffset(), first.getLineNumber(), first.getFilename()); |
3717 |
} |
3712 |
} |
3718 |
// if we made it this far, then we have all we need |
3713 |
// if we made it this far, then we have all we need |
3719 |
// do the callback |
3714 |
// do the callback |
3720 |
resultDeclaration.acceptElement(requestor); |
3715 |
resultDeclaration.acceptElement(requestor); |
3721 |
setCompletionValues(scope, kind, KeywordSetKey.DECLARATION ); |
3716 |
setCompletionValues(scope, kind, KeywordSetKey.DECLARATION); |
3722 |
break; |
3717 |
break; |
3723 |
case IToken.t_namespace : |
3718 |
case IToken.t_namespace : |
3724 |
resultDeclaration = namespaceDefinition(scope); |
3719 |
resultDeclaration = namespaceDefinition(scope); |
Lines 3737-3749
Link Here
|
3737 |
break; |
3732 |
break; |
3738 |
} |
3733 |
} |
3739 |
default : |
3734 |
default : |
3740 |
if( extension.supportsExtendedTemplateInstantiationSyntax() && extension.isValidModifierForInstantiation(LA(1)) && LT(2) == IToken.t_template ) |
3735 |
if (extension.supportsExtendedTemplateInstantiationSyntax() && extension.isValidModifierForInstantiation(LA(1)) && LT(2) == IToken.t_template) |
3741 |
resultDeclaration = templateDeclaration(scope); |
3736 |
resultDeclaration = templateDeclaration(scope); |
3742 |
else |
3737 |
else |
3743 |
resultDeclaration = simpleDeclarationStrategyUnion(scope, ownerTemplate, overideKind, overideKey); |
3738 |
resultDeclaration = simpleDeclarationStrategyUnion(scope, ownerTemplate, overideKind, overideKey); |
3744 |
} |
3739 |
} |
3745 |
setCompletionValues(scope, kind, KeywordSetKey.DECLARATION ); |
3740 |
setCompletionValues(scope, kind, KeywordSetKey.DECLARATION); |
3746 |
endDeclaration( resultDeclaration ); |
3741 |
endDeclaration(resultDeclaration); |
3747 |
} |
3742 |
} |
3748 |
|
3743 |
|
3749 |
|
3744 |
|
Lines 3765-3772
Link Here
|
3765 |
} |
3760 |
} |
3766 |
catch (BacktrackException bt) |
3761 |
catch (BacktrackException bt) |
3767 |
{ |
3762 |
{ |
3768 |
if( simpleDeclarationMark == null ) |
3763 |
if (simpleDeclarationMark == null) |
3769 |
throwBacktrack( bt ); |
3764 |
throwBacktrack(bt); |
3770 |
firstFailure = bt.getProblem(); |
3765 |
firstFailure = bt.getProblem(); |
3771 |
// did not work |
3766 |
// did not work |
3772 |
backup(simpleDeclarationMark); |
3767 |
backup(simpleDeclarationMark); |
Lines 3778-3795
Link Here
|
3778 |
scope, |
3773 |
scope, |
3779 |
ownerTemplate, overrideKind, false, overrideKey); |
3774 |
ownerTemplate, overrideKind, false, overrideKey); |
3780 |
} |
3775 |
} |
3781 |
catch( BacktrackException bt2 ) |
3776 |
catch (BacktrackException bt2) |
3782 |
{ |
3777 |
{ |
3783 |
if( simpleDeclarationMark == null ) |
3778 |
if (simpleDeclarationMark == null) |
3784 |
{ |
3779 |
{ |
3785 |
if( firstFailure != null && (bt2.getProblem() == null )) |
3780 |
if (firstFailure != null && (bt2.getProblem() == null)) |
3786 |
throwBacktrack(firstFailure); |
3781 |
throwBacktrack(firstFailure); |
3787 |
else |
3782 |
else |
3788 |
throwBacktrack(bt2); |
3783 |
throwBacktrack(bt2); |
3789 |
} |
3784 |
} |
3790 |
|
3785 |
|
3791 |
secondFailure = bt2.getProblem(); |
3786 |
secondFailure = bt2.getProblem(); |
3792 |
backup( simpleDeclarationMark ); |
3787 |
backup(simpleDeclarationMark); |
3793 |
|
3788 |
|
3794 |
try |
3789 |
try |
3795 |
{ |
3790 |
{ |
Lines 3798-3813
Link Here
|
3798 |
scope, |
3793 |
scope, |
3799 |
ownerTemplate, overrideKind, false, overrideKey); |
3794 |
ownerTemplate, overrideKind, false, overrideKey); |
3800 |
} |
3795 |
} |
3801 |
catch( BacktrackException b3 ) |
3796 |
catch (BacktrackException b3) |
3802 |
{ |
3797 |
{ |
3803 |
backup( simpleDeclarationMark ); //TODO - necessary? |
3798 |
backup(simpleDeclarationMark); //TODO - necessary? |
3804 |
|
3799 |
|
3805 |
if( firstFailure != null ) |
3800 |
if (firstFailure != null) |
3806 |
throwBacktrack( firstFailure ); |
3801 |
throwBacktrack(firstFailure); |
3807 |
else if( secondFailure != null ) |
3802 |
else if (secondFailure != null) |
3808 |
throwBacktrack( secondFailure ); |
3803 |
throwBacktrack(secondFailure); |
3809 |
else |
3804 |
else |
3810 |
throwBacktrack( b3 ); |
3805 |
throwBacktrack(b3); |
3811 |
return null; |
3806 |
return null; |
3812 |
} |
3807 |
} |
3813 |
} |
3808 |
} |
Lines 3835-3841
Link Here
|
3835 |
|
3830 |
|
3836 |
IASTCompletionNode.CompletionKind kind = getCompletionKindForDeclaration(scope, null); |
3831 |
IASTCompletionNode.CompletionKind kind = getCompletionKindForDeclaration(scope, null); |
3837 |
|
3832 |
|
3838 |
setCompletionValues(scope,CompletionKind.NAMESPACE_REFERENCE, KeywordSetKey.EMPTY ); |
3833 |
setCompletionValues(scope,CompletionKind.NAMESPACE_REFERENCE, KeywordSetKey.EMPTY); |
3839 |
IToken identifier = null; |
3834 |
IToken identifier = null; |
3840 |
// optional name |
3835 |
// optional name |
3841 |
if (LT(1) == IToken.tIDENTIFIER) |
3836 |
if (LT(1) == IToken.tIDENTIFIER) |
Lines 3854-3874
Link Here
|
3854 |
first.getOffset(), |
3849 |
first.getOffset(), |
3855 |
first.getLineNumber(), |
3850 |
first.getLineNumber(), |
3856 |
(identifier == null ? first.getOffset() : identifier.getOffset()), |
3851 |
(identifier == null ? first.getOffset() : identifier.getOffset()), |
3857 |
(identifier == null ? first.getEndOffset() : identifier.getEndOffset() ), |
3852 |
(identifier == null ? first.getEndOffset() : identifier.getEndOffset()), |
3858 |
(identifier == null ? first.getLineNumber() : identifier.getLineNumber() ), first.getFilename()); |
3853 |
(identifier == null ? first.getLineNumber() : identifier.getLineNumber()), first.getFilename()); |
3859 |
} |
3854 |
} |
3860 |
catch (Exception e1) |
3855 |
catch (Exception e1) |
3861 |
{ |
3856 |
{ |
3862 |
|
3857 |
|
3863 |
logException( "namespaceDefinition:createNamespaceDefinition", e1 ); //$NON-NLS-1$ |
3858 |
logException("namespaceDefinition:createNamespaceDefinition", e1); //$NON-NLS-1$ |
3864 |
throwBacktrack(first.getOffset(), lbrace.getEndOffset(), first.getLineNumber(), first.getFilename()); |
3859 |
throwBacktrack(first.getOffset(), lbrace.getEndOffset(), first.getLineNumber(), first.getFilename()); |
3865 |
return null; |
3860 |
return null; |
3866 |
} |
3861 |
} |
3867 |
namespaceDefinition.enterScope( requestor ); |
3862 |
namespaceDefinition.enterScope(requestor); |
3868 |
try |
3863 |
try |
3869 |
{ |
3864 |
{ |
3870 |
setCompletionValues(scope,CompletionKind.VARIABLE_TYPE, KeywordSetKey.DECLARATION ); |
3865 |
setCompletionValues(scope,CompletionKind.VARIABLE_TYPE, KeywordSetKey.DECLARATION); |
3871 |
endDeclaration( namespaceDefinition ); |
3866 |
endDeclaration(namespaceDefinition); |
3872 |
namespaceDeclarationLoop : while (LT(1) != IToken.tRBRACE) |
3867 |
namespaceDeclarationLoop : while (LT(1) != IToken.tRBRACE) |
3873 |
{ |
3868 |
{ |
3874 |
int checkToken = LA(1).hashCode(); |
3869 |
int checkToken = LA(1).hashCode(); |
Lines 3892-3935
Link Here
|
3892 |
if (checkToken == LA(1).hashCode()) |
3887 |
if (checkToken == LA(1).hashCode()) |
3893 |
failParseWithErrorHandling(); |
3888 |
failParseWithErrorHandling(); |
3894 |
} |
3889 |
} |
3895 |
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND,KeywordSetKey.EMPTY ); |
3890 |
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND,KeywordSetKey.EMPTY); |
3896 |
// consume the } |
3891 |
// consume the } |
3897 |
IToken last = consume(IToken.tRBRACE); |
3892 |
IToken last = consume(IToken.tRBRACE); |
3898 |
|
3893 |
|
3899 |
namespaceDefinition.setEndingOffsetAndLineNumber( |
3894 |
namespaceDefinition.setEndingOffsetAndLineNumber( |
3900 |
last.getOffset() + last.getLength(), last.getLineNumber()); |
3895 |
last.getOffset() + last.getLength(), last.getLineNumber()); |
3901 |
setCompletionValues(scope, kind, KeywordSetKey.DECLARATION ); |
3896 |
setCompletionValues(scope, kind, KeywordSetKey.DECLARATION); |
3902 |
} |
3897 |
} |
3903 |
finally |
3898 |
finally |
3904 |
{ |
3899 |
{ |
3905 |
namespaceDefinition.exitScope( requestor ); |
3900 |
namespaceDefinition.exitScope(requestor); |
3906 |
} |
3901 |
} |
3907 |
return namespaceDefinition; |
3902 |
return namespaceDefinition; |
3908 |
} |
3903 |
} |
3909 |
else if( LT(1) == IToken.tASSIGN ) |
3904 |
else if (LT(1) == IToken.tASSIGN) |
3910 |
{ |
3905 |
{ |
3911 |
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND,KeywordSetKey.EMPTY); |
3906 |
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND,KeywordSetKey.EMPTY); |
3912 |
IToken assign = consume( IToken.tASSIGN ); |
3907 |
IToken assign = consume(IToken.tASSIGN); |
3913 |
|
3908 |
|
3914 |
if( identifier == null ) |
3909 |
if (identifier == null) |
3915 |
{ |
3910 |
{ |
3916 |
throwBacktrack(first.getOffset(), assign.getEndOffset(), first.getLineNumber(), first.getFilename()); |
3911 |
throwBacktrack(first.getOffset(), assign.getEndOffset(), first.getLineNumber(), first.getFilename()); |
3917 |
return null; |
3912 |
return null; |
3918 |
} |
3913 |
} |
3919 |
|
3914 |
|
3920 |
ITokenDuple duple = name(scope, CompletionKind.NAMESPACE_REFERENCE, KeywordSetKey.EMPTY); |
3915 |
ITokenDuple duple = name(scope, CompletionKind.NAMESPACE_REFERENCE, KeywordSetKey.EMPTY); |
3921 |
IToken semi = consume( IToken.tSEMI ); |
3916 |
IToken semi = consume(IToken.tSEMI); |
3922 |
setCompletionValues(scope, kind, KeywordSetKey.DECLARATION ); |
3917 |
setCompletionValues(scope, kind, KeywordSetKey.DECLARATION); |
3923 |
IASTNamespaceAlias alias = null; |
3918 |
IASTNamespaceAlias alias = null; |
3924 |
try |
3919 |
try |
3925 |
{ |
3920 |
{ |
3926 |
alias = astFactory.createNamespaceAlias( |
3921 |
alias = astFactory.createNamespaceAlias( |
3927 |
scope, identifier.getCharImage(), duple, first.getOffset(), |
3922 |
scope, identifier.getCharImage(), duple, first.getOffset(), |
3928 |
first.getLineNumber(), identifier.getOffset(), identifier.getEndOffset(), identifier.getLineNumber(), duple.getLastToken().getEndOffset(), duple.getLastToken().getLineNumber() ); |
3923 |
first.getLineNumber(), identifier.getOffset(), identifier.getEndOffset(), identifier.getLineNumber(), duple.getLastToken().getEndOffset(), duple.getLastToken().getLineNumber()); |
3929 |
} |
3924 |
} |
3930 |
catch (Exception e1) |
3925 |
catch (Exception e1) |
3931 |
{ |
3926 |
{ |
3932 |
logException( "namespaceDefinition:createNamespaceAlias", e1 ); //$NON-NLS-1$ |
3927 |
logException("namespaceDefinition:createNamespaceAlias", e1); //$NON-NLS-1$ |
3933 |
throwBacktrack(first.getOffset(), semi.getEndOffset(), first.getLineNumber(), first.getFilename()); |
3928 |
throwBacktrack(first.getOffset(), semi.getEndOffset(), first.getLineNumber(), first.getFilename()); |
3934 |
return null; |
3929 |
return null; |
3935 |
} |
3930 |
} |
Lines 3937-3943
Link Here
|
3937 |
} |
3932 |
} |
3938 |
else |
3933 |
else |
3939 |
{ |
3934 |
{ |
3940 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
3935 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
3941 |
throwBacktrack(first.getOffset(), endOffset, first.getLineNumber(), first.getFilename()); |
3936 |
throwBacktrack(first.getOffset(), endOffset, first.getLineNumber(), first.getFilename()); |
3942 |
return null; |
3937 |
return null; |
3943 |
} |
3938 |
} |
Lines 3957-3964
Link Here
|
3957 |
* IParserCallback object which serves as the owner scope for |
3952 |
* IParserCallback object which serves as the owner scope for |
3958 |
* this declaration. |
3953 |
* this declaration. |
3959 |
* @param tryConstructor |
3954 |
* @param tryConstructor |
3960 |
* true == take strategy1 (constructor ) : false == take strategy |
3955 |
* true == take strategy1 (constructor) : false == take strategy |
3961 |
* 2 ( pointer to function) |
3956 |
* 2 (pointer to function) |
3962 |
* @return TODO |
3957 |
* @return TODO |
3963 |
* @throws BacktrackException |
3958 |
* @throws BacktrackException |
3964 |
* request a backtrack |
3959 |
* request a backtrack |
Lines 3973-3988
Link Here
|
3973 |
int firstOffset = firstToken.getOffset(); |
3968 |
int firstOffset = firstToken.getOffset(); |
3974 |
int firstLine = firstToken.getLineNumber(); |
3969 |
int firstLine = firstToken.getLineNumber(); |
3975 |
char [] fn = firstToken.getFilename(); |
3970 |
char [] fn = firstToken.getFilename(); |
3976 |
if( firstToken.getType() == IToken.tLBRACE ) throwBacktrack(firstToken.getOffset(), firstToken.getEndOffset(), firstToken.getLineNumber(), firstToken.getFilename()); |
3971 |
if (firstToken.getType() == IToken.tLBRACE) throwBacktrack(firstToken.getOffset(), firstToken.getEndOffset(), firstToken.getLineNumber(), firstToken.getFilename()); |
3977 |
DeclarationWrapper sdw = |
3972 |
DeclarationWrapper sdw = |
3978 |
new DeclarationWrapper(scope, firstToken.getOffset(), firstToken.getLineNumber(), ownerTemplate, fn); |
3973 |
new DeclarationWrapper(scope, firstToken.getOffset(), firstToken.getLineNumber(), ownerTemplate, fn); |
3979 |
firstToken = null; // necessary for scalability |
3974 |
firstToken = null; // necessary for scalability |
3980 |
|
3975 |
|
3981 |
CompletionKind completionKindForDeclaration = getCompletionKindForDeclaration(scope, overideKind); |
3976 |
CompletionKind completionKindForDeclaration = getCompletionKindForDeclaration(scope, overideKind); |
3982 |
setCompletionValues( scope, completionKindForDeclaration, KeywordSetKey.DECL_SPECIFIER_SEQUENCE ); |
3977 |
setCompletionValues(scope, completionKindForDeclaration, KeywordSetKey.DECL_SPECIFIER_SEQUENCE); |
3983 |
declSpecifierSeq(sdw, false, strategy == SimpleDeclarationStrategy.TRY_CONSTRUCTOR, completionKindForDeclaration, overrideKey ); |
3978 |
declSpecifierSeq(sdw, false, strategy == SimpleDeclarationStrategy.TRY_CONSTRUCTOR, completionKindForDeclaration, overrideKey); |
3984 |
IASTSimpleTypeSpecifier simpleTypeSpecifier = null; |
3979 |
IASTSimpleTypeSpecifier simpleTypeSpecifier = null; |
3985 |
if (sdw.getTypeSpecifier() == null && sdw.getSimpleType() != IASTSimpleTypeSpecifier.Type.UNSPECIFIED ) |
3980 |
if (sdw.getTypeSpecifier() == null && sdw.getSimpleType() != IASTSimpleTypeSpecifier.Type.UNSPECIFIED) |
3986 |
try |
3981 |
try |
3987 |
{ |
3982 |
{ |
3988 |
simpleTypeSpecifier = astFactory.createSimpleTypeSpecifier( |
3983 |
simpleTypeSpecifier = astFactory.createSimpleTypeSpecifier( |
Lines 3999-4011
Link Here
|
3999 |
sdw.isGloballyQualified(), sdw.getExtensionParameters()); |
3994 |
sdw.isGloballyQualified(), sdw.getExtensionParameters()); |
4000 |
sdw.setTypeSpecifier( |
3995 |
sdw.setTypeSpecifier( |
4001 |
simpleTypeSpecifier); |
3996 |
simpleTypeSpecifier); |
4002 |
sdw.setTypeName( null ); |
3997 |
sdw.setTypeName(null); |
4003 |
} |
3998 |
} |
4004 |
catch (Exception e1) |
3999 |
catch (Exception e1) |
4005 |
{ |
4000 |
{ |
4006 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
4001 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
4007 |
logException( "simpleDeclaration:createSimpleTypeSpecifier", e1 ); //$NON-NLS-1$ |
4002 |
logException("simpleDeclaration:createSimpleTypeSpecifier", e1); //$NON-NLS-1$ |
4008 |
if( e1 instanceof ASTSemanticException && ((ASTSemanticException)e1).getProblem() != null ) |
4003 |
if (e1 instanceof ASTSemanticException && ((ASTSemanticException)e1).getProblem() != null) |
4009 |
throwBacktrack(((ASTSemanticException)e1).getProblem()); |
4004 |
throwBacktrack(((ASTSemanticException)e1).getProblem()); |
4010 |
else |
4005 |
else |
4011 |
throwBacktrack(firstOffset, endOffset, firstLine, fn); |
4006 |
throwBacktrack(firstOffset, endOffset, firstLine, fn); |
Lines 4020-4026
Link Here
|
4020 |
while (LT(1) == IToken.tCOMMA) |
4015 |
while (LT(1) == IToken.tCOMMA) |
4021 |
{ |
4016 |
{ |
4022 |
consume(); |
4017 |
consume(); |
4023 |
initDeclarator(sdw, strategy, completionKindForDeclaration, constructInitializersInDeclarations ); |
4018 |
initDeclarator(sdw, strategy, completionKindForDeclaration, constructInitializersInDeclarations); |
4024 |
} |
4019 |
} |
4025 |
} |
4020 |
} |
4026 |
|
4021 |
|
Lines 4035-4045
Link Here
|
4035 |
consumedSemi = true; |
4030 |
consumedSemi = true; |
4036 |
break; |
4031 |
break; |
4037 |
case IToken.t_try : |
4032 |
case IToken.t_try : |
4038 |
consume( IToken.t_try ); |
4033 |
consume(IToken.t_try); |
4039 |
if( LT(1) == IToken.tCOLON ) |
4034 |
if (LT(1) == IToken.tCOLON) |
4040 |
ctorInitializer( declarator ); |
4035 |
ctorInitializer(declarator); |
4041 |
hasFunctionTryBlock = true; |
4036 |
hasFunctionTryBlock = true; |
4042 |
declarator.setFunctionTryBlock( true ); |
4037 |
declarator.setFunctionTryBlock(true); |
4043 |
break; |
4038 |
break; |
4044 |
case IToken.tCOLON : |
4039 |
case IToken.tCOLON : |
4045 |
ctorInitializer(declarator); |
4040 |
ctorInitializer(declarator); |
Lines 4047-4134
Link Here
|
4047 |
case IToken.tLBRACE: |
4042 |
case IToken.tLBRACE: |
4048 |
break; |
4043 |
break; |
4049 |
case IToken.tRPAREN: |
4044 |
case IToken.tRPAREN: |
4050 |
if( ! fromCatchHandler ) |
4045 |
if (! fromCatchHandler) |
4051 |
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1).getLineNumber(), fn); |
4046 |
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1).getLineNumber(), fn); |
4052 |
break; |
4047 |
break; |
4053 |
default: |
4048 |
default: |
4054 |
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1).getLineNumber(), fn); |
4049 |
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1).getLineNumber(), fn); |
4055 |
} |
4050 |
} |
4056 |
|
4051 |
|
4057 |
if( ! consumedSemi ) |
4052 |
if (!consumedSemi) { |
4058 |
{ |
4053 |
if (LT(1) == IToken.tLBRACE) { |
4059 |
if( LT(1) == IToken.tLBRACE ) |
|
|
4060 |
{ |
4061 |
declarator.setHasFunctionBody(true); |
4054 |
declarator.setHasFunctionBody(true); |
4062 |
hasFunctionBody = true; |
4055 |
hasFunctionBody = true; |
4063 |
} |
4056 |
} |
4064 |
|
4057 |
|
4065 |
if( hasFunctionTryBlock && ! hasFunctionBody ) |
4058 |
if (hasFunctionTryBlock && !hasFunctionBody) |
4066 |
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1).getLineNumber(), fn); |
4059 |
throwBacktrack(firstOffset, LA(1).getEndOffset(), LA(1).getLineNumber(), fn); |
4067 |
} |
4060 |
} |
4068 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
4061 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
4069 |
List l = null; |
4062 |
List l = null; |
4070 |
try |
4063 |
try { |
4071 |
{ |
|
|
4072 |
l = sdw.createASTNodes(astFactory); |
4064 |
l = sdw.createASTNodes(astFactory); |
4073 |
} |
4065 |
} catch (ASTSemanticException e) { |
4074 |
catch (ASTSemanticException e) |
4066 |
if (e.getProblem() == null) { |
4075 |
{ |
4067 |
IProblem p = problemFactory.createProblem(IProblem.SYNTAX_ERROR, |
4076 |
if( e.getProblem() == null ) |
4068 |
sdw.getStartingOffset(), |
4077 |
{ |
4069 |
lastToken != null ? lastToken.getEndOffset() : 0, |
4078 |
IProblem p = problemFactory.createProblem( IProblem.SYNTAX_ERROR, |
4070 |
sdw.getStartingLine(), fn, |
4079 |
sdw.getStartingOffset(), |
4071 |
EMPTY_STRING_ARRAY, false, true); |
4080 |
lastToken != null ? lastToken.getEndOffset() : 0, |
4072 |
throwBacktrack(p); |
4081 |
sdw.getStartingLine(), |
|
|
4082 |
fn, |
4083 |
EMPTY_STRING, false, true ); |
4084 |
throwBacktrack( p ); |
4085 |
} else { |
4073 |
} else { |
4086 |
throwBacktrack(e.getProblem()); |
4074 |
throwBacktrack(e.getProblem()); |
4087 |
} |
4075 |
} |
4088 |
} |
4076 |
} catch (Exception e) { |
4089 |
catch( Exception e ) |
4077 |
logException("simpleDecl", e); //$NON-NLS-1$ |
4090 |
{ |
|
|
4091 |
logException( "simpleDecl", e ); //$NON-NLS-1$ |
4092 |
throwBacktrack(firstOffset, endOffset, firstLine, fn); |
4078 |
throwBacktrack(firstOffset, endOffset, firstLine, fn); |
4093 |
} |
4079 |
} |
4094 |
|
4080 |
|
4095 |
if (hasFunctionBody && l.size() != 1) |
4081 |
if (hasFunctionBody && l.size() != 1) { |
4096 |
{ |
|
|
4097 |
throwBacktrack(firstOffset, endOffset, firstLine, fn); //TODO Should be an IProblem |
4082 |
throwBacktrack(firstOffset, endOffset, firstLine, fn); //TODO Should be an IProblem |
4098 |
} |
4083 |
} |
4099 |
if (!l.isEmpty()) // no need to do this unless we have a declarator |
4084 |
if (!l.isEmpty()) {// no need to do this unless we have a declarator |
4100 |
{ |
4085 |
if (!hasFunctionBody || fromCatchHandler) { |
4101 |
if (!hasFunctionBody || fromCatchHandler) |
|
|
4102 |
{ |
4103 |
IASTDeclaration declaration = null; |
4086 |
IASTDeclaration declaration = null; |
4104 |
for( int i = 0; i < l.size(); ++i ) |
4087 |
for (int i = 0; i < l.size(); ++i) { |
4105 |
{ |
|
|
4106 |
declaration = (IASTDeclaration)l.get(i); |
4088 |
declaration = (IASTDeclaration)l.get(i); |
4107 |
((IASTOffsetableElement)declaration).setEndingOffsetAndLineNumber( |
4089 |
((IASTOffsetableElement)declaration).setEndingOffsetAndLineNumber( |
4108 |
lastToken.getEndOffset(), lastToken.getLineNumber()); |
4090 |
lastToken.getEndOffset(), lastToken.getLineNumber()); |
4109 |
declaration.acceptElement( requestor ); |
4091 |
declaration.acceptElement(requestor); |
4110 |
} |
4092 |
} |
4111 |
return declaration; |
4093 |
return declaration; |
4112 |
} |
4094 |
} |
4113 |
IASTDeclaration declaration = (IASTDeclaration)l.get(0); |
4095 |
IASTDeclaration declaration = (IASTDeclaration)l.get(0); |
4114 |
endDeclaration( declaration ); |
4096 |
endDeclaration(declaration); |
4115 |
declaration.enterScope( requestor ); |
4097 |
declaration.enterScope(requestor); |
4116 |
try |
4098 |
try |
4117 |
{ |
4099 |
{ |
4118 |
if ( !( declaration instanceof IASTScope ) ) |
4100 |
if (!(declaration instanceof IASTScope)) |
4119 |
throwBacktrack(firstOffset, endOffset, firstLine, fn); |
4101 |
throwBacktrack(firstOffset, endOffset, firstLine, fn); |
4120 |
|
4102 |
|
4121 |
handleFunctionBody((IASTScope)declaration ); |
4103 |
handleFunctionBody((IASTScope)declaration); |
4122 |
((IASTOffsetableElement)declaration).setEndingOffsetAndLineNumber( |
4104 |
((IASTOffsetableElement)declaration).setEndingOffsetAndLineNumber( |
4123 |
lastToken.getEndOffset(), lastToken.getLineNumber()); |
4105 |
lastToken.getEndOffset(), lastToken.getLineNumber()); |
4124 |
} |
4106 |
} |
4125 |
finally |
4107 |
finally |
4126 |
{ |
4108 |
{ |
4127 |
declaration.exitScope( requestor ); |
4109 |
declaration.exitScope(requestor); |
4128 |
} |
4110 |
} |
4129 |
|
4111 |
|
4130 |
if( hasFunctionTryBlock ) |
4112 |
if (hasFunctionTryBlock) |
4131 |
catchHandlerSequence( scope ); |
4113 |
catchHandlerSequence(scope); |
4132 |
|
4114 |
|
4133 |
return declaration; |
4115 |
return declaration; |
4134 |
|
4116 |
|
Lines 4136-4142
Link Here
|
4136 |
|
4118 |
|
4137 |
try |
4119 |
try |
4138 |
{ |
4120 |
{ |
4139 |
if( sdw.getTypeSpecifier() != null ) |
4121 |
if (sdw.getTypeSpecifier() != null) |
4140 |
{ |
4122 |
{ |
4141 |
IASTAbstractTypeSpecifierDeclaration declaration = astFactory.createTypeSpecDeclaration( |
4123 |
IASTAbstractTypeSpecifierDeclaration declaration = astFactory.createTypeSpecDeclaration( |
4142 |
sdw.getScope(), |
4124 |
sdw.getScope(), |
Lines 4151-4167
Link Here
|
4151 |
} |
4133 |
} |
4152 |
catch (Exception e1) |
4134 |
catch (Exception e1) |
4153 |
{ |
4135 |
{ |
4154 |
logException( "simpleDeclaration:createTypeSpecDeclaration", e1 ); //$NON-NLS-1$ |
4136 |
logException("simpleDeclaration:createTypeSpecDeclaration", e1); //$NON-NLS-1$ |
4155 |
throwBacktrack(firstOffset, endOffset, firstLine, fn); |
4137 |
throwBacktrack(firstOffset, endOffset, firstLine, fn); |
4156 |
} |
4138 |
} |
4157 |
|
4139 |
|
4158 |
return null; |
4140 |
return null; |
4159 |
} catch( BacktrackException be ) |
4141 |
} catch (BacktrackException be) |
4160 |
{ |
4142 |
{ |
4161 |
throwBacktrack(be); |
4143 |
throwBacktrack(be); |
4162 |
return null; |
4144 |
return null; |
4163 |
} |
4145 |
} |
4164 |
catch( EndOfFileException eof ) |
4146 |
catch (EndOfFileException eof) |
4165 |
{ |
4147 |
{ |
4166 |
throw eof; |
4148 |
throw eof; |
4167 |
} |
4149 |
} |
Lines 4170-4185
Link Here
|
4170 |
|
4152 |
|
4171 |
protected void handleFunctionBody(IASTScope scope) throws BacktrackException, EndOfFileException |
4153 |
protected void handleFunctionBody(IASTScope scope) throws BacktrackException, EndOfFileException |
4172 |
{ |
4154 |
{ |
4173 |
if( mode == ParserMode.QUICK_PARSE || mode == ParserMode.STRUCTURAL_PARSE ) |
4155 |
if (mode == ParserMode.QUICK_PARSE || mode == ParserMode.STRUCTURAL_PARSE ) |
4174 |
skipOverCompoundStatement(); |
4156 |
skipOverCompoundStatement(); |
4175 |
else if( mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE ) |
4157 |
else if (mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE) |
4176 |
{ |
4158 |
{ |
4177 |
if( scanner.isOnTopContext() ) |
4159 |
if (scanner.isOnTopContext()) |
4178 |
functionBody(scope); |
4160 |
functionBody(scope); |
4179 |
else |
4161 |
else |
4180 |
skipOverCompoundStatement(); |
4162 |
skipOverCompoundStatement(); |
4181 |
} |
4163 |
} |
4182 |
else if( mode == ParserMode.COMPLETE_PARSE ) |
4164 |
else if (mode == ParserMode.COMPLETE_PARSE) |
4183 |
functionBody(scope); |
4165 |
functionBody(scope); |
4184 |
|
4166 |
|
4185 |
|
4167 |
|
Lines 4207-4213
Link Here
|
4207 |
/** |
4189 |
/** |
4208 |
* This method parses a constructor chain ctorinitializer: : |
4190 |
* This method parses a constructor chain ctorinitializer: : |
4209 |
* meminitializerlist meminitializerlist: meminitializer | meminitializer , |
4191 |
* meminitializerlist meminitializerlist: meminitializer | meminitializer , |
4210 |
* meminitializerlist meminitializer: meminitializerid | ( expressionlist? ) |
4192 |
* meminitializerlist meminitializer: meminitializerid | (expressionlist?) |
4211 |
* meminitializerid: ::? nestednamespecifier? classname identifier |
4193 |
* meminitializerid: ::? nestednamespecifier? classname identifier |
4212 |
* |
4194 |
* |
4213 |
* @param declarator |
4195 |
* @param declarator |
Lines 4216-4222
Link Here
|
4216 |
* @throws BacktrackException |
4198 |
* @throws BacktrackException |
4217 |
* request a backtrack |
4199 |
* request a backtrack |
4218 |
*/ |
4200 |
*/ |
4219 |
protected void ctorInitializer(Declarator d ) |
4201 |
protected void ctorInitializer(Declarator d) |
4220 |
throws EndOfFileException, BacktrackException |
4202 |
throws EndOfFileException, BacktrackException |
4221 |
{ |
4203 |
{ |
4222 |
int startingOffset = consume(IToken.tCOLON).getOffset(); |
4204 |
int startingOffset = consume(IToken.tCOLON).getOffset(); |
Lines 4228-4239
Link Here
|
4228 |
break; |
4210 |
break; |
4229 |
|
4211 |
|
4230 |
|
4212 |
|
4231 |
ITokenDuple duple = name(scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EMPTY ); |
4213 |
ITokenDuple duple = name(scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EMPTY); |
4232 |
|
4214 |
|
4233 |
consume(IToken.tLPAREN); |
4215 |
consume(IToken.tLPAREN); |
4234 |
IASTExpression expressionList = null; |
4216 |
IASTExpression expressionList = null; |
4235 |
|
4217 |
|
4236 |
if( LT(1) != IToken.tRPAREN ) |
4218 |
if (LT(1) != IToken.tRPAREN) |
4237 |
expressionList = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EXPRESSION); |
4219 |
expressionList = expression(scope, CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.EXPRESSION); |
4238 |
|
4220 |
|
4239 |
IToken rparen = consume(IToken.tRPAREN); |
4221 |
IToken rparen = consume(IToken.tRPAREN); |
Lines 4241-4251
Link Here
|
4241 |
try |
4223 |
try |
4242 |
{ |
4224 |
{ |
4243 |
d.addConstructorMemberInitializer( |
4225 |
d.addConstructorMemberInitializer( |
4244 |
astFactory.createConstructorMemberInitializer(scope, duple, expressionList) ); |
4226 |
astFactory.createConstructorMemberInitializer(scope, duple, expressionList)); |
4245 |
} |
4227 |
} |
4246 |
catch (Exception e1) |
4228 |
catch (Exception e1) |
4247 |
{ |
4229 |
{ |
4248 |
logException( "ctorInitializer:addConstructorMemberInitializer", e1 ); //$NON-NLS-1$ |
4230 |
logException("ctorInitializer:addConstructorMemberInitializer", e1); //$NON-NLS-1$ |
4249 |
throwBacktrack(startingOffset, rparen.getEndOffset(), rparen.getLineNumber(), rparen.getFilename()); |
4231 |
throwBacktrack(startingOffset, rparen.getEndOffset(), rparen.getLineNumber(), rparen.getFilename()); |
4250 |
} |
4232 |
} |
4251 |
if (LT(1) == IToken.tLBRACE) |
4233 |
if (LT(1) == IToken.tLBRACE) |
Lines 4274-4280
Link Here
|
4274 |
|
4256 |
|
4275 |
DeclarationWrapper sdw = |
4257 |
DeclarationWrapper sdw = |
4276 |
new DeclarationWrapper(scope, current.getOffset(), current.getLineNumber(), null, current.getFilename()); |
4258 |
new DeclarationWrapper(scope, current.getOffset(), current.getLineNumber(), null, current.getFilename()); |
4277 |
declSpecifierSeq(sdw, true, false, CompletionKind.ARGUMENT_TYPE, KeywordSetKey.DECL_SPECIFIER_SEQUENCE ); |
4259 |
declSpecifierSeq(sdw, true, false, CompletionKind.ARGUMENT_TYPE, KeywordSetKey.DECL_SPECIFIER_SEQUENCE); |
4278 |
if (sdw.getTypeSpecifier() == null |
4260 |
if (sdw.getTypeSpecifier() == null |
4279 |
&& sdw.getSimpleType() |
4261 |
&& sdw.getSimpleType() |
4280 |
!= IASTSimpleTypeSpecifier.Type.UNSPECIFIED) |
4262 |
!= IASTSimpleTypeSpecifier.Type.UNSPECIFIED) |
Lines 4300-4320
Link Here
|
4300 |
} |
4282 |
} |
4301 |
catch (Exception e) |
4283 |
catch (Exception e) |
4302 |
{ |
4284 |
{ |
4303 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
4285 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
4304 |
logException( "parameterDeclaration:createSimpleTypeSpecifier", e ); //$NON-NLS-1$ |
4286 |
logException("parameterDeclaration:createSimpleTypeSpecifier", e); //$NON-NLS-1$ |
4305 |
throwBacktrack(current.getOffset(), endOffset, current.getLineNumber(), current.getFilename()); |
4287 |
throwBacktrack(current.getOffset(), endOffset, current.getLineNumber(), current.getFilename()); |
4306 |
} |
4288 |
} |
4307 |
|
4289 |
|
4308 |
setCompletionValues(scope,CompletionKind.SINGLE_NAME_REFERENCE,KeywordSetKey.EMPTY ); |
4290 |
setCompletionValues(scope,CompletionKind.SINGLE_NAME_REFERENCE,KeywordSetKey.EMPTY); |
4309 |
if (LT(1) != IToken.tSEMI) |
4291 |
if (LT(1) != IToken.tSEMI) |
4310 |
initDeclarator(sdw, SimpleDeclarationStrategy.TRY_FUNCTION, CompletionKind.VARIABLE_TYPE, constructInitializersInParameters ); |
4292 |
initDeclarator(sdw, SimpleDeclarationStrategy.TRY_FUNCTION, CompletionKind.VARIABLE_TYPE, constructInitializersInParameters); |
4311 |
|
4293 |
|
4312 |
if( lastToken != null ) |
4294 |
if (lastToken != null) |
4313 |
sdw.setEndingOffsetAndLineNumber( lastToken.getEndOffset(), lastToken.getLineNumber() ); |
4295 |
sdw.setEndingOffsetAndLineNumber(lastToken.getEndOffset(), lastToken.getLineNumber()); |
4314 |
|
4296 |
|
4315 |
if (current == LA(1)) |
4297 |
if (current == LA(1)) |
4316 |
{ |
4298 |
{ |
4317 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
4299 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
4318 |
throwBacktrack(current.getOffset(), endOffset, current.getLineNumber(), current.getFilename()); |
4300 |
throwBacktrack(current.getOffset(), endOffset, current.getLineNumber(), current.getFilename()); |
4319 |
} |
4301 |
} |
4320 |
collection.addParameter(sdw); |
4302 |
collection.addParameter(sdw); |
Lines 4439-4445
Link Here
|
4439 |
className = duple.getToken(index); |
4421 |
className = duple.getToken(index); |
4440 |
} |
4422 |
} |
4441 |
|
4423 |
|
4442 |
boolean result = CharArrayUtils.equals( className.getCharImage(), duple.getLastToken().getCharImage() ); |
4424 |
boolean result = CharArrayUtils.equals(className.getCharImage(), duple.getLastToken().getCharImage()); |
4443 |
backup(mark); |
4425 |
backup(mark); |
4444 |
return result; |
4426 |
return result; |
4445 |
} finally { |
4427 |
} finally { |
Lines 4811-4817
Link Here
|
4811 |
} catch (ASTSemanticException e) { |
4793 |
} catch (ASTSemanticException e) { |
4812 |
throwBacktrack(e.getProblem()); |
4794 |
throwBacktrack(e.getProblem()); |
4813 |
} catch (Exception e) { |
4795 |
} catch (Exception e) { |
4814 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
4796 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
4815 |
logException( |
4797 |
logException( |
4816 |
"elaboratedTypeSpecifier:createElaboratedTypeSpecifier", e); //$NON-NLS-1$ |
4798 |
"elaboratedTypeSpecifier:createElaboratedTypeSpecifier", e); //$NON-NLS-1$ |
4817 |
throwBacktrack(t.getOffset(), endOffset, t.getLineNumber(), t.getFilename()); |
4799 |
throwBacktrack(t.getOffset(), endOffset, t.getLineNumber(), t.getFilename()); |
Lines 4876-4882
Link Here
|
4876 |
constructInitializers); |
4858 |
constructInitializers); |
4877 |
d.setInitializerClause(clause); |
4859 |
d.setInitializerClause(clause); |
4878 |
} |
4860 |
} |
4879 |
catch( EndOfFileException eof ) |
4861 |
catch (EndOfFileException eof) |
4880 |
{ |
4862 |
{ |
4881 |
failParse(); |
4863 |
failParse(); |
4882 |
throw eof; |
4864 |
throw eof; |
Lines 4992-5005
Link Here
|
4992 |
assignmentExpression, null, designators, |
4974 |
assignmentExpression, null, designators, |
4993 |
constructInitializers); |
4975 |
constructInitializers); |
4994 |
} catch (Exception e) { |
4976 |
} catch (Exception e) { |
4995 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
4977 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
4996 |
logException("cInitializerClause:createInitializerClause", e); //$NON-NLS-1$ |
4978 |
logException("cInitializerClause:createInitializerClause", e); //$NON-NLS-1$ |
4997 |
throwBacktrack(startingOffset, endOffset, line, fn); |
4979 |
throwBacktrack(startingOffset, endOffset, line, fn); |
4998 |
} |
4980 |
} |
4999 |
} catch (BacktrackException b) { |
4981 |
} catch (BacktrackException b) { |
5000 |
// do nothing |
4982 |
// do nothing |
5001 |
} |
4983 |
} |
5002 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
4984 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
5003 |
throwBacktrack(startingOffset, endOffset, line, fn); |
4985 |
throwBacktrack(startingOffset, endOffset, line, fn); |
5004 |
return null; |
4986 |
return null; |
5005 |
} |
4987 |
} |
Lines 5068-5074
Link Here
|
5068 |
IASTExpression assignmentExpression = assignmentExpression(scope, |
5050 |
IASTExpression assignmentExpression = assignmentExpression(scope, |
5069 |
CompletionKind.SINGLE_NAME_REFERENCE, |
5051 |
CompletionKind.SINGLE_NAME_REFERENCE, |
5070 |
KeywordSetKey.EXPRESSION); |
5052 |
KeywordSetKey.EXPRESSION); |
5071 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
5053 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
5072 |
try { |
5054 |
try { |
5073 |
return createInitializerClause(scope, |
5055 |
return createInitializerClause(scope, |
5074 |
IASTInitializerClause.Kind.ASSIGNMENT_EXPRESSION, |
5056 |
IASTInitializerClause.Kind.ASSIGNMENT_EXPRESSION, |
Lines 5216-5222
Link Here
|
5216 |
parameterScope, queryName)) |
5198 |
parameterScope, queryName)) |
5217 |
failed = true; |
5199 |
failed = true; |
5218 |
} catch (Exception e) { |
5200 |
} catch (Exception e) { |
5219 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
5201 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
5220 |
logException( |
5202 |
logException( |
5221 |
"declarator:queryIsTypeName", e); //$NON-NLS-1$ |
5203 |
"declarator:queryIsTypeName", e); //$NON-NLS-1$ |
5222 |
throwBacktrack(startingOffset, endOffset, line, newMark.getFilename()); |
5204 |
throwBacktrack(startingOffset, endOffset, line, newMark.getFilename()); |
Lines 5263-5269
Link Here
|
5263 |
seenParameter = false; |
5245 |
seenParameter = false; |
5264 |
break; |
5246 |
break; |
5265 |
default : |
5247 |
default : |
5266 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
5248 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
5267 |
if (seenParameter) |
5249 |
if (seenParameter) |
5268 |
throwBacktrack(startingOffset, endOffset, line, fn); |
5250 |
throwBacktrack(startingOffset, endOffset, line, fn); |
5269 |
parameterDeclaration(d, parameterScope); |
5251 |
parameterDeclaration(d, parameterScope); |
Lines 5337-5353
Link Here
|
5337 |
} catch (ASTSemanticException e) { |
5319 |
} catch (ASTSemanticException e) { |
5338 |
throwBacktrack(e.getProblem()); |
5320 |
throwBacktrack(e.getProblem()); |
5339 |
} catch (Exception e) { |
5321 |
} catch (Exception e) { |
5340 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
5322 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
5341 |
logException( |
5323 |
logException( |
5342 |
"declarator:createExceptionSpecification", e); //$NON-NLS-1$ |
5324 |
"declarator:createExceptionSpecification", e); //$NON-NLS-1$ |
5343 |
throwBacktrack(startingOffset, endOffset, line, fn); |
5325 |
throwBacktrack(startingOffset, endOffset, line, fn); |
5344 |
} |
5326 |
} |
5345 |
} |
5327 |
} |
5346 |
// check for optional pure virtual |
5328 |
// check for optional pure virtual |
5347 |
if (LT(1) == IToken.tASSIGN && LT(2) == IToken.tINTEGER ) |
5329 |
if (LT(1) == IToken.tASSIGN && LT(2) == IToken.tINTEGER ) |
5348 |
{ |
5330 |
{ |
5349 |
char[] image = LA(2).getCharImage(); |
5331 |
char[] image = LA(2).getCharImage(); |
5350 |
if( image.length == 1 && image[0] == '0' ){ |
5332 |
if (image.length == 1 && image[0] == '0'){ |
5351 |
consume(IToken.tASSIGN); |
5333 |
consume(IToken.tASSIGN); |
5352 |
consume(IToken.tINTEGER); |
5334 |
consume(IToken.tINTEGER); |
5353 |
d.setPureVirtual(true); |
5335 |
d.setPureVirtual(true); |
Lines 5444-5450
Link Here
|
5444 |
? argumentList |
5426 |
? argumentList |
5445 |
: null), kind); |
5427 |
: null), kind); |
5446 |
else { |
5428 |
else { |
5447 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
5429 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
5448 |
backup(mark); |
5430 |
backup(mark); |
5449 |
throwBacktrack(mark.getOffset(), endOffset, mark.getLineNumber(), mark.getFilename()); |
5431 |
throwBacktrack(mark.getOffset(), endOffset, mark.getLineNumber(), mark.getFilename()); |
5450 |
} |
5432 |
} |
Lines 5496-5506
Link Here
|
5496 |
} catch (ASTSemanticException e) { |
5478 |
} catch (ASTSemanticException e) { |
5497 |
throwBacktrack(e.getProblem()); |
5479 |
throwBacktrack(e.getProblem()); |
5498 |
} catch (Exception e) { |
5480 |
} catch (Exception e) { |
5499 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
5481 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
5500 |
logException("enumSpecifier:createEnumerationSpecifier", e); //$NON-NLS-1$ |
5482 |
logException("enumSpecifier:createEnumerationSpecifier", e); //$NON-NLS-1$ |
5501 |
throwBacktrack(mark.getOffset(), endOffset, mark.getLineNumber(), mark.getFilename()); |
5483 |
throwBacktrack(mark.getOffset(), endOffset, mark.getLineNumber(), mark.getFilename()); |
5502 |
} |
5484 |
} |
5503 |
handleEnumeration( enumeration ); |
5485 |
handleEnumeration(enumeration); |
5504 |
consume(IToken.tLBRACE); |
5486 |
consume(IToken.tLBRACE); |
5505 |
while (LT(1) != IToken.tRBRACE) { |
5487 |
while (LT(1) != IToken.tRBRACE) { |
5506 |
IToken enumeratorIdentifier = null; |
5488 |
IToken enumeratorIdentifier = null; |
Lines 5533-5539
Link Here
|
5533 |
} catch (ASTSemanticException e1) { |
5515 |
} catch (ASTSemanticException e1) { |
5534 |
throwBacktrack(e1.getProblem()); |
5516 |
throwBacktrack(e1.getProblem()); |
5535 |
} catch (Exception e) { |
5517 |
} catch (Exception e) { |
5536 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
5518 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
5537 |
logException("enumSpecifier:addEnumerator", e); //$NON-NLS-1$ |
5519 |
logException("enumSpecifier:addEnumerator", e); //$NON-NLS-1$ |
5538 |
throwBacktrack(mark.getOffset(), endOffset, mark.getLineNumber(), mark.getFilename()); |
5520 |
throwBacktrack(mark.getOffset(), endOffset, mark.getLineNumber(), mark.getFilename()); |
5539 |
} |
5521 |
} |
Lines 5544-5550
Link Here
|
5544 |
.freeReferences(); |
5526 |
.freeReferences(); |
5545 |
if (enumerator != null) |
5527 |
if (enumerator != null) |
5546 |
enumerator.freeReferences(); |
5528 |
enumerator.freeReferences(); |
5547 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
5529 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
5548 |
throwBacktrack(mark.getOffset(), endOffset, mark.getLineNumber(), mark.getFilename()); |
5530 |
throwBacktrack(mark.getOffset(), endOffset, mark.getLineNumber(), mark.getFilename()); |
5549 |
} |
5531 |
} |
5550 |
try { |
5532 |
try { |
Lines 5561-5567
Link Here
|
5561 |
} catch (ASTSemanticException e1) { |
5543 |
} catch (ASTSemanticException e1) { |
5562 |
throwBacktrack(e1.getProblem()); |
5544 |
throwBacktrack(e1.getProblem()); |
5563 |
} catch (Exception e) { |
5545 |
} catch (Exception e) { |
5564 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
5546 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
5565 |
logException("enumSpecifier:addEnumerator", e); //$NON-NLS-1$ |
5547 |
logException("enumSpecifier:addEnumerator", e); //$NON-NLS-1$ |
5566 |
throwBacktrack(mark.getOffset(), endOffset, mark.getLineNumber(), mark.getFilename()); |
5548 |
throwBacktrack(mark.getOffset(), endOffset, mark.getLineNumber(), mark.getFilename()); |
5567 |
} |
5549 |
} |
Lines 5574-5580
Link Here
|
5574 |
sdw.setTypeSpecifier(enumeration); |
5556 |
sdw.setTypeSpecifier(enumeration); |
5575 |
} else { |
5557 |
} else { |
5576 |
// enumSpecifierAbort |
5558 |
// enumSpecifierAbort |
5577 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
5559 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
5578 |
backup(mark); |
5560 |
backup(mark); |
5579 |
throwBacktrack(mark.getOffset(), endOffset, mark.getLineNumber(), mark.getFilename()); |
5561 |
throwBacktrack(mark.getOffset(), endOffset, mark.getLineNumber(), mark.getFilename()); |
5580 |
} |
5562 |
} |
Lines 5655-5661
Link Here
|
5655 |
} catch (ASTSemanticException e) { |
5637 |
} catch (ASTSemanticException e) { |
5656 |
throwBacktrack(e.getProblem()); |
5638 |
throwBacktrack(e.getProblem()); |
5657 |
} catch (Exception e) { |
5639 |
} catch (Exception e) { |
5658 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
5640 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
5659 |
logException("classSpecifier:createClassSpecifier", e); //$NON-NLS-1$ |
5641 |
logException("classSpecifier:createClassSpecifier", e); //$NON-NLS-1$ |
5660 |
throwBacktrack(mark.getOffset(), endOffset, mark.getLineNumber(), mark.getFilename()); |
5642 |
throwBacktrack(mark.getOffset(), endOffset, mark.getLineNumber(), mark.getFilename()); |
5661 |
} |
5643 |
} |
Lines 5757-5763
Link Here
|
5757 |
la = null; |
5739 |
la = null; |
5758 |
consume(IToken.tCOLON); |
5740 |
consume(IToken.tCOLON); |
5759 |
|
5741 |
|
5760 |
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.BASE_SPECIFIER ); |
5742 |
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.BASE_SPECIFIER); |
5761 |
boolean isVirtual = false; |
5743 |
boolean isVirtual = false; |
5762 |
ASTAccessVisibility visibility = ASTAccessVisibility.PUBLIC; |
5744 |
ASTAccessVisibility visibility = ASTAccessVisibility.PUBLIC; |
5763 |
ITokenDuple nameDuple = null; |
5745 |
ITokenDuple nameDuple = null; |
Lines 5770-5810
Link Here
|
5770 |
{ |
5752 |
{ |
5771 |
case IToken.t_virtual : |
5753 |
case IToken.t_virtual : |
5772 |
consume(IToken.t_virtual); |
5754 |
consume(IToken.t_virtual); |
5773 |
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.EMPTY ); |
5755 |
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.EMPTY); |
5774 |
isVirtual = true; |
5756 |
isVirtual = true; |
5775 |
break; |
5757 |
break; |
5776 |
case IToken.t_public : |
5758 |
case IToken.t_public : |
5777 |
consume(); |
5759 |
consume(); |
5778 |
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.EMPTY ); |
5760 |
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.EMPTY); |
5779 |
break; |
5761 |
break; |
5780 |
case IToken.t_protected : |
5762 |
case IToken.t_protected : |
5781 |
consume(); |
5763 |
consume(); |
5782 |
visibility = ASTAccessVisibility.PROTECTED; |
5764 |
visibility = ASTAccessVisibility.PROTECTED; |
5783 |
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.EMPTY ); |
5765 |
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.EMPTY); |
5784 |
break; |
5766 |
break; |
5785 |
case IToken.t_private : |
5767 |
case IToken.t_private : |
5786 |
visibility = ASTAccessVisibility.PRIVATE; |
5768 |
visibility = ASTAccessVisibility.PRIVATE; |
5787 |
consume(); |
5769 |
consume(); |
5788 |
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.EMPTY ); |
5770 |
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.EMPTY); |
5789 |
break; |
5771 |
break; |
5790 |
case IToken.tCOLONCOLON : |
5772 |
case IToken.tCOLONCOLON : |
5791 |
case IToken.tIDENTIFIER : |
5773 |
case IToken.tIDENTIFIER : |
5792 |
//to get templates right we need to use the class as the scope |
5774 |
//to get templates right we need to use the class as the scope |
5793 |
nameDuple = name(astClassSpec, CompletionKind.CLASS_REFERENCE, KeywordSetKey.BASE_SPECIFIER ); |
5775 |
nameDuple = name(astClassSpec, CompletionKind.CLASS_REFERENCE, KeywordSetKey.BASE_SPECIFIER); |
5794 |
break; |
5776 |
break; |
5795 |
case IToken.tCOMMA : |
5777 |
case IToken.tCOMMA : |
5796 |
//because we are using the class as the scope to get the name, we need to postpone adding the base |
5778 |
//because we are using the class as the scope to get the name, we need to postpone adding the base |
5797 |
//specifiers until after we have all the nameDuples |
5779 |
//specifiers until after we have all the nameDuples |
5798 |
if( bases == null ){ |
5780 |
if (bases == null){ |
5799 |
bases = new ArrayList(4); |
5781 |
bases = new ArrayList(4); |
5800 |
} |
5782 |
} |
5801 |
bases.add( new Object[] { isVirtual ? Boolean.TRUE : Boolean.FALSE, visibility, nameDuple } ); |
5783 |
bases.add(new Object[] { isVirtual ? Boolean.TRUE : Boolean.FALSE, visibility, nameDuple }); |
5802 |
|
5784 |
|
5803 |
isVirtual = false; |
5785 |
isVirtual = false; |
5804 |
visibility = ASTAccessVisibility.PUBLIC; |
5786 |
visibility = ASTAccessVisibility.PUBLIC; |
5805 |
nameDuple = null; |
5787 |
nameDuple = null; |
5806 |
consume(); |
5788 |
consume(); |
5807 |
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.BASE_SPECIFIER ); |
5789 |
setCompletionValues(astClassSpec.getOwnerScope(), CompletionKind.CLASS_REFERENCE, KeywordSetKey.BASE_SPECIFIER); |
5808 |
continue baseSpecifierLoop; |
5790 |
continue baseSpecifierLoop; |
5809 |
default : |
5791 |
default : |
5810 |
break baseSpecifierLoop; |
5792 |
break baseSpecifierLoop; |
Lines 5813-5829
Link Here
|
5813 |
|
5795 |
|
5814 |
try |
5796 |
try |
5815 |
{ |
5797 |
{ |
5816 |
if( bases != null ){ |
5798 |
if (bases != null){ |
5817 |
int size = bases.size(); |
5799 |
int size = bases.size(); |
5818 |
for( int i = 0; i < size; i++ ){ |
5800 |
for (int i = 0; i < size; i++){ |
5819 |
Object [] data = (Object[]) bases.get( i ); |
5801 |
Object [] data = (Object[]) bases.get(i); |
5820 |
try { |
5802 |
try { |
5821 |
astFactory.addBaseSpecifier( astClassSpec, |
5803 |
astFactory.addBaseSpecifier(astClassSpec, |
5822 |
((Boolean)data[0]).booleanValue(), |
5804 |
((Boolean)data[0]).booleanValue(), |
5823 |
(ASTAccessVisibility) data[1], |
5805 |
(ASTAccessVisibility) data[1], |
5824 |
(ITokenDuple)data[2] ); |
5806 |
(ITokenDuple)data[2]); |
5825 |
} catch (ASTSemanticException e1) { |
5807 |
} catch (ASTSemanticException e1) { |
5826 |
failParse( e1.getProblem() ); |
5808 |
failParse(e1.getProblem()); |
5827 |
} |
5809 |
} |
5828 |
} |
5810 |
} |
5829 |
} |
5811 |
} |
Lines 5832-5847
Link Here
|
5832 |
astClassSpec, |
5814 |
astClassSpec, |
5833 |
isVirtual, |
5815 |
isVirtual, |
5834 |
visibility, |
5816 |
visibility, |
5835 |
nameDuple ); |
5817 |
nameDuple); |
5836 |
} |
5818 |
} |
5837 |
catch (ASTSemanticException e) |
5819 |
catch (ASTSemanticException e) |
5838 |
{ |
5820 |
{ |
5839 |
failParse( e.getProblem() ); |
5821 |
failParse(e.getProblem()); |
5840 |
} catch (Exception e) |
5822 |
} catch (Exception e) |
5841 |
{ |
5823 |
{ |
5842 |
int endOffset = ( lastToken != null ) ? lastToken.getEndOffset() : 0 ; |
5824 |
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0 ; |
5843 |
logException( "baseSpecifier_2::addBaseSpecifier", e ); //$NON-NLS-1$ |
5825 |
logException("baseSpecifier_2::addBaseSpecifier", e); //$NON-NLS-1$ |
5844 |
throwBacktrack( startingOffset, endOffset, line, fn ); |
5826 |
throwBacktrack(startingOffset, endOffset, line, fn); |
5845 |
} |
5827 |
} |
5846 |
} |
5828 |
} |
5847 |
|
5829 |
|
Lines 5890-5896
Link Here
|
5890 |
cleanupLastToken(); |
5872 |
cleanupLastToken(); |
5891 |
return; |
5873 |
return; |
5892 |
case IToken.t_if : |
5874 |
case IToken.t_if : |
5893 |
if_loop: while( true ){ |
5875 |
if_loop: while(true){ |
5894 |
consume(IToken.t_if); |
5876 |
consume(IToken.t_if); |
5895 |
consume(IToken.tLPAREN); |
5877 |
consume(IToken.tLPAREN); |
5896 |
IToken start = LA(1); |
5878 |
IToken start = LA(1); |
Lines 5900-5920
Link Here
|
5900 |
consume(IToken.tRPAREN); |
5882 |
consume(IToken.tRPAREN); |
5901 |
} catch (BacktrackException b) { |
5883 |
} catch (BacktrackException b) { |
5902 |
//if the problem has no offset info, make a new one that does |
5884 |
//if the problem has no offset info, make a new one that does |
5903 |
if( b.getProblem() != null && b.getProblem().getSourceLineNumber() == -1 ){ |
5885 |
if (b.getProblem() != null && b.getProblem().getSourceLineNumber() == -1){ |
5904 |
IProblem p = b.getProblem(); |
5886 |
IProblem p = b.getProblem(); |
5905 |
IProblem p2 = problemFactory.createProblem( p.getID(), start.getOffset(), |
5887 |
IProblem p2 = problemFactory.createProblem(p.getID(), start.getOffset(), |
5906 |
lastToken != null ? lastToken.getEndOffset() : start.getEndOffset(), |
5888 |
lastToken != null ? lastToken.getEndOffset() : start.getEndOffset(), |
5907 |
start.getLineNumber(), p.getOriginatingFileName(), |
5889 |
start.getLineNumber(), p.getOriginatingFileName(), |
5908 |
p.getArguments() != null ? p.getArguments().toCharArray() : null, |
5890 |
p.getArguments(), |
5909 |
p.isWarning(), p.isError() ); |
5891 |
p.isWarning(), p.isError()); |
5910 |
b.initialize( p2 ); |
5892 |
b.initialize(p2); |
5911 |
} |
5893 |
} |
5912 |
failParse(b); |
5894 |
failParse(b); |
5913 |
failParseWithErrorHandling(); |
5895 |
failParseWithErrorHandling(); |
5914 |
passedCondition = false; |
5896 |
passedCondition = false; |
5915 |
} |
5897 |
} |
5916 |
|
5898 |
|
5917 |
if( passedCondition ){ |
5899 |
if (passedCondition){ |
5918 |
if (LT(1) != IToken.tLBRACE) |
5900 |
if (LT(1) != IToken.tLBRACE) |
5919 |
singleStatementScope(scope); |
5901 |
singleStatementScope(scope); |
5920 |
else |
5902 |
else |
Lines 6058-6110
Link Here
|
6058 |
// declarationStatement |
6040 |
// declarationStatement |
6059 |
declaration(scope, null, null, KeywordSetKey.STATEMENT); |
6041 |
declaration(scope, null, null, KeywordSetKey.STATEMENT); |
6060 |
} |
6042 |
} |
6061 |
|
|
|
6062 |
} |
6043 |
} |
|
|
6044 |
|
6063 |
protected void catchHandlerSequence(IASTScope scope) |
6045 |
protected void catchHandlerSequence(IASTScope scope) |
6064 |
throws EndOfFileException, BacktrackException { |
6046 |
throws EndOfFileException, BacktrackException { |
6065 |
if( LT(1) != IToken.t_catch ) |
6047 |
if (LT(1) != IToken.t_catch) { |
6066 |
{ |
|
|
6067 |
IToken la = LA(1); |
6048 |
IToken la = LA(1); |
6068 |
throwBacktrack(la.getOffset(), la.getEndOffset(), la.getLineNumber(), la.getFilename()); // error, need at least one of these |
6049 |
throwBacktrack(la.getOffset(), la.getEndOffset(), la.getLineNumber(), la.getFilename()); // error, need at least one of these |
6069 |
} |
6050 |
} |
6070 |
while (LT(1) == IToken.t_catch) |
6051 |
while (LT(1) == IToken.t_catch) { |
6071 |
{ |
|
|
6072 |
consume(IToken.t_catch); |
6052 |
consume(IToken.t_catch); |
6073 |
setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,KeywordSetKey.EMPTY ); |
6053 |
setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,KeywordSetKey.EMPTY); |
6074 |
consume(IToken.tLPAREN); |
6054 |
consume(IToken.tLPAREN); |
6075 |
setCompletionValues(scope,CompletionKind.EXCEPTION_REFERENCE,KeywordSetKey.DECL_SPECIFIER_SEQUENCE); |
6055 |
setCompletionValues(scope,CompletionKind.EXCEPTION_REFERENCE,KeywordSetKey.DECL_SPECIFIER_SEQUENCE); |
6076 |
try |
6056 |
try { |
6077 |
{ |
6057 |
if (LT(1) == IToken.tELLIPSIS) |
6078 |
if( LT(1) == IToken.tELLIPSIS ) |
6058 |
consume(IToken.tELLIPSIS); |
6079 |
consume( IToken.tELLIPSIS ); |
|
|
6080 |
else |
6059 |
else |
6081 |
simpleDeclaration( SimpleDeclarationStrategy.TRY_VARIABLE, scope, null, CompletionKind.EXCEPTION_REFERENCE, true, KeywordSetKey.DECLARATION); |
6060 |
simpleDeclaration(SimpleDeclarationStrategy.TRY_VARIABLE, scope, null, CompletionKind.EXCEPTION_REFERENCE, true, KeywordSetKey.DECLARATION); |
6082 |
consume(IToken.tRPAREN); |
6061 |
consume(IToken.tRPAREN); |
6083 |
|
6062 |
|
6084 |
catchBlockCompoundStatement(scope); |
6063 |
catchBlockCompoundStatement(scope); |
6085 |
} |
6064 |
} catch (BacktrackException bte) { |
6086 |
catch( BacktrackException bte ) |
6065 |
failParse(bte); |
6087 |
{ |
|
|
6088 |
failParse( bte ); |
6089 |
failParseWithErrorHandling(); |
6066 |
failParseWithErrorHandling(); |
6090 |
} |
6067 |
} |
6091 |
} |
6068 |
} |
6092 |
} |
6069 |
} |
6093 |
|
6070 |
|
6094 |
protected void catchBlockCompoundStatement(IASTScope scope) |
6071 |
protected void catchBlockCompoundStatement(IASTScope scope) |
6095 |
throws BacktrackException, EndOfFileException |
6072 |
throws BacktrackException, EndOfFileException { |
6096 |
{ |
6073 |
if (mode == ParserMode.QUICK_PARSE || mode == ParserMode.STRUCTURAL_PARSE) { |
6097 |
if( mode == ParserMode.QUICK_PARSE || mode == ParserMode.STRUCTURAL_PARSE ) |
|
|
6098 |
skipOverCompoundStatement(); |
6074 |
skipOverCompoundStatement(); |
6099 |
else if( mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE ) |
6075 |
} else if (mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE) { |
6100 |
{ |
6076 |
if (scanner.isOnTopContext()) |
6101 |
if( scanner.isOnTopContext() ) |
|
|
6102 |
compoundStatement(scope, true); |
6077 |
compoundStatement(scope, true); |
6103 |
else |
6078 |
else |
6104 |
skipOverCompoundStatement(); |
6079 |
skipOverCompoundStatement(); |
6105 |
} |
6080 |
} else if (mode == ParserMode.COMPLETE_PARSE) { |
6106 |
else if( mode == ParserMode.COMPLETE_PARSE ) |
|
|
6107 |
compoundStatement(scope, true); |
6081 |
compoundStatement(scope, true); |
|
|
6082 |
} |
6108 |
} |
6083 |
} |
6109 |
|
6084 |
|
6110 |
protected void singleStatementScope(IASTScope scope) |
6085 |
protected void singleStatementScope(IASTScope scope) |
Lines 6177-6191
Link Here
|
6177 |
try { |
6152 |
try { |
6178 |
newScope = astFactory.createNewCodeBlock(scope); |
6153 |
newScope = astFactory.createNewCodeBlock(scope); |
6179 |
} catch (Exception e) { |
6154 |
} catch (Exception e) { |
6180 |
int endOffset = ( lastToken == null ) ? 0 : lastToken.getEndOffset(); |
6155 |
int endOffset = (lastToken == null) ? 0 : lastToken.getEndOffset(); |
6181 |
logException("compoundStatement:createNewCodeBlock", e); //$NON-NLS-1$ |
6156 |
logException("compoundStatement:createNewCodeBlock", e); //$NON-NLS-1$ |
6182 |
throwBacktrack(startingOffset, endOffset, line, fn); |
6157 |
throwBacktrack(startingOffset, endOffset, line, fn); |
6183 |
} |
6158 |
} |
6184 |
newScope.enterScope(requestor); |
6159 |
newScope.enterScope(requestor); |
6185 |
} |
6160 |
} |
6186 |
|
6161 |
|
6187 |
try |
6162 |
try { |
6188 |
{ |
|
|
6189 |
setCompletionValues((createNewScope ? newScope : scope), |
6163 |
setCompletionValues((createNewScope ? newScope : scope), |
6190 |
CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.STATEMENT); |
6164 |
CompletionKind.SINGLE_NAME_REFERENCE, KeywordSetKey.STATEMENT); |
6191 |
|
6165 |
|
Lines 6204-6212
Link Here
|
6204 |
} |
6178 |
} |
6205 |
|
6179 |
|
6206 |
consume(IToken.tRBRACE); |
6180 |
consume(IToken.tRBRACE); |
6207 |
} |
6181 |
} finally { |
6208 |
finally |
|
|
6209 |
{ |
6210 |
if (createNewScope) |
6182 |
if (createNewScope) |
6211 |
newScope.exitScope(requestor); |
6183 |
newScope.exitScope(requestor); |
6212 |
} |
6184 |
} |
Lines 6251-6259
Link Here
|
6251 |
*/ |
6223 |
*/ |
6252 |
public ISelectionParseResult parse(int startingOffset, int endingOffset) |
6224 |
public ISelectionParseResult parse(int startingOffset, int endingOffset) |
6253 |
throws ParseError { |
6225 |
throws ParseError { |
6254 |
if( mode != ParserMode.SELECTION_PARSE ) |
6226 |
if (mode != ParserMode.SELECTION_PARSE) |
6255 |
throw new ParseError(ParseError.ParseErrorKind.METHOD_NOT_IMPLEMENTED); |
6227 |
throw new ParseError(ParseError.ParseErrorKind.METHOD_NOT_IMPLEMENTED); |
6256 |
offsetRange = new OffsetDuple( startingOffset, endingOffset ); |
6228 |
offsetRange = new OffsetDuple(startingOffset, endingOffset); |
6257 |
translationUnit(); |
6229 |
translationUnit(); |
6258 |
return reconcileTokenDuple(); |
6230 |
return reconcileTokenDuple(); |
6259 |
|
6231 |
|
Lines 6265-6278
Link Here
|
6265 |
* @see org.eclipse.cdt.core.parser.IParser#parse(int) |
6237 |
* @see org.eclipse.cdt.core.parser.IParser#parse(int) |
6266 |
*/ |
6238 |
*/ |
6267 |
public IASTCompletionNode parse(int offset) throws ParseError { |
6239 |
public IASTCompletionNode parse(int offset) throws ParseError { |
6268 |
if( mode != ParserMode.COMPLETION_PARSE ) |
6240 |
if (mode != ParserMode.COMPLETION_PARSE) |
6269 |
throw new ParseError(ParseError.ParseErrorKind.METHOD_NOT_IMPLEMENTED); |
6241 |
throw new ParseError(ParseError.ParseErrorKind.METHOD_NOT_IMPLEMENTED); |
6270 |
scanner.setOffsetBoundary(offset); |
6242 |
scanner.setOffsetBoundary(offset); |
6271 |
//long startTime = System.currentTimeMillis(); |
6243 |
//long startTime = System.currentTimeMillis(); |
6272 |
translationUnit(); |
6244 |
translationUnit(); |
6273 |
//long stopTime = System.currentTimeMillis(); |
6245 |
//long stopTime = System.currentTimeMillis(); |
6274 |
//System.out.println("Completion Parse time: " + (stopTime - startTime) + "ms"); |
6246 |
//System.out.println("Completion Parse time: " + (stopTime - startTime) + "ms"); |
6275 |
return new ASTCompletionNode( getCompletionKind(), getCompletionScope(), getCompletionContext(), getCompletionPrefix(), reconcileKeywords( getKeywordSet(), getCompletionPrefix() ), String.valueOf(getCompletionFunctionName()), getParameterListExpression() ); |
6247 |
return new ASTCompletionNode(getCompletionKind(), getCompletionScope(), getCompletionContext(), getCompletionPrefix(), reconcileKeywords(getKeywordSet(), getCompletionPrefix()), String.valueOf(getCompletionFunctionName()), getParameterListExpression()); |
6276 |
|
6248 |
|
6277 |
} |
6249 |
} |
6278 |
|
6250 |
|
Lines 6283-6289
Link Here
|
6283 |
* org.eclipse.cdt.core.parser.ParserLanguage) |
6255 |
* org.eclipse.cdt.core.parser.ParserLanguage) |
6284 |
*/ |
6256 |
*/ |
6285 |
protected void setupASTFactory(IScanner scanner, ParserLanguage language) { |
6257 |
protected void setupASTFactory(IScanner scanner, ParserLanguage language) { |
6286 |
astFactory = ParserFactory.createASTFactory( mode, language); |
6258 |
astFactory = ParserFactory.createASTFactory(mode, language); |
6287 |
scanner.setASTFactory(astFactory); |
6259 |
scanner.setASTFactory(astFactory); |
6288 |
astFactory.setLogger(log); |
6260 |
astFactory.setLogger(log); |
6289 |
} |
6261 |
} |
Lines 6299-6305
Link Here
|
6299 |
|
6271 |
|
6300 |
protected void endDeclaration(IASTDeclaration declaration) |
6272 |
protected void endDeclaration(IASTDeclaration declaration) |
6301 |
throws EndOfFileException { |
6273 |
throws EndOfFileException { |
6302 |
if( mode != ParserMode.SELECTION_PARSE || ! tokenDupleCompleted() ) |
6274 |
if (mode != ParserMode.SELECTION_PARSE || ! tokenDupleCompleted()) |
6303 |
cleanupLastToken(); |
6275 |
cleanupLastToken(); |
6304 |
else |
6276 |
else |
6305 |
{ |
6277 |
{ |
Lines 6331-6337
Link Here
|
6331 |
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#validateCaches() |
6303 |
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#validateCaches() |
6332 |
*/ |
6304 |
*/ |
6333 |
public boolean validateCaches() { |
6305 |
public boolean validateCaches() { |
6334 |
if( astFactory instanceof CompleteParseASTFactory) |
6306 |
if (astFactory instanceof CompleteParseASTFactory) |
6335 |
return ((CompleteParseASTFactory)astFactory).validateCaches(); |
6307 |
return ((CompleteParseASTFactory)astFactory).validateCaches(); |
6336 |
return true; |
6308 |
return true; |
6337 |
} |
6309 |
} |
Lines 6365-6371
Link Here
|
6365 |
* @return |
6337 |
* @return |
6366 |
*/ |
6338 |
*/ |
6367 |
protected String getCompletionPrefix() { |
6339 |
protected String getCompletionPrefix() { |
6368 |
return ( finalToken == null ? String.valueOf(EMPTY_STRING) : finalToken.getImage() ); |
6340 |
return (finalToken == null ? String.valueOf(EMPTY_STRING) : finalToken.getImage()); |
6369 |
} |
6341 |
} |
6370 |
|
6342 |
|
6371 |
/** |
6343 |
/** |
Lines 6376-6387
Link Here
|
6376 |
} |
6348 |
} |
6377 |
|
6349 |
|
6378 |
protected void setCompletionContext(IASTNode node) { |
6350 |
protected void setCompletionContext(IASTNode node) { |
6379 |
if( mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE ) |
6351 |
if (mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE) |
6380 |
this.context = node; |
6352 |
this.context = node; |
6381 |
} |
6353 |
} |
6382 |
|
6354 |
|
6383 |
protected void setCompletionKind(IASTCompletionNode.CompletionKind kind) { |
6355 |
protected void setCompletionKind(IASTCompletionNode.CompletionKind kind) { |
6384 |
if( mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE ) |
6356 |
if (mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE) |
6385 |
this.cKind = kind; |
6357 |
this.cKind = kind; |
6386 |
} |
6358 |
} |
6387 |
|
6359 |
|
Lines 6393-6464
Link Here
|
6393 |
* @param string |
6365 |
* @param string |
6394 |
*/ |
6366 |
*/ |
6395 |
protected void setCompletionValues(CompletionKind kind, Set keywordSet, String prefix) { |
6367 |
protected void setCompletionValues(CompletionKind kind, Set keywordSet, String prefix) { |
6396 |
if( mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE ) |
6368 |
if (mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE) |
6397 |
{ |
6369 |
{ |
6398 |
setCompletionScope(compilationUnit); |
6370 |
setCompletionScope(compilationUnit); |
6399 |
this.keywordSet = keywordSet; |
6371 |
this.keywordSet = keywordSet; |
6400 |
setCompletionKind(kind); |
6372 |
setCompletionKind(kind); |
6401 |
setCompletionContext(null); |
6373 |
setCompletionContext(null); |
6402 |
setCompletionFunctionName( ); |
6374 |
setCompletionFunctionName(); |
6403 |
setCompletionToken( TokenFactory.createStandAloneToken( IToken.tIDENTIFIER, prefix ) ); |
6375 |
setCompletionToken(TokenFactory.createStandAloneToken(IToken.tIDENTIFIER, prefix)); |
6404 |
} |
6376 |
} |
6405 |
} |
6377 |
} |
6406 |
|
6378 |
|
6407 |
/** |
6379 |
/** |
6408 |
*/ |
6380 |
*/ |
6409 |
protected void setCompletionFunctionName() { |
6381 |
protected void setCompletionFunctionName() { |
6410 |
if( mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE ) |
6382 |
if (mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE) |
6411 |
functionOrConstructorName = currentFunctionName; |
6383 |
functionOrConstructorName = currentFunctionName; |
6412 |
} |
6384 |
} |
6413 |
|
6385 |
|
6414 |
|
6386 |
|
6415 |
|
6387 |
|
6416 |
protected void setCompletionKeywords(KeywordSetKey key) { |
6388 |
protected void setCompletionKeywords(KeywordSetKey key) { |
6417 |
this.keywordSet = KeywordSets.getKeywords( key, language ); |
6389 |
this.keywordSet = KeywordSets.getKeywords(key, language); |
6418 |
} |
6390 |
} |
6419 |
|
6391 |
|
6420 |
protected void setCompletionToken(IToken token) { |
6392 |
protected void setCompletionToken(IToken token) { |
6421 |
if( mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE ) |
6393 |
if (mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE) |
6422 |
finalToken = token; |
6394 |
finalToken = token; |
6423 |
} |
6395 |
} |
6424 |
|
6396 |
|
6425 |
protected void setCompletionValues(IASTScope scope, CompletionKind kind, KeywordSetKey key, IASTNode node, String prefix) throws EndOfFileException { |
6397 |
protected void setCompletionValues(IASTScope scope, CompletionKind kind, KeywordSetKey key, IASTNode node, String prefix) throws EndOfFileException { |
6426 |
if( mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE ) |
6398 |
if (mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE) |
6427 |
{ |
6399 |
{ |
6428 |
setCompletionToken( TokenFactory.createStandAloneToken( IToken.tIDENTIFIER, prefix ) ); |
6400 |
setCompletionToken(TokenFactory.createStandAloneToken(IToken.tIDENTIFIER, prefix)); |
6429 |
setCompletionValues(scope, kind, key, node ); |
6401 |
setCompletionValues(scope, kind, key, node); |
6430 |
} |
6402 |
} |
6431 |
} |
6403 |
} |
6432 |
|
6404 |
|
6433 |
protected void setCompletionValues(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws EndOfFileException { |
6405 |
protected void setCompletionValues(IASTScope scope, CompletionKind kind, KeywordSetKey key) throws EndOfFileException { |
6434 |
if( mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE ) |
6406 |
if (mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE) |
6435 |
setCompletionValues(scope, kind, key, null ); |
6407 |
setCompletionValues(scope, kind, key, null); |
6436 |
} |
6408 |
} |
6437 |
|
6409 |
|
6438 |
|
6410 |
|
6439 |
|
6411 |
|
6440 |
protected void setCompletionValues(IASTScope scope, CompletionKind kind, KeywordSetKey key, IASTNode node) throws EndOfFileException { |
6412 |
protected void setCompletionValues(IASTScope scope, CompletionKind kind, KeywordSetKey key, IASTNode node) throws EndOfFileException { |
6441 |
if( mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE ) |
6413 |
if (mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE) |
6442 |
{ |
6414 |
{ |
6443 |
setCompletionScope(scope); |
6415 |
setCompletionScope(scope); |
6444 |
setCompletionKeywords(key); |
6416 |
setCompletionKeywords(key); |
6445 |
setCompletionKind(kind); |
6417 |
setCompletionKind(kind); |
6446 |
setCompletionContext(node); |
6418 |
setCompletionContext(node); |
6447 |
setCompletionFunctionName( ); |
6419 |
setCompletionFunctionName(); |
6448 |
checkEndOfFile(); |
6420 |
checkEndOfFile(); |
6449 |
} |
6421 |
} |
6450 |
} |
6422 |
} |
6451 |
|
6423 |
|
6452 |
|
6424 |
|
6453 |
protected void setCompletionValues( IASTScope scope, CompletionKind kind, IToken first, IToken last, List arguments, KeywordSetKey key ) throws EndOfFileException{ |
6425 |
protected void setCompletionValues(IASTScope scope, CompletionKind kind, IToken first, IToken last, List arguments, KeywordSetKey key) throws EndOfFileException{ |
6454 |
if( mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE ) |
6426 |
if (mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE) |
6455 |
{ |
6427 |
{ |
6456 |
setCompletionScope( scope ); |
6428 |
setCompletionScope(scope); |
6457 |
setCompletionKind( kind ); |
6429 |
setCompletionKind(kind); |
6458 |
setCompletionKeywords(key); |
6430 |
setCompletionKeywords(key); |
6459 |
ITokenDuple duple = TokenFactory.createTokenDuple( first, last, arguments ); |
6431 |
ITokenDuple duple = TokenFactory.createTokenDuple(first, last, arguments); |
6460 |
try { |
6432 |
try { |
6461 |
setCompletionContext( astFactory.lookupSymbolInContext( scope, duple, null ) ); |
6433 |
setCompletionContext(astFactory.lookupSymbolInContext(scope, duple, null)); |
6462 |
} catch (ASTNotImplementedException e) { |
6434 |
} catch (ASTNotImplementedException e) { |
6463 |
} |
6435 |
} |
6464 |
setCompletionFunctionName(); |
6436 |
setCompletionFunctionName(); |
Lines 6466-6480
Link Here
|
6466 |
} |
6438 |
} |
6467 |
|
6439 |
|
6468 |
protected void setCompletionValues(IASTScope scope, CompletionKind kind, KeywordSetKey key, IASTExpression firstExpression, Kind expressionKind) throws EndOfFileException { |
6440 |
protected void setCompletionValues(IASTScope scope, CompletionKind kind, KeywordSetKey key, IASTExpression firstExpression, Kind expressionKind) throws EndOfFileException { |
6469 |
if( mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE ) |
6441 |
if (mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE) |
6470 |
{ |
6442 |
{ |
6471 |
IASTNode node = astFactory.expressionToMostPreciseASTNode( scope, firstExpression ); |
6443 |
IASTNode node = astFactory.expressionToMostPreciseASTNode(scope, firstExpression); |
6472 |
if( kind == CompletionKind.MEMBER_REFERENCE ) |
6444 |
if (kind == CompletionKind.MEMBER_REFERENCE) |
6473 |
{ |
6445 |
{ |
6474 |
if( ! validMemberOperation( node, expressionKind )) |
6446 |
if (! validMemberOperation(node, expressionKind)) |
6475 |
node =null; |
6447 |
node =null; |
6476 |
} |
6448 |
} |
6477 |
setCompletionValues(scope,kind,key, node ); |
6449 |
setCompletionValues(scope,kind,key, node ); |
6478 |
} |
6450 |
} |
6479 |
} |
6451 |
} |
6480 |
|
6452 |
|
Lines 6484-6498
Link Here
|
6484 |
* @return |
6456 |
* @return |
6485 |
*/ |
6457 |
*/ |
6486 |
private boolean validMemberOperation(IASTNode node, Kind expressionKind) { |
6458 |
private boolean validMemberOperation(IASTNode node, Kind expressionKind) { |
6487 |
if( expressionKind == Kind.POSTFIX_ARROW_IDEXPRESSION || expressionKind == Kind.POSTFIX_ARROW_TEMPL_IDEXP ) |
6459 |
if (expressionKind == Kind.POSTFIX_ARROW_IDEXPRESSION || expressionKind == Kind.POSTFIX_ARROW_TEMPL_IDEXP) |
6488 |
return astFactory.validateIndirectMemberOperation( node ); |
6460 |
return astFactory.validateIndirectMemberOperation(node); |
6489 |
else if( expressionKind == Kind.POSTFIX_DOT_IDEXPRESSION || expressionKind == Kind.POSTFIX_DOT_TEMPL_IDEXPRESS ) |
6461 |
else if (expressionKind == Kind.POSTFIX_DOT_IDEXPRESSION || expressionKind == Kind.POSTFIX_DOT_TEMPL_IDEXPRESS) |
6490 |
return astFactory.validateDirectMemberOperation( node ); |
6462 |
return astFactory.validateDirectMemberOperation(node); |
6491 |
return false; |
6463 |
return false; |
6492 |
} |
6464 |
} |
6493 |
|
6465 |
|
6494 |
protected void setCompletionScope(IASTScope scope) { |
6466 |
protected void setCompletionScope(IASTScope scope) { |
6495 |
if( mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE ) |
6467 |
if (mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE) |
6496 |
this.contextualScope = scope; |
6468 |
this.contextualScope = scope; |
6497 |
} |
6469 |
} |
6498 |
|
6470 |
|
Lines 6500-6510
Link Here
|
6500 |
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setCompletionValues(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind) |
6472 |
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setCompletionValues(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind) |
6501 |
*/ |
6473 |
*/ |
6502 |
protected void setCompletionValues(IASTScope scope, CompletionKind kind) throws EndOfFileException { |
6474 |
protected void setCompletionValues(IASTScope scope, CompletionKind kind) throws EndOfFileException { |
6503 |
if( mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE ) |
6475 |
if (mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE) |
6504 |
{ |
6476 |
{ |
6505 |
setCompletionScope(scope); |
6477 |
setCompletionScope(scope); |
6506 |
setCompletionKind(kind); |
6478 |
setCompletionKind(kind); |
6507 |
setCompletionFunctionName( ); |
6479 |
setCompletionFunctionName(); |
6508 |
checkEndOfFile(); |
6480 |
checkEndOfFile(); |
6509 |
} |
6481 |
} |
6510 |
} |
6482 |
} |
Lines 6514-6525
Link Here
|
6514 |
*/ |
6486 |
*/ |
6515 |
protected void setCompletionValues(IASTScope scope, CompletionKind kind, |
6487 |
protected void setCompletionValues(IASTScope scope, CompletionKind kind, |
6516 |
IASTNode context) throws EndOfFileException { |
6488 |
IASTNode context) throws EndOfFileException { |
6517 |
if( mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE ) |
6489 |
if (mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE) |
6518 |
{ |
6490 |
{ |
6519 |
setCompletionScope(scope); |
6491 |
setCompletionScope(scope); |
6520 |
setCompletionKind(kind); |
6492 |
setCompletionKind(kind); |
6521 |
setCompletionContext(context); |
6493 |
setCompletionContext(context); |
6522 |
setCompletionFunctionName( ); |
6494 |
setCompletionFunctionName(); |
6523 |
checkEndOfFile(); |
6495 |
checkEndOfFile(); |
6524 |
} |
6496 |
} |
6525 |
} |
6497 |
} |
Lines 6536-6542
Link Here
|
6536 |
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setCurrentFunctionName(java.lang.String) |
6508 |
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setCurrentFunctionName(java.lang.String) |
6537 |
*/ |
6509 |
*/ |
6538 |
protected void setCurrentFunctionName(char[] functionName) { |
6510 |
protected void setCurrentFunctionName(char[] functionName) { |
6539 |
if( mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE ) |
6511 |
if (mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE) |
6540 |
currentFunctionName = functionName; |
6512 |
currentFunctionName = functionName; |
6541 |
} |
6513 |
} |
6542 |
|
6514 |
|
Lines 6545-6551
Link Here
|
6545 |
*/ |
6517 |
*/ |
6546 |
protected void setCompletionValuesNoContext(IASTScope scope, |
6518 |
protected void setCompletionValuesNoContext(IASTScope scope, |
6547 |
CompletionKind kind, KeywordSetKey key) throws EndOfFileException { |
6519 |
CompletionKind kind, KeywordSetKey key) throws EndOfFileException { |
6548 |
if( mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE ) |
6520 |
if (mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE) |
6549 |
{ |
6521 |
{ |
6550 |
setCompletionScope(scope); |
6522 |
setCompletionScope(scope); |
6551 |
setCompletionKeywords(key); |
6523 |
setCompletionKeywords(key); |
Lines 6559-6565
Link Here
|
6559 |
*/ |
6531 |
*/ |
6560 |
protected void setParameterListExpression( |
6532 |
protected void setParameterListExpression( |
6561 |
IASTExpression assignmentExpression) { |
6533 |
IASTExpression assignmentExpression) { |
6562 |
if( mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE ) |
6534 |
if (mode == ParserMode.COMPLETION_PARSE || mode == ParserMode.SELECTION_PARSE) |
6563 |
parameterListExpression = assignmentExpression; |
6535 |
parameterListExpression = assignmentExpression; |
6564 |
} |
6536 |
} |
6565 |
/** |
6537 |
/** |
Lines 6582-6611
Link Here
|
6582 |
* @see org.eclipse.cdt.internal.core.parser.Parser#handleNewToken(org.eclipse.cdt.core.parser.IToken) |
6554 |
* @see org.eclipse.cdt.internal.core.parser.Parser#handleNewToken(org.eclipse.cdt.core.parser.IToken) |
6583 |
*/ |
6555 |
*/ |
6584 |
protected void handleNewToken(IToken value) { |
6556 |
protected void handleNewToken(IToken value) { |
6585 |
if( mode != ParserMode.SELECTION_PARSE ) return; |
6557 |
if (mode != ParserMode.SELECTION_PARSE) return; |
6586 |
if( value != null && CharArrayUtils.equals(value.getFilename(), parserStartFilename)) |
6558 |
if (value != null && CharArrayUtils.equals(value.getFilename(), parserStartFilename)) |
6587 |
{ |
6559 |
{ |
6588 |
TraceUtil.outputTrace(log, "IToken provided w/offsets ", null, value.getOffset(), " & ", value.getEndOffset() ); //$NON-NLS-1$ //$NON-NLS-2$ |
6560 |
TraceUtil.outputTrace(log, "IToken provided w/offsets ", null, value.getOffset(), " & ", value.getEndOffset()); //$NON-NLS-1$ //$NON-NLS-2$ |
6589 |
boolean change = false; |
6561 |
boolean change = false; |
6590 |
if( value.getOffset() == offsetRange.getFloorOffset() ) |
6562 |
if (value.getOffset() == offsetRange.getFloorOffset()) |
6591 |
{ |
6563 |
{ |
6592 |
TraceUtil.outputTrace(log, "Offset Floor Hit w/token \"", null, value.getCharImage(), "\"", null ); //$NON-NLS-1$ //$NON-NLS-2$ |
6564 |
TraceUtil.outputTrace(log, "Offset Floor Hit w/token \"", null, value.getCharImage(), "\"", null); //$NON-NLS-1$ //$NON-NLS-2$ |
6593 |
firstTokenOfDuple = value; |
6565 |
firstTokenOfDuple = value; |
6594 |
change = true; |
6566 |
change = true; |
6595 |
} |
6567 |
} |
6596 |
if( value.getEndOffset() == offsetRange.getCeilingOffset() ) |
6568 |
if (value.getEndOffset() == offsetRange.getCeilingOffset()) |
6597 |
{ |
6569 |
{ |
6598 |
TraceUtil.outputTrace(log, "Offset Ceiling Hit w/token \"", null, value.getCharImage(), "\"", null ); //$NON-NLS-1$ //$NON-NLS-2$ |
6570 |
TraceUtil.outputTrace(log, "Offset Ceiling Hit w/token \"", null, value.getCharImage(), "\"", null); //$NON-NLS-1$ //$NON-NLS-2$ |
6599 |
change = true; |
6571 |
change = true; |
6600 |
lastTokenOfDuple = value; |
6572 |
lastTokenOfDuple = value; |
6601 |
} |
6573 |
} |
6602 |
if( change && tokenDupleCompleted() ) |
6574 |
if (change && tokenDupleCompleted()) |
6603 |
{ |
6575 |
{ |
6604 |
if ( ourScope == null ) |
6576 |
if (ourScope == null) |
6605 |
ourScope = getCompletionScope(); |
6577 |
ourScope = getCompletionScope(); |
6606 |
if( ourContext == null ) |
6578 |
if (ourContext == null) |
6607 |
ourContext = getCompletionContext(); |
6579 |
ourContext = getCompletionContext(); |
6608 |
if( ourKind == null ) |
6580 |
if (ourKind == null) |
6609 |
ourKind = getCompletionKind(); |
6581 |
ourKind = getCompletionKind(); |
6610 |
} |
6582 |
} |
6611 |
} |
6583 |
} |
Lines 6626-6641
Link Here
|
6626 |
* |
6598 |
* |
6627 |
*/ |
6599 |
*/ |
6628 |
protected ISelectionParseResult reconcileTokenDuple() throws ParseError { |
6600 |
protected ISelectionParseResult reconcileTokenDuple() throws ParseError { |
6629 |
if( firstTokenOfDuple == null || lastTokenOfDuple == null ) |
6601 |
if (firstTokenOfDuple == null || lastTokenOfDuple == null) |
6630 |
throw new ParseError( ParseError.ParseErrorKind.OFFSET_RANGE_NOT_NAME ); |
6602 |
throw new ParseError(ParseError.ParseErrorKind.OFFSET_RANGE_NOT_NAME); |
6631 |
|
6603 |
|
6632 |
if( getCompletionKind() == IASTCompletionNode.CompletionKind.UNREACHABLE_CODE ) |
6604 |
if (getCompletionKind() == IASTCompletionNode.CompletionKind.UNREACHABLE_CODE) |
6633 |
throw new ParseError( ParseError.ParseErrorKind.OFFSETDUPLE_UNREACHABLE ); |
6605 |
throw new ParseError(ParseError.ParseErrorKind.OFFSETDUPLE_UNREACHABLE); |
6634 |
|
6606 |
|
6635 |
ITokenDuple duple = TokenFactory.createTokenDuple( firstTokenOfDuple, lastTokenOfDuple ); |
6607 |
ITokenDuple duple = TokenFactory.createTokenDuple(firstTokenOfDuple, lastTokenOfDuple); |
6636 |
|
6608 |
|
6637 |
if( ! duple.syntaxOfName() ) |
6609 |
if (! duple.syntaxOfName()) |
6638 |
throw new ParseError( ParseError.ParseErrorKind.OFFSET_RANGE_NOT_NAME ); |
6610 |
throw new ParseError(ParseError.ParseErrorKind.OFFSET_RANGE_NOT_NAME); |
6639 |
|
6611 |
|
6640 |
return provideSelectionNode(duple); |
6612 |
return provideSelectionNode(duple); |
6641 |
} |
6613 |
} |
Lines 6648-6673
Link Here
|
6648 |
|
6620 |
|
6649 |
ITokenDuple finalDuple = null; |
6621 |
ITokenDuple finalDuple = null; |
6650 |
// reconcile the name to look up first |
6622 |
// reconcile the name to look up first |
6651 |
if( ! duple.equals( greaterContextDuple )) |
6623 |
if (! duple.equals(greaterContextDuple)) |
6652 |
{ |
6624 |
{ |
6653 |
// 3 cases |
6625 |
// 3 cases |
6654 |
// duple is prefix of greaterContextDuple |
6626 |
// duple is prefix of greaterContextDuple |
6655 |
// or duple is suffix of greaterContextDuple |
6627 |
// or duple is suffix of greaterContextDuple |
6656 |
// duple is a sub-duple of greaterContextDuple |
6628 |
// duple is a sub-duple of greaterContextDuple |
6657 |
if( greaterContextDuple == null || duple.getFirstToken().equals( greaterContextDuple.getFirstToken() )) |
6629 |
if (greaterContextDuple == null || duple.getFirstToken().equals(greaterContextDuple.getFirstToken())) |
6658 |
finalDuple = duple; // => do not use greaterContextDuple |
6630 |
finalDuple = duple; // => do not use greaterContextDuple |
6659 |
else if( duple.getLastSegment().getFirstToken().equals( greaterContextDuple.getLastSegment().getFirstToken() )) |
6631 |
else if (duple.getLastSegment().getFirstToken().equals(greaterContextDuple.getLastSegment().getFirstToken())) |
6660 |
finalDuple = greaterContextDuple; // => use greaterContextDuple |
6632 |
finalDuple = greaterContextDuple; // => use greaterContextDuple |
6661 |
else |
6633 |
else |
6662 |
throw new ParseError( ParseError.ParseErrorKind.OFFSET_RANGE_NOT_NAME ); |
6634 |
throw new ParseError(ParseError.ParseErrorKind.OFFSET_RANGE_NOT_NAME); |
6663 |
} |
6635 |
} |
6664 |
else |
6636 |
else |
6665 |
finalDuple = greaterContextDuple; |
6637 |
finalDuple = greaterContextDuple; |
6666 |
|
6638 |
|
6667 |
IASTNode node = lookupNode(finalDuple); |
6639 |
IASTNode node = lookupNode(finalDuple); |
6668 |
if( node == null ) return null; |
6640 |
if (node == null) return null; |
6669 |
if( !(node instanceof IASTOffsetableNamedElement )) return null; |
6641 |
if (!(node instanceof IASTOffsetableNamedElement)) return null; |
6670 |
return new SelectionParseResult( (IASTOffsetableNamedElement) node, new String( ((IASTOffsetableElement)node).getFilename() )); |
6642 |
return new SelectionParseResult((IASTOffsetableNamedElement) node, new String(((IASTOffsetableElement)node).getFilename())); |
6671 |
} |
6643 |
} |
6672 |
|
6644 |
|
6673 |
|
6645 |
|
Lines 6678-6689
Link Here
|
6678 |
* @return |
6650 |
* @return |
6679 |
*/ |
6651 |
*/ |
6680 |
protected IASTNode lookupNode(ITokenDuple finalDuple) { |
6652 |
protected IASTNode lookupNode(ITokenDuple finalDuple) { |
6681 |
if( contextNode == null ) return null; |
6653 |
if (contextNode == null) return null; |
6682 |
if( contextNode instanceof IASTDeclaration ) |
6654 |
if (contextNode instanceof IASTDeclaration) |
6683 |
{ |
6655 |
{ |
6684 |
if( contextNode instanceof IASTOffsetableNamedElement && !(contextNode instanceof IASTUsingDirective) && !(contextNode instanceof IASTUsingDeclaration)) |
6656 |
if (contextNode instanceof IASTOffsetableNamedElement && !(contextNode instanceof IASTUsingDirective) && !(contextNode instanceof IASTUsingDeclaration)) |
6685 |
{ |
6657 |
{ |
6686 |
if( contextNode instanceof IASTFunction ) { |
6658 |
if (contextNode instanceof IASTFunction) { |
6687 |
Iterator i = ((IASTFunction)contextNode).getParameters(); |
6659 |
Iterator i = ((IASTFunction)contextNode).getParameters(); |
6688 |
while (i.hasNext()) { |
6660 |
while (i.hasNext()) { |
6689 |
IASTParameterDeclaration parm = (IASTParameterDeclaration)i.next(); |
6661 |
IASTParameterDeclaration parm = (IASTParameterDeclaration)i.next(); |
Lines 6703-6719
Link Here
|
6703 |
} |
6675 |
} |
6704 |
} |
6676 |
} |
6705 |
|
6677 |
|
6706 |
if( ((IASTOffsetableNamedElement)contextNode).getName().equals( finalDuple.toString() ) && ((IASTOffsetableNamedElement)contextNode).getNameOffset() == finalDuple.getStartOffset()) // 75731 needs to include offset for equality as well... |
6678 |
if (((IASTOffsetableNamedElement)contextNode).getName().equals(finalDuple.toString()) && ((IASTOffsetableNamedElement)contextNode).getNameOffset() == finalDuple.getStartOffset()) // 75731 needs to include offset for equality as well... |
6707 |
return contextNode; |
6679 |
return contextNode; |
6708 |
} |
6680 |
} |
6709 |
if( contextNode instanceof IASTQualifiedNameElement ) |
6681 |
if (contextNode instanceof IASTQualifiedNameElement) |
6710 |
{ |
6682 |
{ |
6711 |
String [] elementQualifiedName = ((IASTQualifiedNameElement)contextNode).getFullyQualifiedName(); |
6683 |
String [] elementQualifiedName = ((IASTQualifiedNameElement)contextNode).getFullyQualifiedName(); |
6712 |
if( Arrays.equals( elementQualifiedName, finalDuple.toQualifiedName() ) ){ |
6684 |
if (Arrays.equals(elementQualifiedName, finalDuple.toQualifiedName())){ |
6713 |
IASTNode declNode = null; |
6685 |
IASTNode declNode = null; |
6714 |
if( contextNode instanceof ISymbolOwner ){ |
6686 |
if (contextNode instanceof ISymbolOwner){ |
6715 |
ISymbolOwner owner = (ISymbolOwner) contextNode; |
6687 |
ISymbolOwner owner = (ISymbolOwner) contextNode; |
6716 |
if( owner.getSymbol() != null && owner.getSymbol().getASTExtension() != null ){ |
6688 |
if (owner.getSymbol() != null && owner.getSymbol().getASTExtension() != null){ |
6717 |
declNode = owner.getSymbol().getASTExtension().getPrimaryDeclaration(); |
6689 |
declNode = owner.getSymbol().getASTExtension().getPrimaryDeclaration(); |
6718 |
} |
6690 |
} |
6719 |
} |
6691 |
} |
Lines 6721-6748
Link Here
|
6721 |
} |
6693 |
} |
6722 |
} |
6694 |
} |
6723 |
try { |
6695 |
try { |
6724 |
if( ourKind == IASTCompletionNode.CompletionKind.NEW_TYPE_REFERENCE ) |
6696 |
if (ourKind == IASTCompletionNode.CompletionKind.NEW_TYPE_REFERENCE) |
6725 |
{ |
6697 |
{ |
6726 |
if( contextNode instanceof IASTVariable ) |
6698 |
if (contextNode instanceof IASTVariable) |
6727 |
{ |
6699 |
{ |
6728 |
IASTInitializerClause initializer = ((IASTVariable)contextNode).getInitializerClause(); |
6700 |
IASTInitializerClause initializer = ((IASTVariable)contextNode).getInitializerClause(); |
6729 |
if( initializer != null ) |
6701 |
if (initializer != null) |
6730 |
{ |
6702 |
{ |
6731 |
IASTExpression ownerExpression = initializer.findExpressionForDuple( finalDuple ); |
6703 |
IASTExpression ownerExpression = initializer.findExpressionForDuple(finalDuple); |
6732 |
return astFactory.lookupSymbolInContext( ourScope, finalDuple, ownerExpression ); |
6704 |
return astFactory.lookupSymbolInContext(ourScope, finalDuple, ownerExpression); |
6733 |
} |
6705 |
} |
6734 |
} |
6706 |
} |
6735 |
} |
6707 |
} |
6736 |
|
6708 |
|
6737 |
return astFactory.lookupSymbolInContext( ourScope, finalDuple, null ); |
6709 |
return astFactory.lookupSymbolInContext(ourScope, finalDuple, null); |
6738 |
} catch (ASTNotImplementedException e) { |
6710 |
} catch (ASTNotImplementedException e) { |
6739 |
return null; |
6711 |
return null; |
6740 |
} |
6712 |
} |
6741 |
} |
6713 |
} |
6742 |
else if( contextNode instanceof IASTExpression ) |
6714 |
else if (contextNode instanceof IASTExpression) |
6743 |
{ |
6715 |
{ |
6744 |
try { |
6716 |
try { |
6745 |
return astFactory.lookupSymbolInContext( ourScope, finalDuple, contextNode ); |
6717 |
return astFactory.lookupSymbolInContext(ourScope, finalDuple, contextNode); |
6746 |
} catch (ASTNotImplementedException e) { |
6718 |
} catch (ASTNotImplementedException e) { |
6747 |
return null; |
6719 |
return null; |
6748 |
} |
6720 |
} |
Lines 6754-6778
Link Here
|
6754 |
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setGreaterNameContext(org.eclipse.cdt.core.parser.ITokenDuple) |
6726 |
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setGreaterNameContext(org.eclipse.cdt.core.parser.ITokenDuple) |
6755 |
*/ |
6727 |
*/ |
6756 |
protected void setGreaterNameContext(ITokenDuple tokenDuple) { |
6728 |
protected void setGreaterNameContext(ITokenDuple tokenDuple) { |
6757 |
if( mode != ParserMode.SELECTION_PARSE ) return; |
6729 |
if (mode != ParserMode.SELECTION_PARSE) return; |
6758 |
if( pastPointOfSelection ) return; |
6730 |
if (pastPointOfSelection) return; |
6759 |
if( greaterContextDuple == null && lastTokenOfDuple != null && firstTokenOfDuple != null && CharArrayUtils.equals(tokenDuple.getFilename(), parserStartFilename)) |
6731 |
if (greaterContextDuple == null && lastTokenOfDuple != null && firstTokenOfDuple != null && CharArrayUtils.equals(tokenDuple.getFilename(), parserStartFilename)) |
6760 |
{ |
6732 |
{ |
6761 |
if( tokenDuple.getStartOffset() > lastTokenOfDuple.getEndOffset() ) |
6733 |
if (tokenDuple.getStartOffset() > lastTokenOfDuple.getEndOffset()) |
6762 |
{ |
6734 |
{ |
6763 |
pastPointOfSelection = true; |
6735 |
pastPointOfSelection = true; |
6764 |
return; |
6736 |
return; |
6765 |
} |
6737 |
} |
6766 |
int tokensFound = 0; |
6738 |
int tokensFound = 0; |
6767 |
|
6739 |
|
6768 |
for( IToken token = tokenDuple.getFirstToken(); token != null; token = token.getNext() ) |
6740 |
for (IToken token = tokenDuple.getFirstToken(); token != null; token = token.getNext()) |
6769 |
{ |
6741 |
{ |
6770 |
if( token == firstTokenOfDuple ) ++tokensFound; |
6742 |
if (token == firstTokenOfDuple) ++tokensFound; |
6771 |
if( token == lastTokenOfDuple ) ++tokensFound; |
6743 |
if (token == lastTokenOfDuple) ++tokensFound; |
6772 |
if( token == tokenDuple.getLastToken() ) |
6744 |
if (token == tokenDuple.getLastToken()) |
6773 |
break; |
6745 |
break; |
6774 |
} |
6746 |
} |
6775 |
if( tokensFound == 2 ) |
6747 |
if (tokensFound == 2) |
6776 |
{ |
6748 |
{ |
6777 |
greaterContextDuple = tokenDuple; |
6749 |
greaterContextDuple = tokenDuple; |
6778 |
pastPointOfSelection = true; |
6750 |
pastPointOfSelection = true; |
Lines 6787-6808
Link Here
|
6787 |
*/ |
6759 |
*/ |
6788 |
protected void endExpression(IASTExpression expression) |
6760 |
protected void endExpression(IASTExpression expression) |
6789 |
throws EndOfFileException { |
6761 |
throws EndOfFileException { |
6790 |
if( mode != ParserMode.SELECTION_PARSE || ! tokenDupleCompleted() ) |
6762 |
if (mode != ParserMode.SELECTION_PARSE || !tokenDupleCompleted()) { |
6791 |
cleanupLastToken(); |
6763 |
cleanupLastToken(); |
6792 |
else |
6764 |
} else { |
6793 |
{ |
|
|
6794 |
contextNode = expression; |
6765 |
contextNode = expression; |
6795 |
throw new EndOfFileException(); |
6766 |
throw new EndOfFileException(); |
6796 |
} |
6767 |
} |
6797 |
|
|
|
6798 |
} |
6768 |
} |
6799 |
|
|
|
6800 |
|
6769 |
|
6801 |
public static class SelectionParseResult implements ISelectionParseResult |
6770 |
public static class SelectionParseResult implements ISelectionParseResult { |
6802 |
{ |
6771 |
public SelectionParseResult(IASTOffsetableNamedElement node, String fileName) { |
6803 |
|
|
|
6804 |
public SelectionParseResult( IASTOffsetableNamedElement node, String fileName ) |
6805 |
{ |
6806 |
this.node = node; |
6772 |
this.node = node; |
6807 |
this.fileName = fileName; |
6773 |
this.fileName = fileName; |
6808 |
} |
6774 |
} |
Lines 6823-6838
Link Here
|
6823 |
public String getFilename() { |
6789 |
public String getFilename() { |
6824 |
return fileName; |
6790 |
return fileName; |
6825 |
} |
6791 |
} |
6826 |
|
|
|
6827 |
} |
6792 |
} |
|
|
6793 |
|
6828 |
/* (non-Javadoc) |
6794 |
/* (non-Javadoc) |
6829 |
* @see org.eclipse.cdt.internal.core.parser.Parser#endEnumerator(org.eclipse.cdt.core.parser.ast.IASTEnumerator) |
6795 |
* @see org.eclipse.cdt.internal.core.parser.Parser#endEnumerator(org.eclipse.cdt.core.parser.ast.IASTEnumerator) |
6830 |
*/ |
6796 |
*/ |
6831 |
protected void endEnumerator(IASTEnumerator enumerator) throws EndOfFileException { |
6797 |
protected void endEnumerator(IASTEnumerator enumerator) throws EndOfFileException { |
6832 |
if( mode != ParserMode.SELECTION_PARSE || ! tokenDupleCompleted() ) |
6798 |
if (mode != ParserMode.SELECTION_PARSE || !tokenDupleCompleted()) { |
6833 |
cleanupLastToken(); |
6799 |
cleanupLastToken(); |
6834 |
else |
6800 |
} else { |
6835 |
{ |
|
|
6836 |
contextNode = enumerator; |
6801 |
contextNode = enumerator; |
6837 |
throw new EndOfFileException(); |
6802 |
throw new EndOfFileException(); |
6838 |
} |
6803 |
} |
Lines 6842-6861
Link Here
|
6842 |
*/ |
6807 |
*/ |
6843 |
protected void handleClassSpecifier(IASTClassSpecifier classSpecifier) |
6808 |
protected void handleClassSpecifier(IASTClassSpecifier classSpecifier) |
6844 |
throws EndOfFileException { |
6809 |
throws EndOfFileException { |
6845 |
if( mode != ParserMode.SELECTION_PARSE || ! tokenDupleCompleted() ) |
6810 |
if (mode != ParserMode.SELECTION_PARSE || !tokenDupleCompleted()) { |
6846 |
cleanupLastToken(); |
6811 |
cleanupLastToken(); |
6847 |
else |
6812 |
} else { |
6848 |
{ |
|
|
6849 |
contextNode = classSpecifier; |
6813 |
contextNode = classSpecifier; |
6850 |
throw new EndOfFileException(); |
6814 |
throw new EndOfFileException(); |
6851 |
} |
6815 |
} |
6852 |
} |
6816 |
} |
6853 |
|
6817 |
|
6854 |
protected void handleEnumeration(IASTEnumerationSpecifier enumeration) throws EndOfFileException { |
6818 |
protected void handleEnumeration(IASTEnumerationSpecifier enumeration) throws EndOfFileException { |
6855 |
if( mode != ParserMode.SELECTION_PARSE || ! tokenDupleCompleted() ) |
6819 |
if (mode != ParserMode.SELECTION_PARSE || !tokenDupleCompleted()) { |
6856 |
cleanupLastToken(); |
6820 |
cleanupLastToken(); |
6857 |
else |
6821 |
} else { |
6858 |
{ |
|
|
6859 |
contextNode = enumeration; |
6822 |
contextNode = enumeration; |
6860 |
throw new EndOfFileException(); |
6823 |
throw new EndOfFileException(); |
6861 |
} |
6824 |
} |
Lines 6867-6882
Link Here
|
6867 |
* @return |
6830 |
* @return |
6868 |
*/ |
6831 |
*/ |
6869 |
private Set reconcileKeywords(Set keywords, String prefix) { |
6832 |
private Set reconcileKeywords(Set keywords, String prefix) { |
6870 |
if( keywords == null ) return null; |
6833 |
if (keywords == null) return null; |
6871 |
if( prefix.equals( "")) return keywords; //$NON-NLS-1$ |
6834 |
if (prefix.equals("")) return keywords; //$NON-NLS-1$ |
6872 |
Set resultSet = new TreeSet(); |
6835 |
Set resultSet = new TreeSet(); |
6873 |
Iterator i = keywords.iterator(); |
6836 |
Iterator i = keywords.iterator(); |
6874 |
while( i.hasNext() ) |
6837 |
while(i.hasNext()) |
6875 |
{ |
6838 |
{ |
6876 |
String value = (String) i.next(); |
6839 |
String value = (String) i.next(); |
6877 |
if( value.startsWith( prefix ) ) |
6840 |
if (value.startsWith(prefix)) |
6878 |
resultSet.add( value ); |
6841 |
resultSet.add(value); |
6879 |
else if( value.compareTo( prefix ) > 0 ) |
6842 |
else if (value.compareTo(prefix) > 0) |
6880 |
break; |
6843 |
break; |
6881 |
} |
6844 |
} |
6882 |
return resultSet; |
6845 |
return resultSet; |
Lines 6894-6912
Link Here
|
6894 |
* @see org.eclipse.cdt.internal.core.parser.Parser#handleOffsetLimitException() |
6857 |
* @see org.eclipse.cdt.internal.core.parser.Parser#handleOffsetLimitException() |
6895 |
*/ |
6858 |
*/ |
6896 |
protected void handleOffsetLimitException(OffsetLimitReachedException exception) throws EndOfFileException { |
6859 |
protected void handleOffsetLimitException(OffsetLimitReachedException exception) throws EndOfFileException { |
6897 |
if( mode != ParserMode.COMPLETION_PARSE ) |
6860 |
if (mode != ParserMode.COMPLETION_PARSE) |
6898 |
throw new EndOfFileException(); |
6861 |
throw new EndOfFileException(); |
6899 |
|
6862 |
|
6900 |
if( exception.getCompletionNode() == null ) |
6863 |
if (exception.getCompletionNode() == null) { |
6901 |
{ |
6864 |
setCompletionToken(exception.getFinalToken()); |
6902 |
setCompletionToken( exception.getFinalToken() ); |
6865 |
if ((finalToken!= null)&& (!finalToken.canBeAPrefix())) |
6903 |
if( (finalToken!= null )&& (!finalToken.canBeAPrefix() )) |
|
|
6904 |
setCompletionToken(null); |
6866 |
setCompletionToken(null); |
6905 |
} |
6867 |
} else { |
6906 |
else |
|
|
6907 |
{ |
6908 |
ASTCompletionNode node = (ASTCompletionNode) exception.getCompletionNode(); |
6868 |
ASTCompletionNode node = (ASTCompletionNode) exception.getCompletionNode(); |
6909 |
setCompletionValues( node.getCompletionKind(), node.getKeywordSet(), node.getCompletionPrefix() ); |
6869 |
setCompletionValues(node.getCompletionKind(), node.getKeywordSet(), node.getCompletionPrefix()); |
6910 |
} |
6870 |
} |
6911 |
|
6871 |
|
6912 |
throw exception; |
6872 |
throw exception; |
Lines 6916-6926
Link Here
|
6916 |
* @see org.eclipse.cdt.internal.core.parser.Parser#getCompletionKindForDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope) |
6876 |
* @see org.eclipse.cdt.internal.core.parser.Parser#getCompletionKindForDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope) |
6917 |
*/ |
6877 |
*/ |
6918 |
protected CompletionKind getCompletionKindForDeclaration(IASTScope scope, CompletionKind overide) { |
6878 |
protected CompletionKind getCompletionKindForDeclaration(IASTScope scope, CompletionKind overide) { |
6919 |
if( mode != ParserMode.COMPLETION_PARSE ) return null; |
6879 |
if (mode != ParserMode.COMPLETION_PARSE) return null; |
6920 |
IASTCompletionNode.CompletionKind kind = null; |
6880 |
IASTCompletionNode.CompletionKind kind = null; |
6921 |
if( overide != null ) |
6881 |
if (overide != null) |
6922 |
kind = overide; |
6882 |
kind = overide; |
6923 |
else if( scope instanceof IASTClassSpecifier ) |
6883 |
else if (scope instanceof IASTClassSpecifier) |
6924 |
kind = CompletionKind.FIELD_TYPE; |
6884 |
kind = CompletionKind.FIELD_TYPE; |
6925 |
else if (scope instanceof IASTCodeScope) |
6885 |
else if (scope instanceof IASTCodeScope) |
6926 |
kind = CompletionKind.SINGLE_NAME_REFERENCE; |
6886 |
kind = CompletionKind.SINGLE_NAME_REFERENCE; |
Lines 6929-6938
Link Here
|
6929 |
return kind; |
6889 |
return kind; |
6930 |
} |
6890 |
} |
6931 |
|
6891 |
|
6932 |
|
6892 |
protected IToken getCompletionToken() { |
6933 |
protected IToken getCompletionToken() |
6893 |
if (mode != ParserMode.COMPLETION_PARSE) |
6934 |
{ |
|
|
6935 |
if( mode != ParserMode.COMPLETION_PARSE ) |
6936 |
return null; |
6894 |
return null; |
6937 |
return finalToken; |
6895 |
return finalToken; |
6938 |
} |
6896 |
} |
Lines 6940-6957
Link Here
|
6940 |
/* (non-Javadoc) |
6898 |
/* (non-Javadoc) |
6941 |
* @see org.eclipse.cdt.core.parser.ast.IASTReferenceStore#processReferences() |
6899 |
* @see org.eclipse.cdt.core.parser.ast.IASTReferenceStore#processReferences() |
6942 |
*/ |
6900 |
*/ |
6943 |
public static void processReferences(List references, ISourceElementRequestor requestor ) |
6901 |
public static void processReferences(List references, ISourceElementRequestor requestor) { |
6944 |
{ |
6902 |
if (references == null || references.isEmpty()) |
6945 |
if( references == null || references.isEmpty() ) |
|
|
6946 |
return; |
6903 |
return; |
6947 |
|
6904 |
|
6948 |
for( int i = 0; i < references.size(); ++i ) |
6905 |
for (int i = 0; i < references.size(); ++i) |
6949 |
{ |
6906 |
{ |
6950 |
IASTReference reference = ((IASTReference)references.get(i)); |
6907 |
IASTReference reference = ((IASTReference)references.get(i)); |
6951 |
reference.acceptElement(requestor ); |
6908 |
reference.acceptElement(requestor); |
6952 |
} |
6909 |
} |
6953 |
|
6910 |
|
6954 |
references.clear(); |
6911 |
references.clear(); |
6955 |
} |
6912 |
} |
6956 |
|
|
|
6957 |
} |
6913 |
} |