Skip to content

Commit d251392

Browse files
committed
refact: improve null analysis config
1 parent 180fa78 commit d251392

17 files changed

+74
-136
lines changed

plugin/build.properties

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,5 @@ bin.excludes = src/main/java/org/dart4e/localization/Messages.java,\
1010
src/main/resources/images/logo/dart_wizard_banner.afphoto,\
1111
src/main/resources/images/launch/external_terminal.afphoto
1212

13-
# https://codeiseasy.wordpress.com/2013/03/08/tycho-and-jdt-null-analysis/
1413
# JDT Null Analysis for Eclipse
15-
additional.bundles = org.eclipse.jdt.annotation,com.vegardit.no-npe.eea-all
16-
# JDT Null Analysis types for Tycho
17-
jars.extra.classpath = platform:/plugin/org.eclipse.jdt.annotation,platform:/plugin/com.vegardit.no-npe.eea-all
14+
additional.bundles = org.eclipse.jdt.annotation

plugin/pom.xml

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -81,40 +81,7 @@
8181
</execution>
8282
</executions>
8383
</plugin>
84-
85-
<plugin>
86-
<!-- https://tycho.eclipseprojects.io/doc/3.0.0/tycho-compiler-plugin/plugin-info.html -->
87-
<groupId>org.eclipse.tycho</groupId>
88-
<artifactId>tycho-compiler-plugin</artifactId>
89-
<configuration>
90-
<!-- workaround for tycho-compiler-plugin ignoring EEAs loaded via
91-
build.properties: jars.extra.classpath = ...,platform:/plugin/com.vegardit.no-npe.eea-all
92-
-->
93-
<compilerArgs>
94-
<arg>-annotationpath</arg>
95-
<arg>${com.vegardit.no-npe:no-npe-eea-all:jar}</arg>
96-
</compilerArgs>
97-
</configuration>
98-
</plugin>
9984
</plugins>
10085
</build>
10186

102-
<dependencies>
103-
<dependency>
104-
<!-- only required for workaround for tycho-compiler-plugin ignoring EEAs loaded via
105-
build.properties: jars.extra.classpath = ...,platform:/plugin/com.vegardit.no-npe.eea-all
106-
-->
107-
<groupId>com.vegardit.no-npe</groupId>
108-
<artifactId>no-npe-eea-all</artifactId>
109-
<version>1.0.0-SNAPSHOT</version>
110-
<scope>provided</scope>
111-
</dependency>
112-
</dependencies>
113-
<repositories>
114-
<repository>
115-
<id>no-npe-snapshots</id>
116-
<url>https://raw.githubusercontent.com/vegardit/no-npe/mvn-snapshots-repo/</url>
117-
</repository>
118-
</repositories>
119-
12087
</project>

