Skip to content

Commit 1b452bb

Browse files
committed
refact: improve null-analysis
This commit improves null-analysis via External Eclipse null Annotations (EEA) and enables null-analysis for CLI builds
1 parent 2a97d84 commit 1b452bb

133 files changed

Lines changed: 661 additions & 561 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

org.eclipse.tm4e.core/.settings/org.eclipse.jdt.core.prefs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
eclipse.preferences.version=1
2-
org.eclipse.jdt.core.builder.annotationPath.allLocations=disabled
2+
org.eclipse.jdt.core.builder.annotationPath.allLocations=enabled
33
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=enabled
44
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
55
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
66
org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
77
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
88
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
9+
org.eclipse.jdt.core.compiler.annotation.notowning=org.eclipse.jdt.annotation.NotOwning
910
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
1011
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
1112
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
13+
org.eclipse.jdt.core.compiler.annotation.owning=org.eclipse.jdt.annotation.Owning
14+
org.eclipse.jdt.core.compiler.annotation.resourceanalysis=disabled
1215
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
1316
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
1417
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
@@ -42,8 +45,10 @@ org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
4245
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
4346
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
4447
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
48+
org.eclipse.jdt.core.compiler.problem.incompatibleOwningContract=warning
4549
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
4650
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
51+
org.eclipse.jdt.core.compiler.problem.insufficientResourceAnalysis=warning
4752
org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
4853
org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
4954
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled

org.eclipse.tm4e.core/build.properties

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,5 @@ bin.includes = META-INF/,\
55
plugin.properties,\
66
about.html
77

8-
# https://codeiseasy.wordpress.com/2013/03/08/tycho-and-jdt-null-analysis/
98
# JDT Null Analysis for Eclipse
109
additional.bundles = org.eclipse.jdt.annotation
11-
# JDT Null Analysis types for Tycho
12-
jars.extra.classpath = platform:/plugin/org.eclipse.jdt.annotation

org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/TMException.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
*/
1212
package org.eclipse.tm4e.core;
1313

14+
import org.eclipse.jdt.annotation.Nullable;
15+
1416
/**
1517
* TextMate exception.
1618
*
@@ -19,11 +21,11 @@ public class TMException extends RuntimeException {
1921

2022
private static final long serialVersionUID = 1L;
2123

22-
public TMException(final String message) {
24+
public TMException(final @Nullable String message) {
2325
super(message);
2426
}
2527

26-
public TMException(final String message, final Throwable cause) {
28+
public TMException(final @Nullable String message, final @Nullable Throwable cause) {
2729
super(message, cause);
2830
}
2931
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
@NonNullByDefault
1+
@NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
22
package org.eclipse.tm4e.core.grammar;
33

4+
import static org.eclipse.jdt.annotation.DefaultLocation.*;
5+
46
import org.eclipse.jdt.annotation.NonNullByDefault;

org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/grammar/AttributedScopeStack.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.util.List;
1919
import java.util.Objects;
2020

21-
import org.eclipse.jdt.annotation.NonNullByDefault;
2221
import org.eclipse.jdt.annotation.Nullable;
2322
import org.eclipse.tm4e.core.internal.grammar.tokenattrs.EncodedTokenAttributes;
2423
import org.eclipse.tm4e.core.internal.theme.FontStyle;
@@ -32,7 +31,6 @@
3231
*/
3332
final class AttributedScopeStack {
3433

35-
@NonNullByDefault({}) // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/233
3634
record Frame(int encodedTokenAttributes, List<String> scopeNames) {
3735
}
3836

org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/grammar/LineTokenizer.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
import java.util.Collections;
2828
import java.util.List;
2929

30-
import org.eclipse.jdt.annotation.NonNull;
31-
import org.eclipse.jdt.annotation.NonNullByDefault;
3230
import org.eclipse.jdt.annotation.Nullable;
3331
import org.eclipse.tm4e.core.internal.oniguruma.OnigCaptureIndex;
3432
import org.eclipse.tm4e.core.internal.oniguruma.OnigScannerMatch;
@@ -72,9 +70,8 @@ private static final class MatchInjectionsResult extends MatchResult {
7270
}
7371
}
7472

75-
@NonNullByDefault({})
7673
private record WhileCheckResult(
77-
@NonNull StateStack stack,
74+
StateStack stack,
7875
int linePos,
7976
int anchorPosition,
8077
boolean isFirstLine) {

org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/grammar/StateStack.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.util.List;
2424
import java.util.Objects;
2525

26-
import org.eclipse.jdt.annotation.NonNullByDefault;
2726
import org.eclipse.jdt.annotation.Nullable;
2827
import org.eclipse.tm4e.core.grammar.IStateStack;
2928
import org.eclipse.tm4e.core.internal.rule.IRuleRegistry;
@@ -39,7 +38,6 @@
3938
*/
4039
public final class StateStack implements IStateStack {
4140

42-
@NonNullByDefault({}) // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/233
4341
record Frame(
4442
RuleId ruleId,
4543
@Nullable Integer enterPos,

org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/grammar/dependencies/package-info.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
* "https://github.com/microsoft/vscode-textmate/blob/main/src/grammar/grammarDependencies.ts">
44
* github.com/microsoft/vscode-textmate/blob/main/src/grammar/grammarDependencies.ts</a>
55
*/
6-
@NonNullByDefault
6+
@NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
77
package org.eclipse.tm4e.core.internal.grammar.dependencies;
88

9+
import static org.eclipse.jdt.annotation.DefaultLocation.*;
10+
911
import org.eclipse.jdt.annotation.NonNullByDefault;

org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/grammar/package-info.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
* "https://github.com/microsoft/vscode-textmate/blob/main/src/grammar/grammar.ts">
44
* github.com/microsoft/vscode-textmate/blob/main/src/grammar/grammar.ts</a>
55
*/
6-
@NonNullByDefault
6+
@NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
77
package org.eclipse.tm4e.core.internal.grammar;
88

9+
import static org.eclipse.jdt.annotation.DefaultLocation.*;
10+
911
import org.eclipse.jdt.annotation.NonNullByDefault;

org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/grammar/raw/IRawCaptures.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,21 @@
1616
*/
1717
package org.eclipse.tm4e.core.internal.grammar.raw;
1818

19+
import java.util.function.BiConsumer;
20+
21+
import org.eclipse.jdt.annotation.Nullable;
22+
1923
/**
2024
* @see <a href=
2125
* "https://github.com/microsoft/vscode-textmate/blob/09effd8b7429b71010e0fa34ea2e16e622692946/src/rawGrammar.ts#L62">
2226
* github.com/microsoft/vscode-textmate/blob/main/src/rawGrammar.ts</a>
2327
*/
2428
public interface IRawCaptures {
2529

30+
@Nullable
2631
IRawRule getCapture(String captureId);
2732

2833
Iterable<String> getCaptureIds();
34+
35+
void forEachCapture(BiConsumer<String, IRawRule> action);
2936
}

0 commit comments

Comments
 (0)