OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012, the Dart project authors. | 2 * Copyright (c) 2012, the Dart project authors. |
3 * | 3 * |
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
11 * or implied. See the License for the specific language governing permissions a
nd limitations under | 11 * or implied. See the License for the specific language governing permissions a
nd limitations under |
12 * the License. | 12 * the License. |
13 */ | 13 */ |
14 package com.google.dart.tools.core.internal.completion; | 14 package com.google.dart.tools.core.internal.completion; |
15 | 15 |
16 import com.google.dart.compiler.ErrorCode; | |
17 import com.google.dart.compiler.ast.DartBlock; | |
18 import com.google.dart.compiler.ast.DartClass; | |
19 import com.google.dart.compiler.ast.DartField; | |
20 import com.google.dart.compiler.ast.DartFunction; | |
21 import com.google.dart.compiler.ast.DartIdentifier; | |
22 import com.google.dart.compiler.ast.DartIfStatement; | |
23 import com.google.dart.compiler.ast.DartMethodInvocation; | |
24 import com.google.dart.compiler.ast.DartNewExpression; | |
25 import com.google.dart.compiler.ast.DartNode; | |
26 import com.google.dart.compiler.ast.DartParameter; | |
27 import com.google.dart.compiler.ast.DartPropertyAccess; | |
28 import com.google.dart.compiler.ast.DartReturnStatement; | |
29 import com.google.dart.compiler.ast.DartSuperConstructorInvocation; | |
30 import com.google.dart.compiler.ast.DartSyntheticErrorIdentifier; | |
31 import com.google.dart.compiler.ast.DartTypeNode; | |
32 import com.google.dart.compiler.ast.DartTypeParameter; | |
33 import com.google.dart.compiler.ast.DartVariableStatement; | |
34 import com.google.dart.compiler.parser.DartParser; | |
35 import com.google.dart.compiler.parser.DartScanner; | |
36 import com.google.dart.compiler.parser.DartScanner.Location; | |
37 import com.google.dart.compiler.parser.ParserContext; | |
38 import com.google.dart.compiler.parser.Token; | |
39 import com.google.dart.tools.core.internal.completion.ast.BlockCompleter; | |
40 import com.google.dart.tools.core.internal.completion.ast.ClassCompleter; | |
41 import com.google.dart.tools.core.internal.completion.ast.CompletionNode; | |
42 import com.google.dart.tools.core.internal.completion.ast.FieldCompleter; | |
43 import com.google.dart.tools.core.internal.completion.ast.FunctionCompleter; | |
44 import com.google.dart.tools.core.internal.completion.ast.IdentifierCompleter; | |
45 import com.google.dart.tools.core.internal.completion.ast.IfCompleter; | |
46 import com.google.dart.tools.core.internal.completion.ast.MethodInvocationComple
ter; | |
47 import com.google.dart.tools.core.internal.completion.ast.NewExpressionCompleter
; | |
48 import com.google.dart.tools.core.internal.completion.ast.ParameterCompleter; | |
49 import com.google.dart.tools.core.internal.completion.ast.PropertyAccessComplete
r; | |
50 import com.google.dart.tools.core.internal.completion.ast.ReturnCompleter; | |
51 import com.google.dart.tools.core.internal.completion.ast.SuperConstructorInvoca
tionCompleter; | |
52 import com.google.dart.tools.core.internal.completion.ast.TypeCompleter; | |
53 import com.google.dart.tools.core.internal.completion.ast.TypeParameterCompleter
; | |
54 import com.google.dart.tools.core.internal.completion.ast.VariableStatementCompl
eter; | |
55 | |
56 import static com.google.dart.tools.core.internal.completion.Mark.ArrayLiteral; | 16 import static com.google.dart.tools.core.internal.completion.Mark.ArrayLiteral; |
57 import static com.google.dart.tools.core.internal.completion.Mark.BinaryExpressi
on; | 17 import static com.google.dart.tools.core.internal.completion.Mark.BinaryExpressi
on; |
58 import static com.google.dart.tools.core.internal.completion.Mark.Block; | 18 import static com.google.dart.tools.core.internal.completion.Mark.Block; |
59 import static com.google.dart.tools.core.internal.completion.Mark.BreakStatement
; | 19 import static com.google.dart.tools.core.internal.completion.Mark.BreakStatement
; |
60 import static com.google.dart.tools.core.internal.completion.Mark.CatchClause; | 20 import static com.google.dart.tools.core.internal.completion.Mark.CatchClause; |
61 import static com.google.dart.tools.core.internal.completion.Mark.CatchParameter
; | 21 import static com.google.dart.tools.core.internal.completion.Mark.CatchParameter
; |
62 import static com.google.dart.tools.core.internal.completion.Mark.ClassBody; | 22 import static com.google.dart.tools.core.internal.completion.Mark.ClassBody; |
63 import static com.google.dart.tools.core.internal.completion.Mark.ClassMember; | 23 import static com.google.dart.tools.core.internal.completion.Mark.ClassMember; |
64 import static com.google.dart.tools.core.internal.completion.Mark.CompilationUni
t; | 24 import static com.google.dart.tools.core.internal.completion.Mark.CompilationUni
t; |
65 import static com.google.dart.tools.core.internal.completion.Mark.ConditionalExp
ression; | 25 import static com.google.dart.tools.core.internal.completion.Mark.ConditionalExp
ression; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 import static com.google.dart.tools.core.internal.completion.Mark.TypeAnnotation
; | 71 import static com.google.dart.tools.core.internal.completion.Mark.TypeAnnotation
; |
112 import static com.google.dart.tools.core.internal.completion.Mark.TypeArguments; | 72 import static com.google.dart.tools.core.internal.completion.Mark.TypeArguments; |
113 import static com.google.dart.tools.core.internal.completion.Mark.TypeExpression
; | 73 import static com.google.dart.tools.core.internal.completion.Mark.TypeExpression
; |
114 import static com.google.dart.tools.core.internal.completion.Mark.TypeFunctionOr
Variable; | 74 import static com.google.dart.tools.core.internal.completion.Mark.TypeFunctionOr
Variable; |
115 import static com.google.dart.tools.core.internal.completion.Mark.TypeParameter; | 75 import static com.google.dart.tools.core.internal.completion.Mark.TypeParameter; |
116 import static com.google.dart.tools.core.internal.completion.Mark.UnaryExpressio
n; | 76 import static com.google.dart.tools.core.internal.completion.Mark.UnaryExpressio
n; |
117 import static com.google.dart.tools.core.internal.completion.Mark.VarDeclaration
; | 77 import static com.google.dart.tools.core.internal.completion.Mark.VarDeclaration
; |
118 import static com.google.dart.tools.core.internal.completion.Mark.VariableDeclar
ation; | 78 import static com.google.dart.tools.core.internal.completion.Mark.VariableDeclar
ation; |
119 import static com.google.dart.tools.core.internal.completion.Mark.WhileStatement
; | 79 import static com.google.dart.tools.core.internal.completion.Mark.WhileStatement
; |
120 | 80 |
| 81 import com.google.dart.compiler.DartCompilerListener; |
| 82 import com.google.dart.compiler.ErrorCode; |
| 83 import com.google.dart.compiler.Source; |
| 84 import com.google.dart.compiler.ast.DartBlock; |
| 85 import com.google.dart.compiler.ast.DartClass; |
| 86 import com.google.dart.compiler.ast.DartField; |
| 87 import com.google.dart.compiler.ast.DartFunction; |
| 88 import com.google.dart.compiler.ast.DartIdentifier; |
| 89 import com.google.dart.compiler.ast.DartIfStatement; |
| 90 import com.google.dart.compiler.ast.DartMethodInvocation; |
| 91 import com.google.dart.compiler.ast.DartNewExpression; |
| 92 import com.google.dart.compiler.ast.DartNode; |
| 93 import com.google.dart.compiler.ast.DartParameter; |
| 94 import com.google.dart.compiler.ast.DartPropertyAccess; |
| 95 import com.google.dart.compiler.ast.DartReturnStatement; |
| 96 import com.google.dart.compiler.ast.DartSuperConstructorInvocation; |
| 97 import com.google.dart.compiler.ast.DartSyntheticErrorIdentifier; |
| 98 import com.google.dart.compiler.ast.DartTypeNode; |
| 99 import com.google.dart.compiler.ast.DartTypeParameter; |
| 100 import com.google.dart.compiler.ast.DartVariableStatement; |
| 101 import com.google.dart.compiler.metrics.CompilerMetrics; |
| 102 import com.google.dart.compiler.parser.DartParser; |
| 103 import com.google.dart.compiler.parser.DartScanner; |
| 104 import com.google.dart.compiler.parser.DartScanner.Location; |
| 105 import com.google.dart.compiler.parser.Token; |
| 106 import com.google.dart.tools.core.internal.completion.ast.BlockCompleter; |
| 107 import com.google.dart.tools.core.internal.completion.ast.ClassCompleter; |
| 108 import com.google.dart.tools.core.internal.completion.ast.CompletionNode; |
| 109 import com.google.dart.tools.core.internal.completion.ast.FieldCompleter; |
| 110 import com.google.dart.tools.core.internal.completion.ast.FunctionCompleter; |
| 111 import com.google.dart.tools.core.internal.completion.ast.IdentifierCompleter; |
| 112 import com.google.dart.tools.core.internal.completion.ast.IfCompleter; |
| 113 import com.google.dart.tools.core.internal.completion.ast.MethodInvocationComple
ter; |
| 114 import com.google.dart.tools.core.internal.completion.ast.NewExpressionCompleter
; |
| 115 import com.google.dart.tools.core.internal.completion.ast.ParameterCompleter; |
| 116 import com.google.dart.tools.core.internal.completion.ast.PropertyAccessComplete
r; |
| 117 import com.google.dart.tools.core.internal.completion.ast.ReturnCompleter; |
| 118 import com.google.dart.tools.core.internal.completion.ast.SuperConstructorInvoca
tionCompleter; |
| 119 import com.google.dart.tools.core.internal.completion.ast.TypeCompleter; |
| 120 import com.google.dart.tools.core.internal.completion.ast.TypeParameterCompleter
; |
| 121 import com.google.dart.tools.core.internal.completion.ast.VariableStatementCompl
eter; |
| 122 |
121 import java.util.ArrayList; | 123 import java.util.ArrayList; |
122 import java.util.List; | 124 import java.util.List; |
123 import java.util.Set; | 125 import java.util.Set; |
124 import java.util.Stack; | 126 import java.util.Stack; |
125 | 127 |
126 public class CompletionParser extends DartParser { | 128 public class CompletionParser extends DartParser { |
127 private Stack<Mark> stack; | 129 private Stack<Mark> stack; |
128 private int completionPosition; | 130 private int completionPosition; |
129 private Token completionToken; | 131 private Token completionToken; |
130 | 132 |
131 public CompletionParser(ParserContext ctx) { | 133 public CompletionParser(Source source, String sourceCode, Set<String> prefixes
, |
132 super(ctx, false); | 134 DartCompilerListener listener, CompilerMetrics compilerMetrics) { |
| 135 super(source, sourceCode, false, prefixes, listener, compilerMetrics); |
133 stack = new Stack<Mark>(); | 136 stack = new Stack<Mark>(); |
134 } | 137 } |
135 | 138 |
136 public CompletionParser(ParserContext ctx, Set<String> prefixes) { | |
137 super(ctx, false, prefixes); | |
138 stack = new Stack<Mark>(); | |
139 } | |
140 | |
141 public void setCompletionPosition(int completionPosition) { | 139 public void setCompletionPosition(int completionPosition) { |
142 this.completionPosition = completionPosition; | 140 this.completionPosition = completionPosition; |
143 } | 141 } |
144 | 142 |
145 @Override | 143 @Override |
146 protected void beginArrayLiteral() { | 144 protected void beginArrayLiteral() { |
147 super.beginArrayLiteral(); | 145 super.beginArrayLiteral(); |
148 pushMark(ArrayLiteral); | 146 pushMark(ArrayLiteral); |
149 } | 147 } |
150 | 148 |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 } | 674 } |
677 // System.out.println("pop " + stack.peek()); | 675 // System.out.println("pop " + stack.peek()); |
678 return stack.pop(); | 676 return stack.pop(); |
679 } | 677 } |
680 | 678 |
681 private void pushMark(Mark mark) { | 679 private void pushMark(Mark mark) { |
682 // System.out.println("push " + mark); | 680 // System.out.println("push " + mark); |
683 stack.push(mark); | 681 stack.push(mark); |
684 } | 682 } |
685 } | 683 } |
OLD | NEW |