Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasstamann committed Apr 5, 2024
2 parents 326739c + b051055 commit a999d73
Show file tree
Hide file tree
Showing 25 changed files with 120 additions and 26 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -54,7 +54,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -68,4 +68,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v3
2 changes: 1 addition & 1 deletion annotationwrapper/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.toolisticon.aptk</groupId>
<artifactId>aptk-annotationwrapper-parent</artifactId>
<version>0.23.0</version>
<version>0.24.0</version>
</parent>

<name>aptk-annotationwrapper-api</name>
Expand Down
2 changes: 1 addition & 1 deletion annotationwrapper/integrationtest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>io.toolisticon.aptk</groupId>
<artifactId>aptk-annotationwrapper-parent</artifactId>
<version>0.23.0</version>
<version>0.24.0</version>
</parent>

<name>aptk-annotationwrapper-integrationTest</name>
Expand Down
2 changes: 1 addition & 1 deletion annotationwrapper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>io.toolisticon.aptk</groupId>
<artifactId>aptk-parent</artifactId>
<version>0.23.0</version>
<version>0.24.0</version>
</parent>


Expand Down
2 changes: 1 addition & 1 deletion annotationwrapper/processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>io.toolisticon.aptk</groupId>
<artifactId>aptk-annotationwrapper-parent</artifactId>
<version>0.23.0</version>
<version>0.24.0</version>
</parent>

<name>aptk-annotationwrapper-processor</name>
Expand Down
2 changes: 1 addition & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.toolisticon.aptk</groupId>
<artifactId>aptk-parent</artifactId>
<version>0.23.0</version>
<version>0.24.0</version>
</parent>

<name>aptk-common</name>
Expand Down
2 changes: 1 addition & 1 deletion compilermessages/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.toolisticon.aptk</groupId>
<artifactId>aptk-compilermessages-parent</artifactId>
<version>0.23.0</version>
<version>0.24.0</version>
</parent>

<name>aptk-compilermessages-api</name>
Expand Down
2 changes: 1 addition & 1 deletion compilermessages/integrationtest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>io.toolisticon.aptk</groupId>
<artifactId>aptk-compilermessages-parent</artifactId>
<version>0.23.0</version>
<version>0.24.0</version>
</parent>

<name>aptk-compilermessages-integrationTest</name>
Expand Down
2 changes: 1 addition & 1 deletion compilermessages/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>io.toolisticon.aptk</groupId>
<artifactId>aptk-parent</artifactId>
<version>0.23.0</version>
<version>0.24.0</version>
</parent>


Expand Down
2 changes: 1 addition & 1 deletion compilermessages/processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>io.toolisticon.aptk</groupId>
<artifactId>aptk-compilermessages-parent</artifactId>
<version>0.23.0</version>
<version>0.24.0</version>
</parent>

<name>aptk-compilermessages-processor</name>
Expand Down
2 changes: 1 addition & 1 deletion cute/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.toolisticon.aptk</groupId>
<artifactId>aptk-parent</artifactId>
<version>0.23.0</version>
<version>0.24.0</version>
</parent>

<name>aptk-cute</name>
Expand Down
2 changes: 1 addition & 1 deletion example/example-annotationprocessor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.toolisticon.aptk</groupId>
<artifactId>aptk-example-parent</artifactId>
<version>0.23.0</version>
<version>0.24.0</version>
</parent>

<name>aptk-example-annotationprocessor</name>
Expand Down
2 changes: 1 addition & 1 deletion example/example-annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.toolisticon.aptk</groupId>
<artifactId>aptk-example-parent</artifactId>
<version>0.23.0</version>
<version>0.24.0</version>
</parent>

<name>aptk-example-annotations</name>
Expand Down
2 changes: 1 addition & 1 deletion example/example-usecase/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.toolisticon.aptk</groupId>
<artifactId>aptk-example-parent</artifactId>
<version>0.23.0</version>
<version>0.24.0</version>
</parent>

<name>aptk-example-usecase</name>
Expand Down
2 changes: 1 addition & 1 deletion example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.toolisticon.aptk</groupId>
<artifactId>aptk-parent</artifactId>
<version>0.23.0</version>
<version>0.24.0</version>
</parent>

<name>aptk-example-parent</name>
Expand Down
2 changes: 1 addition & 1 deletion extensions/java9/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.toolisticon.aptk</groupId>
<artifactId>extension-parent</artifactId>
<version>0.23.0</version>
<version>0.24.0</version>
</parent>

<name>aptk-tools-java9</name>
Expand Down
2 changes: 1 addition & 1 deletion extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.toolisticon.aptk</groupId>
<artifactId>aptk-parent</artifactId>
<version>0.23.0</version>
<version>0.24.0</version>
</parent>

<name>extension-parent</name>
Expand Down
13 changes: 13 additions & 0 deletions idea_aptk_codestyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<code_scheme name="Default (3)" version="173">
<option name="AUTODETECT_INDENTS" value="false" />
<JavaCodeStyleSettings>
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
</JavaCodeStyleSettings>
<JetCodeStyleSettings>
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<codeStyleSettings language="kotlin">
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</codeStyleSettings>
</code_scheme>
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>io.toolisticon.aptk</groupId>
<artifactId>aptk-parent</artifactId>
<version>0.23.0</version>
<version>0.24.0</version>
<packaging>pom</packaging>

<name>aptk-parent</name>
Expand Down
2 changes: 1 addition & 1 deletion templating/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.toolisticon.aptk</groupId>
<artifactId>aptk-parent</artifactId>
<version>0.23.0</version>
<version>0.24.0</version>
</parent>

