-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
NameLogicDisambiguationTest.java
36 lines (28 loc) · 1.54 KB
/
NameLogicDisambiguationTest.java
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
package com.github.javaparser.symbolsolver.resolution.naming;
import com.github.javaparser.*;
import com.github.javaparser.ast.Node;
import com.github.javaparser.symbolsolver.model.resolution.TypeSolver;
import com.github.javaparser.symbolsolver.resolution.AbstractResolutionTest;
import com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver;
import org.junit.Test;
import java.util.List;
import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class NameLogicDisambiguationTest extends AbstractNameLogicTest {
private void assertNameInCodeIsDisambiguited(String code, String name,
NameCategory syntacticClassification,
NameCategory nameCategory,
ParseStart parseStart, TypeSolver typeSolver) {
Node nameNode = getNameInCodeTollerant(code, name, parseStart);
assertEquals(syntacticClassification, NameLogic.syntacticClassificationAccordingToContext(nameNode));
assertEquals(nameCategory, NameLogic.classifyReference(nameNode, typeSolver));
}
@Test
public void ambiguousNameToLocalVar() {
assertNameInCodeIsDisambiguited("class A { void foo() {\n" +
"SomeClass a; a.aField;" + "\n" +
"} }", "a", NameCategory.AMBIGUOUS_NAME, NameCategory.EXPRESSION_NAME, ParseStart.COMPILATION_UNIT,
new ReflectionTypeSolver());
}
}