Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix NPE in isClassQualifiedNameMatching #122

Merged
merged 2 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<java-execenv>JavaSE-21</java-execenv>
<spotbugs-version>4.8.6.6</spotbugs-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<license.licenseName>epl_v1</license.licenseName>
</properties>
<modules>
<module>sandbox_target</module>
Expand Down Expand Up @@ -60,7 +61,7 @@
<repository>
<id>eclipse</id>
<layout>p2</layout>
<url>https://download.eclipse.org/releases/2024-09</url>
<url>https://download.eclipse.org/releases/2024-12</url>
</repository>
<repository>
<id>babel</id>
Expand All @@ -70,7 +71,7 @@
<repository>
<id>orbit</id>
<layout>p2</layout>
<url>https://download.eclipse.org/tools/orbit/simrel/orbit-aggregation/2024-09/</url>
<url>https://download.eclipse.org/tools/orbit/simrel/orbit-aggregation/2024-12/</url>
</repository>
<!--<repository>
<id>swtbot</id>
Expand All @@ -80,6 +81,31 @@
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>2.4.0</version>
<configuration>
<licenseName>gpl_v3</licenseName>
<organizationName>hammer</organizationName>
<verbose>true</verbose>
<inceptionYear>2024</inceptionYear>
<excludes>
<exclude>**/*.gif</exclude>
<exclude>**/*.txt</exclude>
<exclude>**/*.ftl</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>first</id>
<goals>
<goal>update-file-header</goal>
</goals>
<phase>process-sources</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.util.function.BiConsumer;
import java.util.function.BiPredicate;

import org.eclipse.jdt.core.dom.*;

Check warning on line 20 in sandbox_common/src/org/sandbox/jdt/internal/common/LambdaASTVisitor.java

View workflow job for this annotation

GitHub Actions / pmd-code-scan

Unused import 'org.eclipse.jdt.core.dom.*'

Reports import statements that can be removed. They are either unused, duplicated, or the members they import are already implicitly in scope, because they're in java.lang, or the current package. If some imports cannot be resolved, for instance because you run PMD with an incomplete auxiliary classpath, some imports may be conservatively marked as used even if they're not to avoid false positives. UnnecessaryImport (Priority: 4, Ruleset: Code Style) https://docs.pmd-code.org/pmd-doc-7.8.0/pmd_rules_java_codestyle.html#unnecessaryimport

import org.eclipse.jdt.internal.corext.dom.ASTNodes;

Expand Down Expand Up @@ -52,9 +52,9 @@

@Override
public boolean visit(AnnotationTypeDeclaration node) {
if (this.helperVisitor.predicatemap.containsKey(VisitorEnum.AnnotationTypeDeclaration)) {
return ((BiPredicate<AnnotationTypeDeclaration, E>) (this.helperVisitor.predicatemap
.get(VisitorEnum.AnnotationTypeDeclaration))).test(node, this.helperVisitor.dataholder);

Check warning on line 57 in sandbox_common/src/org/sandbox/jdt/internal/common/LambdaASTVisitor.java

View workflow job for this annotation

GitHub Actions / pmd-code-scan

Useless parentheses.

Parenthesized expressions are used to override the default operator precedence rules. Parentheses whose removal would not change the relative nesting of operators are unnecessary, because they don't change the semantics of the enclosing expression. Some parentheses that strictly speaking are unnecessary, may still be considered useful for readability. This rule allows to ignore violations on two kinds of unnecessary parentheses: - "Clarifying" parentheses, which separate operators of difference precedence. While unnecessary, they make precedence rules explicit, which may be useful for rarely used operators. For example: ```java (a + b) & c // is equivalent to `a + b & c`, but probably clearer ``` Unset the property `ignoreClarifying` to report them. - "Balancing" parentheses, which are unnecessary but visually balance out another pair of parentheses around an equality operator. For example, those two expressions are equivalent: ```java (a == null) != (b == null) a == null != (b == null) ``` The parentheses on the right are required, and the parentheses on the left are just more visually pleasing. Unset the property `ignoreBalancing` to report them. UselessParentheses (Priority: 4, Ruleset: Code Style) https://docs.pmd-code.org/pmd-doc-7.8.0/pmd_rules_java_codestyle.html#uselessparentheses
}

Check warning on line 58 in sandbox_common/src/org/sandbox/jdt/internal/common/LambdaASTVisitor.java

View workflow job for this annotation

GitHub Actions / pmd-code-scan

This if statement can be replaced by `return !{condition} || {thenBranch};`

Avoid unnecessary if-then-else statements when returning a boolean. The result of the conditional test can be returned instead. SimplifyBooleanReturns (Priority: 3, Ruleset: Design) https://docs.pmd-code.org/pmd-doc-7.8.0/pmd_rules_java_design.html#simplifybooleanreturns
return true;
}
Expand Down Expand Up @@ -624,13 +624,15 @@
Expression expression = methodInvocation.getExpression();
if (expression != null) {
ITypeBinding typeBinding = expression.resolveTypeBinding();
if (typeBinding != null && !typeBinding.isRecovered()) {
return qualifiedName.equals(typeBinding.getQualifiedName());
}
if (expression instanceof SimpleName) {
String startswith=typeBinding.toString().substring(9);
startswith=startswith.substring(0, startswith.length()-1);
return qualifiedName.endsWith(startswith);
if (typeBinding != null) {
if (!typeBinding.isRecovered()) {
return qualifiedName.equals(typeBinding.getQualifiedName());
}
if (expression instanceof SimpleName) {
String startswith=typeBinding.toString().substring(9);
startswith=startswith.substring(0, startswith.length()-1);
return qualifiedName.endsWith(startswith);
}
}
} else {
IMethodBinding methodBinding = methodInvocation.resolveMethodBinding();
Expand Down
4 changes: 2 additions & 2 deletions sandbox_target/eclipse.target
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<locations>
<!--
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="slicer" includeSource="true" type="InstallableUnit">
<repository location="https://download.eclipse.org/releases/2024-09/"/>
<repository location="https://download.eclipse.org/releases/2024-12/"/>
<repository location="https://download.eclipse.org/tools/orbit/simrel/maven-jetty/release/latest"/>
<repository location="https://download.eclipse.org/cbi/updates/license"/>
<unit id="org.eclipse.jdt.feature.group" version="0.0.0"/>
Expand Down Expand Up @@ -245,7 +245,7 @@
<unit id="org.hamcrest.library.source" version="0.0.0"/>
<unit id="org.opentest4j" version="0.0.0"/>
<unit id="org.junit" version="0.0.0"/>
<repository location="https://download.eclipse.org/eclipse/updates/4.34-I-builds"/>
<repository location="https://download.eclipse.org/eclipse/updates/4.35-I-builds"/>
<repository location="https://download.eclipse.org/cbi/updates/license"/>
<repository location="https://download.eclipse.org/tools/orbit/simrel/orbit-aggregation/nightly/latest"/>
<repository location="https://download.eclipse.org/tools/orbit/simrel/maven-jetty/release/latest"/>
Expand Down
Loading