List of usage examples for javax.lang.model.element ElementKind LOCAL_VARIABLE
ElementKind LOCAL_VARIABLE
To view the source code for javax.lang.model.element ElementKind LOCAL_VARIABLE.
Click Source Link
From source file:cop.raml.processor.RestProcessorTest.java
@Test(groups = { "context", "getClassLevelPath" })
public void shouldReturnUrlFromJavadocWhenNoClassAnnotation() throws Exception {
TypeElementMock typeElement = new TypeElementMock("aaa", ElementKind.LOCAL_VARIABLE)
.setDocComment("{@url /project}");
assertThat(getClassLevelPath(new RestImplMock(), typeElement)).isEqualTo("/project");
}
From source file:cop.raml.processor.RestProcessorTest.java
@Test(groups = { "context", "getClassLevelPath" })
public void shouldReturnNullWhenUrlLinkedToVariable() throws Exception {
TypeElementMock typeElement = new TypeElementMock("aaa", ElementKind.LOCAL_VARIABLE)
.setDocComment("{@url {@link Project}}");
assertThat(getClassLevelPath(new RestImplMock(), typeElement)).isNull();
}
From source file:cop.raml.processor.RestProcessorTest.java
@Test(groups = { "context", "getClassLevelPath" })
public void shouldReturnLinkedValueWhenUrlLinkToStaticVariable() throws Exception {
TypeElementMock typeElement = MockUtils.createElement(MockUtils.Count.class);
typeElement.getEnclosedElements().stream()
.filter(element -> MockUtils.Count.ONE.name().equals(element.getSimpleName().toString()))
.map(element -> (VariableElementMock) element)
.forEach(element -> element.setConstantValue("/project"));
((ImportScannerMock) ThreadLocalContext.getImportScanner()).addElement("MockUtils.Count", typeElement);
typeElement = new TypeElementMock("aaa", ElementKind.LOCAL_VARIABLE)
.setDocComment("{@url {@link MockUtils.Count#ONE}}");
assertThat(getClassLevelPath(new RestImplMock(), typeElement)).isEqualTo("/project");
}
From source file:cop.raml.processor.RestProcessorTest.java
@Test(groups = { "context", "getClassLevelPath" })
public void shouldReturnNullWhenLinkedParameterNotFound() throws Exception {
TypeElementMock typeElement = new TypeElementMock("aaa", ElementKind.LOCAL_VARIABLE)
.setDocComment("{@url {@link MockUtils.Count#ONE}}");
((ImportScannerMock) ThreadLocalContext.getImportScanner()).addElement("MockUtils.Count",
MockUtils.createElement(int.class));
assertThat(getClassLevelPath(new RestImplMock(), typeElement)).isNull();
}
From source file:cop.raml.processor.RestProcessorTest.java
@Test(groups = { "context", "readClassLevelDoc" })
public void shouldIgnoreWhenRestApiIsDone() throws Exception {
TypeElementMock classElement = new TypeElementMock("aaa", ElementKind.LOCAL_VARIABLE)
.setDocComment("{@name bbb}");
setRestImpl(processor, new RestImplMock().setRequestPath("/project"));
RestApi api = new RestApi();
Resource resource = api.createResource("/project");
resource.setDisplayName("aaa");
readClassLevelDoc(processor, api, classElement);
assertThat(resource.getDisplayName()).isEqualTo("bbb");
assertThat(resource.isDone()).isTrue();
classElement.setDocComment("{@name ccc}");
readClassLevelDoc(processor, api, classElement);
assertThat(resource.getDisplayName()).isEqualTo("bbb");
assertThat(resource.isDone()).isTrue();
}
From source file:org.jsweet.transpiler.util.Util.java
/** * Fills the given map with all the variables beeing accessed within the * given code tree.//from w ww. j a v a2s . c o m */ public static void fillAllVariableAccesses(final Map<String, VarSymbol> vars, final JCTree tree) { new TreeScanner() { @Override public void visitIdent(JCIdent ident) { if (ident.sym.getKind() == ElementKind.LOCAL_VARIABLE) { putVar(vars, (VarSymbol) ident.sym); } } @Override public void visitLambda(JCLambda lambda) { if (lambda == tree) { super.visitLambda(lambda); } } }.scan(tree); }