-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathJavaParserBase.cs
More file actions
61 lines (56 loc) · 1.61 KB
/
Copy pathJavaParserBase.cs
File metadata and controls
61 lines (56 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using Antlr4.Runtime;
using System.IO;
using System.Linq;
public abstract class JavaParserBase : Parser {
private readonly ITokenStream _input;
protected JavaParserBase(ITokenStream input, TextWriter output, TextWriter errorOutput)
: base(input, output, errorOutput) {
_input = input;
}
public bool DoLastRecordComponent()
{
var ctx = this.Context;
var tctx = ctx as JavaParser.RecordComponentListContext;
var rcs = tctx.recordComponent();
if (! rcs.Any()) return true;
var count = rcs.Count();
for (int c = 0; c < count; ++c)
{
var rc = rcs[c];
if (rc.ELLIPSIS() != null && c+1 < count)
return false;
}
return true;
}
public bool IsNotIdentifierAssign()
{
var la = this.TokenStream.LA(1);
// If not identifier, return true because it can't be
// "identifier = ..."
switch (la) {
case JavaParser.IDENTIFIER:
case JavaParser.MODULE:
case JavaParser.OPEN:
case JavaParser.REQUIRES:
case JavaParser.EXPORTS:
case JavaParser.OPENS:
case JavaParser.TO:
case JavaParser.USES:
case JavaParser.PROVIDES:
case JavaParser.WHEN:
case JavaParser.WITH:
case JavaParser.TRANSITIVE:
case JavaParser.YIELD:
case JavaParser.SEALED:
case JavaParser.PERMITS:
case JavaParser.RECORD:
case JavaParser.VAR:
break;
default:
return true;
}
var la2 = this.TokenStream.LA(2);
if (la2 != JavaParser.ASSIGN) return true;
return false;
}
}