plugin/src/main/java/org/dart4e/editor/DartFileSpellCheckingReconciler.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
* @author Sebastian Thomschke
5151
*/
5252
public final class DartFileSpellCheckingReconciler extends TMPresentationReconciler implements ModelTokensChangedEvent.Listener,
53-
ITextInputListener {
53+
ITextInputListener {
5454

5555
private static final boolean TRACE_SPELLCHECK_REGIONS = Platform.getDebugBoolean("org.dart4e/trace/spellcheck/regions");
5656
private static final boolean TRACE_SPELLCHECK_TOKENS = Platform.getDebugBoolean("org.dart4e/trace/spellcheck/tokens");
@@ -63,7 +63,7 @@ public final class DartFileSpellCheckingReconciler extends TMPresentationReconci
6363
private Disposable onModelTokensChangedSubscription = () -> { /* nothing to do yet */ };
6464

6565
private void addSpellcheckRegion(final List<Region> regionsToSpellcheck, final IDocument doc, final int offset, final int length)
66-
throws BadLocationException {
66+
throws BadLocationException {
6767
if (TRACE_SPELLCHECK_REGIONS) {
6868
System.out.println("Region offset " + offset + " text: " + doc.get(offset, length));
6969
}
@@ -98,7 +98,7 @@ private List<Region> collectRegionsToSpellcheck(final ITMDocumentModel docModel,
9898
break;
9999

100100
case "comment.block.dart", // one line of a /* block comment
101-
"comment.block.documentation.dart": // one line of a /** block comment OR a /// comment
101+
"comment.block.documentation.dart": // one line of a /** block comment OR a /// comment
102102
if (blockCommentStartOffset == -1) {
103103
blockCommentStartOffset = doc.getLineOffset(lineIndex) + token.startIndex;
104104
}
@@ -147,12 +147,10 @@ public void inputDocumentChanged(final @Nullable IDocument oldInput, final @Null
147147
}
148148

149149
@Override
150-
public void install(@Nullable final ITextViewer viewer) {
150+
public void install(final ITextViewer viewer) {
151151
super.install(viewer);
152152
this.viewer = viewer;
153-
if (viewer != null) {
154-
viewer.addTextInputListener(this);
155-
}
153+
viewer.addTextInputListener(this);
156154
}
157155

158156
@Override
@@ -188,7 +186,7 @@ protected IStatus run(final IProgressMonitor monitor) {
188186
}
189187

190188
private void spellcheck(final IDocument doc, final List<Region> regionsToCheck, final IAnnotationModel annotationModel,
191-
final IProgressMonitor monitor) {
189+
final IProgressMonitor monitor) {
192190
SPELLING_SERVICE.check( //
193191
doc, //
194192
regionsToCheck.toArray(new Region[regionsToCheck.size()]), //

plugin/src/main/java/org/dart4e/flutter/launch/command/AbstractFlutterCommandHandler.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.eclipse.core.commands.AbstractHandler;
1313
import org.eclipse.core.commands.ExecutionEvent;
1414
import org.eclipse.core.resources.IProject;
15+
import org.eclipse.core.runtime.NullProgressMonitor;
1516
import org.eclipse.core.runtime.jobs.Job;
1617
import org.eclipse.jdt.annotation.Nullable;
1718
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -48,6 +49,10 @@ public AbstractFlutterCommandHandler(final String title, final String... flutter
4849

4950
public void runFlutterCommand(final IProject project) {
5051
final var job = Job.create(title, jobMonitor -> {
52+
if (jobMonitor == null) {
53+
jobMonitor = new NullProgressMonitor();
54+
}
55+
5156
final var prefs = FlutterProjectPreference.get(project);
5257
final var flutterSDK = prefs.getEffectiveFlutterSDK();
5358

plugin/src/main/java/org/dart4e/flutter/prefs/FlutterSDKPreferencePage.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public boolean isGrayed(final @Nullable Object element) {
9090
sdkTable.setContentProvider((IStructuredContentProvider) input -> {
9191
@SuppressWarnings("unchecked")
9292
final var items = (List<FlutterSDK>) input;
93-
return items.toArray(new FlutterSDK[items.size()]);
93+
return items == null ? new FlutterSDK[0] : items.toArray(new FlutterSDK[items.size()]);
9494
});
9595

9696
sdkTable.setContentProvider(new IStructuredContentProvider() {
@@ -117,8 +117,8 @@ public StyledString getStyledText(final @Nullable Object element) {
117117
return new StyledString("");
118118
final var sdk = (FlutterSDK) element;
119119
return isDefaultFlutterSDK(sdk) //
120-
? new StyledString(sdk.getName(), Fonts.DEFAULT_FONT_BOLD_STYLER)
121-
: new StyledString(sdk.getName());
120+
? new StyledString(sdk.getName(), Fonts.DEFAULT_FONT_BOLD_STYLER)
121+
: new StyledString(sdk.getName());
122122
}
123123
});
124124
colName.getColumn().setWidth(100);

plugin/src/main/java/org/dart4e/langserver/DartLangServerLauncher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public DartLangServerLauncher() {
5353
}
5454

5555
@Override
56-
public Map<String, Object> getInitializationOptions(final @Nullable URI projectRootUri) {
56+
public @Nullable Map<String, Object> getInitializationOptions(final @Nullable URI projectRootUri) {
5757
final var project = Projects.findProjectOfResource(projectRootUri);
5858
final @Nullable DartSDK dartSDK;
5959
final BuildSystem buildSystem;

plugin/src/main/java/org/dart4e/launch/command/AbstractDartCommandHandler.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.eclipse.core.commands.ExecutionEvent;
1414
import org.eclipse.core.commands.ExecutionException;
1515
import org.eclipse.core.resources.IProject;
16+
import org.eclipse.core.runtime.NullProgressMonitor;
1617
import org.eclipse.core.runtime.jobs.Job;
1718
import org.eclipse.jdt.annotation.Nullable;
1819
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -50,6 +51,10 @@ public AbstractDartCommandHandler(final String title, final String... dartArgs)
5051

5152
public void runDartCommand(final IProject project) {
5253
final var job = Job.create(title, jobMonitor -> {
54+
if (jobMonitor == null) {
55+
jobMonitor = new NullProgressMonitor();
56+
}
57+
5358
final var prefs = DartProjectPreference.get(project);
5459
final var dartSDK = prefs.getEffectiveDartSDK();
5560

plugin/src/main/java/org/dart4e/model/buildsystem/DartBuildFile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public Set<DartDependency> getDependencies(final IProgressMonitor monitor) {
9595

9696
final java.nio.file.Path libLocation = switch (source) {
9797
case "hosted" -> {
98-
final var url = new URL((String) ((Map<?, ?>) descr).get("url"));
98+
final var url = new URL(asNonNull((String) ((Map<?, ?>) descr).get("url")));
9999
yield pubCacheDir.resolve(source).resolve(url.getHost()).resolve(name + "-" + version);
100100
}
101101
case "git" -> {
@@ -141,7 +141,7 @@ public Set<DartDependency> getDependencies(final IProgressMonitor monitor) {
141141
}
142142

143143
protected java.nio.file.Path getSDKDependencyLocation(final String sdkName, final String pkgName,
144-
@SuppressWarnings("unused") final String pkgVersion) {
144+
@SuppressWarnings("unused") final String pkgVersion) {
145145
throw new IllegalArgumentException("Unsupported SDK [" + sdkName + "] of package [" + pkgName + "]");
146146
}
147147

plugin/src/main/java/org/dart4e/navigation/DartOutlineSymbolsProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
public final class DartOutlineSymbolsProvider extends SymbolsLabelProvider {
2828

2929
@Override
30-
public @Nullable Image getImage(final @Nullable Object item) {
30+
public @Nullable Image getImage(final Object item) {
3131
SymbolKind kind = null;
3232
if (item instanceof final SymbolInformation symbolInfo) {
3333
kind = symbolInfo.getKind();

plugin/src/main/java/org/dart4e/shell/RunShellEmbeddedHandler.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.eclipse.core.commands.ExecutionEvent;
2121
import org.eclipse.core.commands.ExecutionException;
2222
import org.eclipse.core.resources.IProject;
23+
import org.eclipse.core.runtime.NullProgressMonitor;
2324
import org.eclipse.core.runtime.Status;
2425
import org.eclipse.core.runtime.jobs.Job;
2526
import org.eclipse.jdt.annotation.Nullable;
@@ -55,6 +56,10 @@ public class RunShellEmbeddedHandler extends AbstractHandler {
5556

5657
private void launchShell(@Nullable final IProject project) {
5758
final var job = Job.create("Preparing Dart Shell", jobMonitor -> {
59+
if (jobMonitor == null) {
60+
jobMonitor = new NullProgressMonitor();
61+
}
62+
5863
final DartSDK dartSDK;
5964
if (project == null) {
6065
dartSDK = DartWorkspacePreference.getDefaultDartSDK(true, true);

0 commit comments

Comments
 (0)