<name>aptk-templating</name>
Expand Down
2 changes: 1 addition & 1 deletion tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.toolisticon.aptk</groupId>
<artifactId>aptk-parent</artifactId>
<version>0.23.0</version>
<version>0.24.0</version>
</parent>

<name>aptk-tools</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ public List<ElementWrapper<Element>> getFlattenedEnclosedElementTree(boolean inc
* @return a list of all elements up to the max depth of the enclosed element tree plus element itself if includeSelf flag is set
*/
public List<ElementWrapper<Element>> getFlattenedEnclosedElementTree(boolean includeSelf, int maxDepth) {
return ElementUtils.AccessEnclosingElements.getFlattenedEnclosingElementsTree(this.unwrap(), includeSelf, maxDepth)
.stream().map(ExecutableElementWrapper::wrap).collect(Collectors.toList());
return ElementUtils.AccessEnclosedElements.flattenEnclosedElementTree(this.unwrap(), includeSelf, maxDepth)
.stream().map(ElementWrapper::wrap).collect(Collectors.toList());
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package io.toolisticon.aptk.tools.wrapper;

import io.toolisticon.aptk.common.ToolingProvider;

import javax.lang.model.element.PackageElement;
import java.util.Optional;

/**
* Wrapper for PackageElement.
Expand Down Expand Up @@ -45,4 +48,16 @@ public static PackageElementWrapper wrap(PackageElement element) {
return new PackageElementWrapper(element);
}

/**
* Gets the PackageElementWrapper by using a fully qualified package name.
* @param fqn the fully qualified name of the package
* @return an Optional containing the PackageElementWrapper or an empty Optional if the package element can't be found
*/
public static Optional<PackageElementWrapper> getByFqn(String fqn) {

PackageElement packageElement = ToolingProvider.getTooling().getElements().getPackageElement(fqn);
return packageElement != null ? Optional.of(PackageElementWrapper.wrap(packageElement)) : Optional.empty();

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.toolisticon.cute.UnitTest;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;

Expand All @@ -25,6 +26,7 @@
import java.lang.annotation.Target;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

/**
Expand Down Expand Up @@ -190,10 +192,11 @@ public void test_getAnnotations() {

CompileTestBuilder.unitTest().<TypeElement>defineTestWithPassedInElement(TestClass.class, (processingEnvironment, element) -> {
ElementWrapper<TypeElement> unit = ElementWrapper.wrap(element);
MatcherAssert.assertThat("Should find annotation", unit.getAnnotations(),Matchers.hasSize(1));
MatcherAssert.assertThat("Should find annotation", unit.getAnnotations(), Matchers.hasSize(1));
}).executeTest();

}

@Test
public void test_getAnnotation_byFqnString() {

Expand Down Expand Up @@ -275,7 +278,6 @@ public void test_getFirstEnclosingElementWithKind() {
MatcherAssert.assertThat(unit.<PackageElementWrapper>getFirstEnclosingElementWithKind(ElementKind.PACKAGE).get().getQualifiedName(), Matchers.is(ElementWrapperTest.class.getPackage().getName()));



}).executeTest();

}
Expand Down Expand Up @@ -943,4 +945,26 @@ public void test_toVariableElementWrapper() {
}


static class FlattenedNestedTestClass {

}
@Test
@Ignore
public void test_filterFlattenedEnclosedElementTree() {
CompileTestBuilder.unitTest().defineTest((processingEnvironment, element) -> {
try {
ToolingProvider.setTooling(processingEnvironment);
PackageElementWrapper packageElementWrapper = PackageElementWrapper.getByFqn(ElementWrapperTest.class.getPackage().getName()).get();
Set<String> types = packageElementWrapper.filterFlattenedEnclosedElementTree().applyFilter(AptkCoreMatchers.IS_TYPE_ELEMENT).getResult().stream().map(e -> e.getQualifiedName().toString()).collect(Collectors.toSet());
MatcherAssert.assertThat("Must find this class", types.contains(ElementWrapperTest.class.getCanonicalName()));
MatcherAssert.assertThat("Must find nested class", types.contains(FlattenedNestedTestClass.class.getCanonicalName()));
}finally {
ToolingProvider.clearTooling();
}
})
.compilationShouldSucceed()
.executeTest();
}


}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package io.toolisticon.aptk.tools.wrapper;

import io.toolisticon.aptk.common.ToolingProvider;
import io.toolisticon.cute.CompileTestBuilder;
import io.toolisticon.cute.PassIn;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.mockito.Mockito;

import javax.lang.model.element.Element;
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;

Expand All @@ -26,6 +28,46 @@ public void test_getQualifiedName() {

}

@Test
public void test_getByFqn() {

CompileTestBuilder.unitTest().<Element>defineTest((processingEnvironment, element) -> {

try {

ToolingProvider.setTooling(processingEnvironment);

String fqn = PackageElementWrapperTest.class.getPackage().getName();
MatcherAssert.assertThat(PackageElementWrapper.getByFqn(fqn).get().getQualifiedName(), Matchers.is(fqn));

} finally {
ToolingProvider.clearTooling();
}

}).executeTest();

}

@Test
public void test_getByFqn_nonExistingPackage() {

CompileTestBuilder.unitTest().<Element>defineTest((processingEnvironment, element) -> {

try {

ToolingProvider.setTooling(processingEnvironment);

String fqn = "xyz.xyz.xyz";
MatcherAssert.assertThat("Package must not be found", !PackageElementWrapper.getByFqn(fqn).isPresent());

} finally {
ToolingProvider.clearTooling();
}

}).executeTest();

}

@Test
public void test_isUnnamed() {
PackageElement packageElement = Mockito.mock(PackageElement.class);
Expand Down

0 comments on commit a999d73

Please sign in to comment.