Add more nullable annotations
diff --git a/ecommons/org.eclipse.statet.ecommons.coremisc/src/org/eclipse/statet/ecommons/io/FileValidator.java b/ecommons/org.eclipse.statet.ecommons.coremisc/src/org/eclipse/statet/ecommons/io/FileValidator.java
index e399bd9..c8e2900 100644
--- a/ecommons/org.eclipse.statet.ecommons.coremisc/src/org/eclipse/statet/ecommons/io/FileValidator.java
+++ b/ecommons/org.eclipse.statet.ecommons.coremisc/src/org/eclipse/statet/ecommons/io/FileValidator.java
@@ -39,6 +39,8 @@
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.statet.jcommons.lang.Nullable;
+
import org.eclipse.statet.ecommons.io.internal.Messages;
import org.eclipse.statet.ecommons.runtime.core.util.StatusUtils;
import org.eclipse.statet.ecommons.variables.core.VariableText2;
@@ -83,7 +85,7 @@
private boolean asWorkspacePath;
private Map<Pattern, Integer> onPattern;
- private IValidator fileStoreValidator;
+ private IValidator<? super IFileStore> fileStoreValidator;
private int currentMax;
@@ -262,7 +264,7 @@
return -1;
}
- public void setFileStoreValidator(final IValidator validator) {
+ public void setFileStoreValidator(final IValidator<? super IFileStore> validator) {
this.fileStoreValidator= validator;
}
@@ -290,7 +292,7 @@
setStatus(null);
}
- protected void setStatus(final IStatus status) {
+ protected void setStatus(final @Nullable IStatus status) {
this.status= status;
}
@@ -580,7 +582,7 @@
}
- public IFileStore getFileStore() {
+ public @Nullable IFileStore getFileStore() {
checkExplicit();
if (this.fileStore == null && this.workspaceResource != null) {
try {
diff --git a/ecommons/org.eclipse.statet.ecommons.coremisc/src/org/eclipse/statet/ecommons/io/ObservableFileValidator.java b/ecommons/org.eclipse.statet.ecommons.coremisc/src/org/eclipse/statet/ecommons/io/ObservableFileValidator.java
index b6d9715..6f635f9 100644
--- a/ecommons/org.eclipse.statet.ecommons.coremisc/src/org/eclipse/statet/ecommons/io/ObservableFileValidator.java
+++ b/ecommons/org.eclipse.statet.ecommons.coremisc/src/org/eclipse/statet/ecommons/io/ObservableFileValidator.java
@@ -25,16 +25,20 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.variables.IStringVariable;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
+
import org.eclipse.statet.ecommons.variables.core.ObservableVariable;
+@NonNullByDefault
public class ObservableFileValidator extends FileValidator {
- private class ResourceObservableValue extends AbstractObservableValue<IResource> {
+ private class ResourceObservableValue extends AbstractObservableValue<@Nullable IResource> {
- private IResource value;
+ private @Nullable IResource value;
public ResourceObservableValue(final Realm realm) {
@@ -48,17 +52,17 @@
}
@Override
- protected IResource doGetValue() {
+ protected @Nullable IResource doGetValue() {
return this.value;
}
@Override
- protected void doSetValue(final IResource value) {
+ protected void doSetValue(final @Nullable IResource value) {
setExplicit(value);
checkExplicit();
}
- void update(final IResource newValue) {
+ void update(final @Nullable IResource newValue) {
if ((newValue != null) ? !newValue.equals(this.value) : null != this.value) {
fireValueChange(Diffs.createValueDiff(this.value, this.value= newValue));
}
@@ -66,10 +70,10 @@
}
- private class FileStoreObservableValue extends AbstractObservableValue<IFileStore> {
+ private class FileStoreObservableValue extends AbstractObservableValue<@Nullable IFileStore> {
- private IFileStore value;
+ private @Nullable IFileStore value;
public FileStoreObservableValue(final Realm realm) {
@@ -83,17 +87,17 @@
}
@Override
- protected IFileStore doGetValue() {
+ protected @Nullable IFileStore doGetValue() {
return this.value;
}
@Override
- protected void doSetValue(final IFileStore value) {
+ protected void doSetValue(final @Nullable IFileStore value) {
setExplicit(value);
checkExplicit();
}
- void update(final IFileStore newValue) {
+ void update(final @Nullable IFileStore newValue) {
if ((newValue != null) ? !newValue.equals(this.value) : null != this.value) {
fireValueChange(Diffs.createValueDiff(this.value, this.value= newValue));
}
@@ -104,10 +108,10 @@
private final Realm realm;
- private IChangeListener observableListener;
+ private @Nullable IChangeListener observableListener;
- private ResourceObservableValue resourceObservable;
- private FileStoreObservableValue fileStoreObservable;
+ private @Nullable ResourceObservableValue resourceObservable;
+ private @Nullable FileStoreObservableValue fileStoreObservable;
public ObservableFileValidator(final Realm realm) {
@@ -118,44 +122,54 @@
@Override
void checkVariable(final IStringVariable variable) {
if (variable instanceof ObservableVariable) {
- if (this.observableListener == null) {
- this.observableListener= new IChangeListener() {
+ IChangeListener listener= this.observableListener;
+ if (listener == null) {
+ listener= new IChangeListener() {
@Override
public void handleChange(final ChangeEvent event) {
updateVariableResolution();
}
};
+ this.observableListener= listener;
}
- ((ObservableVariable) variable).addChangeListener(this.observableListener);
+ ((ObservableVariable) variable).addChangeListener(listener);
}
}
@Override
- protected void setStatus(final IStatus status) {
+ protected void setStatus(final @Nullable IStatus status) {
super.setStatus(status);
- if (this.resourceObservable != null) {
- this.resourceObservable.update(getWorkspaceResource());
+ { final ResourceObservableValue observable= this.resourceObservable;
+ if (observable != null) {
+ observable.update(getWorkspaceResource());
+ }
}
- if (this.fileStoreObservable != null) {
- this.fileStoreObservable.update(getFileStore());
+ { final FileStoreObservableValue observable= this.fileStoreObservable;
+ if (observable != null) {
+ observable.update(getFileStore());
+ }
}
}
- public IObservableValue<IResource> getWorkspaceResourceObservable() {
- if (this.resourceObservable == null) {
- this.resourceObservable= new ResourceObservableValue(this.realm);
- this.resourceObservable.update(getWorkspaceResource());
+ public IObservableValue<@Nullable IResource> getWorkspaceResourceObservable() {
+ ResourceObservableValue observable= this.resourceObservable;
+ if (observable == null) {
+ observable= new ResourceObservableValue(this.realm);
+ observable.update(getWorkspaceResource());
+ this.resourceObservable= observable;
}
- return this.resourceObservable;
+ return observable;
}
- public IObservableValue<IFileStore> getFileStoreObservable() {
- if (this.resourceObservable == null) {
- this.fileStoreObservable= new FileStoreObservableValue(this.realm);
- this.fileStoreObservable.update(getFileStore());
+ public IObservableValue<@Nullable IFileStore> getFileStoreObservable() {
+ FileStoreObservableValue observable= this.fileStoreObservable;
+ if (observable == null) {
+ observable= new FileStoreObservableValue(this.realm);
+ observable.update(getFileStore());
+ this.fileStoreObservable= observable;
}
- return this.fileStoreObservable;
+ return observable;
}
}
diff --git a/ecommons/org.eclipse.statet.ecommons.coremisc/src/org/eclipse/statet/ecommons/variables/core/DynamicVariable.java b/ecommons/org.eclipse.statet.ecommons.coremisc/src/org/eclipse/statet/ecommons/variables/core/DynamicVariable.java
index 2645011..2d5fa80 100644
--- a/ecommons/org.eclipse.statet.ecommons.coremisc/src/org/eclipse/statet/ecommons/variables/core/DynamicVariable.java
+++ b/ecommons/org.eclipse.statet.ecommons.coremisc/src/org/eclipse/statet/ecommons/variables/core/DynamicVariable.java
@@ -14,6 +14,8 @@
package org.eclipse.statet.ecommons.variables.core;
+import static org.eclipse.statet.jcommons.lang.ObjectUtils.nonNullAssert;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -48,26 +50,18 @@
private final IDynamicVariableResolver resolver;
- public ResolverVariable(final String name, final String description,
+ public ResolverVariable(final String name, final @Nullable String description,
final boolean supportsArgument, final IDynamicVariableResolver resolver) {
super(name, description, supportsArgument);
- if (resolver == null) {
- throw new NullPointerException("resolver"); //$NON-NLS-1$
- }
-
- this.resolver= resolver;
+ this.resolver= nonNullAssert(resolver);
}
public ResolverVariable(final IStringVariable variable,
final IDynamicVariableResolver resolver) {
super(variable);
- if (resolver == null) {
- throw new NullPointerException("resolver"); //$NON-NLS-1$
- }
-
- this.resolver= resolver;
+ this.resolver= nonNullAssert(resolver);
}
diff --git a/ecommons/org.eclipse.statet.ecommons.databinding.core/src/org/eclipse/statet/ecommons/databinding/core/observable/WritableEqualityValue.java b/ecommons/org.eclipse.statet.ecommons.databinding.core/src/org/eclipse/statet/ecommons/databinding/core/observable/WritableEqualityValue.java
index bc4b14f..7f5e06b 100644
--- a/ecommons/org.eclipse.statet.ecommons.databinding.core/src/org/eclipse/statet/ecommons/databinding/core/observable/WritableEqualityValue.java
+++ b/ecommons/org.eclipse.statet.ecommons.databinding.core/src/org/eclipse/statet/ecommons/databinding/core/observable/WritableEqualityValue.java
@@ -18,46 +18,19 @@
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.AbstractObservableValue;
+import org.eclipse.statet.jcommons.lang.NonNull;
+import org.eclipse.statet.jcommons.lang.Nullable;
+
public class WritableEqualityValue<TValue> extends AbstractObservableValue<TValue> {
- private final Object valueType;
+ private final @Nullable Object valueType;
private TValue value= null;
/**
- * Constructs a new instance with the default realm, a <code>null</code>
- * value type, and a <code>null</code> value.
- */
- public WritableEqualityValue() {
- this(null, null);
- }
-
- /**
- * Constructs a new instance with the default realm.
- *
- * @param initialValue
- * can be <code>null</code>
- * @param valueType
- * can be <code>null</code>
- */
- public WritableEqualityValue(final TValue initialValue, final Object valueType) {
- this(Realm.getDefault(), initialValue, valueType);
- }
-
- /**
- * Constructs a new instance with the provided <code>realm</code>, a
- * <code>null</code> value type, and a <code>null</code> initial value.
- *
- * @param realm
- */
- public WritableEqualityValue(final Realm realm) {
- this(realm, null, null);
- }
-
- /**
* Constructs a new instance.
*
* @param realm
@@ -66,12 +39,43 @@
* @param valueType
* can be <code>null</code>
*/
- public WritableEqualityValue(final Realm realm, final TValue initialValue, final Object valueType) {
+ public WritableEqualityValue(final @NonNull Realm realm,
+ final @Nullable TValue initialValue, final @Nullable Object valueType) {
super(realm);
this.valueType= valueType;
this.value= initialValue;
}
+ /**
+ * Constructs a new instance with the default realm.
+ *
+ * @param initialValue
+ * can be <code>null</code>
+ * @param valueType
+ * can be <code>null</code>
+ */
+ public WritableEqualityValue(final @Nullable TValue initialValue, final @Nullable Object valueType) {
+ this(Realm.getDefault(), initialValue, valueType);
+ }
+
+ /**
+ * Constructs a new instance with the default realm, a <code>null</code>
+ * value type, and a <code>null</code> value.
+ */
+ public WritableEqualityValue() {
+ this(null, null);
+ }
+
+ /**
+ * Constructs a new instance with the provided <code>realm</code>, a
+ * <code>null</code> value type, and a <code>null</code> initial value.
+ *
+ * @param realm
+ */
+ public WritableEqualityValue(final @NonNull Realm realm) {
+ this(realm, null, null);
+ }
+
@Override
public Object getValueType() {
diff --git a/ecommons/org.eclipse.statet.ecommons.databinding.core/src/org/eclipse/statet/internal/ecommons/databinding/core/ECommonsDatabindingCorePlugin.java b/ecommons/org.eclipse.statet.ecommons.databinding.core/src/org/eclipse/statet/internal/ecommons/databinding/core/ECommonsDatabindingCorePlugin.java
index 079284c..d37f38b 100644
--- a/ecommons/org.eclipse.statet.ecommons.databinding.core/src/org/eclipse/statet/internal/ecommons/databinding/core/ECommonsDatabindingCorePlugin.java
+++ b/ecommons/org.eclipse.statet.ecommons.databinding.core/src/org/eclipse/statet/internal/ecommons/databinding/core/ECommonsDatabindingCorePlugin.java
@@ -19,21 +19,25 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
+
+@NonNullByDefault
public class ECommonsDatabindingCorePlugin extends Plugin {
public static final String BUNDLE_ID= "org.eclipse.statet.ecommons.databinding.core"; //$NON-NLS-1$
- private static ECommonsDatabindingCorePlugin instance;
+ private static @Nullable ECommonsDatabindingCorePlugin instance;
/**
* Returns the shared plug-in instance
*
* @return the shared instance
*/
- public static ECommonsDatabindingCorePlugin getInstance() {
+ public static @Nullable ECommonsDatabindingCorePlugin getInstance() {
return instance;
}
@@ -49,6 +53,9 @@
private boolean started;
+ public ECommonsDatabindingCorePlugin() {
+ }
+
@Override
public void start(final BundleContext context) throws Exception {
super.start(context);
diff --git a/ecommons/org.eclipse.statet.ecommons.debug.core/src/org/eclipse/statet/ecommons/debug/core/util/LaunchUtils.java b/ecommons/org.eclipse.statet.ecommons.debug.core/src/org/eclipse/statet/ecommons/debug/core/util/LaunchUtils.java
index 328d42a..bbd9506 100644
--- a/ecommons/org.eclipse.statet.ecommons.debug.core/src/org/eclipse/statet/ecommons/debug/core/util/LaunchUtils.java
+++ b/ecommons/org.eclipse.statet.ecommons.debug.core/src/org/eclipse/statet/ecommons/debug/core/util/LaunchUtils.java
@@ -44,6 +44,8 @@
import org.eclipse.osgi.util.NLS;
import org.eclipse.statet.jcommons.collections.CaseInsensitiveMap;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
import org.eclipse.statet.ecommons.debug.core.ECommonsDebugCore;
import org.eclipse.statet.internal.ecommons.debug.core.Messages;
@@ -125,7 +127,9 @@
* @param environment
* @throws CoreException
*/
- public static Map<String, String> createEnvironment(final ILaunchConfiguration configuration, final Map<String, String>[] add)
+ @NonNullByDefault
+ public static Map<String, String> createEnvironment(final ILaunchConfiguration configuration,
+ final @Nullable Map<String, String> @Nullable [] additionals)
throws CoreException {
final Map<String, String> envp= (Platform.getOS().startsWith("win")) ? //$NON-NLS-1$
new CaseInsensitiveMap<>(64) : new HashMap<>(64);
@@ -134,10 +138,10 @@
}
Map<String, String> custom= (configuration != null) ? configuration.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, (Map<String, String>) null) : null;
- if (add != null) {
- for (int i= 0; i < add.length; i++) {
- if (add[i] != null) {
- envp.putAll(check(envp, add[i]));
+ if (additionals != null) {
+ for (final Map<String, String> additional : additionals) {
+ if (additional != null) {
+ envp.putAll(check(envp, additional));
}
else if (custom != null) {
envp.putAll(check(envp, custom));
@@ -155,12 +159,14 @@
private static Pattern ENV_PATTERN= Pattern.compile("\\Q${env_var:\\E([^\\}]*)\\}"); //$NON-NLS-1$
- private static Map<String, String> check(final Map<String,String> current, final Map<String,String> add) throws CoreException {
+ @NonNullByDefault
+ private static Map<String, String> check(final Map<String, String> current,
+ final Map<String, String> add) throws CoreException {
final Map<String, String> resolved= new HashMap<>();
final Set<Entry<String, String>> entries= add.entrySet();
for (final Entry<String, String> entry : entries) {
String value= entry.getValue();
- if (value != null && value.length() > 0) {
+ if (value != null && !value.isEmpty()) {
if (value.contains("${env_var:")) { //$NON-NLS-1$
final StringBuffer sb= new StringBuffer(value.length()+32);
final Matcher matcher= ENV_PATTERN.matcher(value);
diff --git a/ecommons/org.eclipse.statet.ecommons.debug.core/src/org/eclipse/statet/ecommons/resources/core/variables/ResourceVariableResolver.java b/ecommons/org.eclipse.statet.ecommons.debug.core/src/org/eclipse/statet/ecommons/resources/core/variables/ResourceVariableResolver.java
index d1ca0a9..854dc6e 100644
--- a/ecommons/org.eclipse.statet.ecommons.debug.core/src/org/eclipse/statet/ecommons/resources/core/variables/ResourceVariableResolver.java
+++ b/ecommons/org.eclipse.statet.ecommons.debug.core/src/org/eclipse/statet/ecommons/resources/core/variables/ResourceVariableResolver.java
@@ -49,17 +49,21 @@
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
+
import org.eclipse.statet.ecommons.debug.core.ECommonsDebugCore;
import org.eclipse.statet.internal.ecommons.debug.core.Messages;
+@NonNullByDefault
public class ResourceVariableResolver implements IDynamicVariableResolver {
public static interface Context {
- IResource getResource();
+ @Nullable IResource getResource();
}
@@ -70,7 +74,7 @@
}
@Override
- public IResource getResource() {
+ public @Nullable IResource getResource() {
final IStringVariableManager manager= VariablesPlugin.getDefault().getStringVariableManager();
try {
final String path= manager.performStringSubstitution("${selected_resource_path}"); //$NON-NLS-1$
@@ -108,7 +112,7 @@
this(context, EXISTS_SELECTED);
}
- public ResourceVariableResolver(final Context context, final byte flags) {
+ public ResourceVariableResolver(final @Nullable Context context, final byte flags) {
this.context= (context != null) ? context : DEFAULT_CONTEXT;
this.flags= flags;
}
@@ -119,7 +123,7 @@
}
@Override
- public String resolveValue(final IDynamicVariable variable, final String argument)
+ public @Nullable String resolveValue(final IDynamicVariable variable, final @Nullable String argument)
throws CoreException {
switch (variable.getName()) {
case RESOURCE_LOC_VAR_NAME:
@@ -160,7 +164,7 @@
}
- protected boolean requireExists(final IDynamicVariable variable, final String argument) {
+ protected boolean requireExists(final IDynamicVariable variable, final @Nullable String argument) {
switch (this.flags & EXISTS_MASK) {
case EXISTS_NEVER:
return false;
@@ -174,7 +178,7 @@
}
protected IResource getResource(final IDynamicVariable variable, final byte resourceType,
- final String argument) throws CoreException {
+ final @Nullable String argument) throws CoreException {
IResource resource;
if (argument == null) {
resource= this.context.getResource();
@@ -217,7 +221,7 @@
return resource;
}
- protected IPath getResourcePath(final IDynamicVariable variable, final String argument)
+ protected IPath getResourcePath(final IDynamicVariable variable, final @Nullable String argument)
throws CoreException {
if (argument == null) {
return getResource(variable, RESOURCE, argument).getFullPath();
@@ -227,6 +231,7 @@
}
}
+ @SuppressWarnings("null")
protected IResource toVariableResource(final IDynamicVariable variable, final byte resourceType,
final IResource resource) {
switch (resourceType) {
@@ -265,7 +270,7 @@
return resource.getName();
}
- protected String toEncValue(final IDynamicVariable variable, final IResource resource)
+ protected @Nullable String toEncValue(final IDynamicVariable variable, final IResource resource)
throws CoreException {
String charset;
if (resource instanceof IFile) {
@@ -280,15 +285,18 @@
return charset;
}
- protected String toNameBaseValue(final IDynamicVariable variable, final IPath path) {
+ protected @Nullable String toNameBaseValue(final IDynamicVariable variable, final IPath path) {
final String lastSegment= path.lastSegment();
+ if (lastSegment == null) {
+ return null;
+ }
final String extension= path.getFileExtension();
return (extension != null) ?
lastSegment.substring(0, lastSegment.length() - (extension.length() + 1)) :
lastSegment;
}
- protected String toNameExtValue(final IDynamicVariable variable, final IPath path) {
+ protected @Nullable String toNameExtValue(final IDynamicVariable variable, final IPath path) {
return path.getFileExtension();
}
diff --git a/ecommons/org.eclipse.statet.ecommons.debug.core/src/org/eclipse/statet/ecommons/resources/core/variables/ResourceVariables.java b/ecommons/org.eclipse.statet.ecommons.debug.core/src/org/eclipse/statet/ecommons/resources/core/variables/ResourceVariables.java
index 3d33cf7..e5bde0a 100644
--- a/ecommons/org.eclipse.statet.ecommons.debug.core/src/org/eclipse/statet/ecommons/resources/core/variables/ResourceVariables.java
+++ b/ecommons/org.eclipse.statet.ecommons.debug.core/src/org/eclipse/statet/ecommons/resources/core/variables/ResourceVariables.java
@@ -23,10 +23,14 @@
import org.eclipse.statet.jcommons.collections.ImCollections;
import org.eclipse.statet.jcommons.collections.ImList;
+import org.eclipse.statet.jcommons.lang.NonNull;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
import org.eclipse.statet.ecommons.variables.core.DynamicVariable;
+@NonNullByDefault
public class ResourceVariables {
@@ -57,22 +61,24 @@
PROJECT_LOC_VAR_NAME, PROJECT_PATH_VAR_NAME, PROJECT_NAME_VAR_NAME, PROJECT_ENC_VAR_NAME,
FILE_NAME_BASE_VAR_NAME, FILE_NAME_EXT_VAR_NAME );
- private static volatile ImList<IDynamicVariable> singleResourceVariables;
+ private static volatile @Nullable ImList<IDynamicVariable> singleResourceVariables;
public static final ImList<IDynamicVariable> getSingleResourceVariables() {
- if (singleResourceVariables == null) {
+ ImList<IDynamicVariable> variables= singleResourceVariables;
+ if (variables == null) {
synchronized (SINGLE_RESOURCE_VAR_NAMES) {
- if (singleResourceVariables == null) {
- singleResourceVariables= createSingleResourceVars();
+ variables= singleResourceVariables;
+ if (variables == null) {
+ variables= createSingleResourceVars();
}
}
}
- return singleResourceVariables;
+ return variables;
}
private static final ImList<IDynamicVariable> createSingleResourceVars() {
final ImList<String> names= ResourceVariables.SINGLE_RESOURCE_VAR_NAMES;
- final IDynamicVariable[] variables= new IDynamicVariable[names.size()];
+ final IDynamicVariable[] variables= new @NonNull IDynamicVariable[names.size()];
final IStringVariableManager manager= VariablesPlugin.getDefault().getStringVariableManager();
for (int i= 0; i < variables.length; i++) {
final String name= names.get(i);
@@ -90,7 +96,7 @@
public static final ImList<IDynamicVariable> createSingleResourceVarDefs(final String selectedResourceTerm) {
final ImList<IDynamicVariable> globalVariables= getSingleResourceVariables();
- final IDynamicVariable[] variables= new IDynamicVariable[globalVariables.size()];
+ final IDynamicVariable[] variables= new @NonNull IDynamicVariable[globalVariables.size()];
final Matcher selResMatcher= Pattern.compile("selected resource", Pattern.LITERAL).matcher(""); //$NON-NLS-1$
final String selResReplacement= Matcher.quoteReplacement(selectedResourceTerm);
diff --git a/ecommons/org.eclipse.statet.ecommons.debug.core/src/org/eclipse/statet/internal/ecommons/debug/core/ECommonsDebugCorePlugin.java b/ecommons/org.eclipse.statet.ecommons.debug.core/src/org/eclipse/statet/internal/ecommons/debug/core/ECommonsDebugCorePlugin.java
index 3ab6bd2..1f69e07 100644
--- a/ecommons/org.eclipse.statet.ecommons.debug.core/src/org/eclipse/statet/internal/ecommons/debug/core/ECommonsDebugCorePlugin.java
+++ b/ecommons/org.eclipse.statet.ecommons.debug.core/src/org/eclipse/statet/internal/ecommons/debug/core/ECommonsDebugCorePlugin.java
@@ -19,18 +19,22 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
+
+@NonNullByDefault
public class ECommonsDebugCorePlugin extends Plugin {
- private static ECommonsDebugCorePlugin instance;
+ private static @Nullable ECommonsDebugCorePlugin instance;
/**
* Returns the shared plug-in instance
*
* @return the shared instance
*/
- public static ECommonsDebugCorePlugin getInstance() {
+ public static @Nullable ECommonsDebugCorePlugin getInstance() {
return instance;
}
@@ -46,6 +50,9 @@
private boolean started;
+ public ECommonsDebugCorePlugin() {
+ }
+
@Override
public void start(final BundleContext context) throws Exception {
super.start(context);
diff --git a/ecommons/org.eclipse.statet.ecommons.debug.ui/src/org/eclipse/statet/ecommons/debug/ui/config/LaunchConfigTabWithDbc.java b/ecommons/org.eclipse.statet.ecommons.debug.ui/src/org/eclipse/statet/ecommons/debug/ui/config/LaunchConfigTabWithDbc.java
index 1ec6bb1..721dc86 100644
--- a/ecommons/org.eclipse.statet.ecommons.debug.ui/src/org/eclipse/statet/ecommons/debug/ui/config/LaunchConfigTabWithDbc.java
+++ b/ecommons/org.eclipse.statet.ecommons.debug.ui/src/org/eclipse/statet/ecommons/debug/ui/config/LaunchConfigTabWithDbc.java
@@ -14,6 +14,8 @@
package org.eclipse.statet.ecommons.debug.ui.config;
+import static org.eclipse.statet.jcommons.lang.ObjectUtils.nonNullAssert;
+
import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.observable.ObservableEvent;
@@ -31,6 +33,9 @@
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.ui.statushandlers.StatusManager;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
+
import org.eclipse.statet.ecommons.databinding.core.AggregateValidationStatus;
import org.eclipse.statet.ecommons.databinding.core.DataStatus;
import org.eclipse.statet.ecommons.databinding.core.util.DirtyTracker;
@@ -48,13 +53,14 @@
* <p>Validation status with severity WARNING are handled like errors, but can be saved.
* </p>
*/
+@NonNullByDefault
public abstract class LaunchConfigTabWithDbc extends AbstractLaunchConfigurationTab {
private DataBindingContext dbc;
private AggregateValidationStatus aggregateStatus;
- private IStatus currentStatus;
+ private @Nullable IStatus currentStatus;
private boolean initializing;
@@ -165,6 +171,44 @@
disposeBindings();
}
+
+ @SuppressWarnings("null")
+ protected String readAttribute(final ILaunchConfiguration configuration,
+ final String attributeName, final String defaultValue) {
+ String value= nonNullAssert(defaultValue);
+ try {
+ value= configuration.getAttribute(attributeName, defaultValue);
+ }
+ catch (final CoreException e) {
+ logReadingError(e);
+ }
+ return value;
+ }
+
+ protected boolean readAttribute(final ILaunchConfiguration configuration,
+ final String attributeName, final boolean defaultValue) {
+ boolean value= defaultValue;
+ try {
+ value= configuration.getAttribute(attributeName, defaultValue);
+ }
+ catch (final CoreException e) {
+ logReadingError(e);
+ }
+ return value;
+ }
+
+ protected int readAttribute(final ILaunchConfiguration configuration,
+ final String attributeName, final int defaultValue) {
+ int value= defaultValue;
+ try {
+ value= configuration.getAttribute(attributeName, defaultValue);
+ }
+ catch (final CoreException e) {
+ logReadingError(e);
+ }
+ return value;
+ }
+
protected void logReadingError(final CoreException e) {
StatusManager.getManager().handle(new Status(IStatus.ERROR, ECommonsDebugUI.BUNDLE_ID, 0,
NLS.bind("An error occurred while reading launch configuration (name: ''{0}'', id: ''{1}'')", //$NON-NLS-1$
@@ -172,6 +216,7 @@
e ));
}
+
@Override
public void initializeFrom(final ILaunchConfiguration configuration) {
this.initializing= true;
diff --git a/ecommons/org.eclipse.statet.ecommons.debug.ui/src/org/eclipse/statet/ecommons/debug/ui/config/LaunchConfigTabWithPresets.java b/ecommons/org.eclipse.statet.ecommons.debug.ui/src/org/eclipse/statet/ecommons/debug/ui/config/LaunchConfigTabWithPresets.java
index 5f77e02..a33d925 100644
--- a/ecommons/org.eclipse.statet.ecommons.debug.ui/src/org/eclipse/statet/ecommons/debug/ui/config/LaunchConfigTabWithPresets.java
+++ b/ecommons/org.eclipse.statet.ecommons.debug.ui/src/org/eclipse/statet/ecommons/debug/ui/config/LaunchConfigTabWithPresets.java
@@ -35,19 +35,22 @@
import org.eclipse.statet.jcommons.collections.ImCollections;
import org.eclipse.statet.jcommons.collections.ImList;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
import org.eclipse.statet.ecommons.debug.ui.ECommonsDebugUI;
import org.eclipse.statet.ecommons.ui.components.DropDownButton;
import org.eclipse.statet.internal.ecommons.debug.ui.Messages;
+@NonNullByDefault
public abstract class LaunchConfigTabWithPresets extends LaunchConfigTabWithDbc {
- private ImList<ILaunchConfiguration> presets;
+ private ImList<ILaunchConfiguration> presets= ImCollections.emptyList();
- private Map<String, Object> presetToLoad;
- private ILaunchConfiguration presetLoaded;
+ private @Nullable Map<String, Object> presetToLoad;
+ private @Nullable ILaunchConfiguration presetLoaded;
protected LaunchConfigTabWithPresets() {
@@ -69,7 +72,7 @@
final SelectionListener selectionListener= new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
- loadPreset((ILaunchConfiguration) e.widget.getData());
+ loadPreset((ILaunchConfiguration)e.widget.getData());
}
};
for (final ILaunchConfiguration preset : this.presets) {
@@ -79,7 +82,7 @@
item.addSelectionListener(selectionListener);
}
- if (this.presets == null || this.presets.isEmpty()) {
+ if (this.presets.isEmpty()) {
button.setEnabled(false);
}
@@ -89,7 +92,7 @@
protected ImList<ILaunchConfigurationTab> getPresetTabs(final ILaunchConfiguration config) {
final ILaunchConfigurationTab[] tabs= getLaunchConfigurationDialog().getTabs();
- if (tabs[tabs.length - 1] instanceof CommonTab) {
+ if (tabs != null && tabs[tabs.length - 1] instanceof CommonTab) {
return ImCollections.newList(tabs, 0, tabs.length - 1);
}
else {
@@ -103,8 +106,8 @@
setDirty(true);
updateLaunchConfigurationDialog();
- if (this.presetLoaded != null) {
- final ILaunchConfiguration config= this.presetLoaded;
+ final ILaunchConfiguration config= this.presetLoaded;
+ if (config != null) {
final List<ILaunchConfigurationTab> tabs= getPresetTabs(config);
for (final ILaunchConfigurationTab tab : tabs) {
@@ -130,17 +133,16 @@
@Override
public void performApply(final ILaunchConfigurationWorkingCopy configuration) {
- if (this.presetToLoad != null) {
- try {
- configuration.removeAttribute(getValidationErrorAttr());
-
- LaunchConfigPresets.apply(this.presetToLoad, configuration);
- this.presetLoaded= configuration;
- return;
- }
- finally {
- this.presetToLoad= null;
- }
+ final Map<String, Object> presetToLoad= this.presetToLoad;
+ if (presetToLoad != null) {
+ this.presetToLoad= null;
+
+ configuration.removeAttribute(getValidationErrorAttr());
+
+ LaunchConfigPresets.apply(presetToLoad, configuration);
+
+ this.presetLoaded= configuration;
+ return;
}
super.performApply(configuration);
diff --git a/ecommons/org.eclipse.statet.ecommons.debug.ui/src/org/eclipse/statet/internal/ecommons/debug/ui/ECommonsDebugUIPlugin.java b/ecommons/org.eclipse.statet.ecommons.debug.ui/src/org/eclipse/statet/internal/ecommons/debug/ui/ECommonsDebugUIPlugin.java
index 0336574..517775a 100644
--- a/ecommons/org.eclipse.statet.ecommons.debug.ui/src/org/eclipse/statet/internal/ecommons/debug/ui/ECommonsDebugUIPlugin.java
+++ b/ecommons/org.eclipse.statet.ecommons.debug.ui/src/org/eclipse/statet/internal/ecommons/debug/ui/ECommonsDebugUIPlugin.java
@@ -21,21 +21,25 @@
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
+
import org.eclipse.statet.ecommons.debug.ui.ECommonsDebugUIResources;
import org.eclipse.statet.ecommons.ui.util.ImageRegistryUtil;
+@NonNullByDefault
public class ECommonsDebugUIPlugin extends AbstractUIPlugin {
- private static ECommonsDebugUIPlugin instance;
+ private static @Nullable ECommonsDebugUIPlugin instance;
/**
* Returns the shared plug-in instance
*
* @return the shared instance
*/
- public static ECommonsDebugUIPlugin getInstance() {
+ public static @Nullable ECommonsDebugUIPlugin getInstance() {
return instance;
}
@@ -51,6 +55,9 @@
private boolean started;
+ public ECommonsDebugUIPlugin() {
+ }
+
@Override
public void start(final BundleContext context) throws Exception {
super.start(context);
diff --git a/ecommons/org.eclipse.statet.ecommons.preferences.core/src/org/eclipse/statet/internal/ecommons/preferences/core/ECommonsPreferencesCorePlugin.java b/ecommons/org.eclipse.statet.ecommons.preferences.core/src/org/eclipse/statet/internal/ecommons/preferences/core/ECommonsPreferencesCorePlugin.java
index 30d1a6e..ee5cc0d 100644
--- a/ecommons/org.eclipse.statet.ecommons.preferences.core/src/org/eclipse/statet/internal/ecommons/preferences/core/ECommonsPreferencesCorePlugin.java
+++ b/ecommons/org.eclipse.statet.ecommons.preferences.core/src/org/eclipse/statet/internal/ecommons/preferences/core/ECommonsPreferencesCorePlugin.java
@@ -14,6 +14,8 @@
package org.eclipse.statet.internal.ecommons.preferences.core;
+import static org.eclipse.statet.jcommons.lang.ObjectUtils.nonNullAssert;
+
import java.util.ArrayList;
import java.util.List;
@@ -23,24 +25,27 @@
import org.eclipse.core.runtime.Plugin;
import org.eclipse.statet.jcommons.lang.Disposable;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
import org.eclipse.statet.ecommons.preferences.core.PreferenceSetService;
+@NonNullByDefault
public final class ECommonsPreferencesCorePlugin extends Plugin {
public static final String BUNDLE_ID= "org.eclipse.statet.ecommons.preferences.core"; //$NON-NLS-1$
- private static ECommonsPreferencesCorePlugin instance;
+ private static @Nullable ECommonsPreferencesCorePlugin instance;
/**
* Returns the shared plug-in instance
*
* @return the shared instance
*/
- public static ECommonsPreferencesCorePlugin getInstance() {
+ public static @Nullable ECommonsPreferencesCorePlugin getInstance() {
return instance;
}
@@ -60,12 +65,12 @@
public ECommonsPreferencesCorePlugin() {
- instance= this;
}
@Override
public void start(final BundleContext context) throws Exception {
super.start(context);
+ instance= this;
synchronized (this) {
this.started= true;
@@ -90,7 +95,6 @@
finally {
this.disposables.clear();
}
-
}
finally {
instance= null;
@@ -100,9 +104,7 @@
public void addStoppingListener(final Disposable listener) {
- if (listener == null) {
- throw new NullPointerException();
- }
+ nonNullAssert(listener);
synchronized (this) {
if (!this.started) {
throw new IllegalStateException("Plug-in is not started.");
diff --git a/ecommons/org.eclipse.statet.ecommons.runtime.core/src/org/eclipse/statet/internal/ecommons/runtime/core/RuntimeCorePlugin.java b/ecommons/org.eclipse.statet.ecommons.runtime.core/src/org/eclipse/statet/internal/ecommons/runtime/core/RuntimeCorePlugin.java
index 61d8572..d902429 100644
--- a/ecommons/org.eclipse.statet.ecommons.runtime.core/src/org/eclipse/statet/internal/ecommons/runtime/core/RuntimeCorePlugin.java
+++ b/ecommons/org.eclipse.statet.ecommons.runtime.core/src/org/eclipse/statet/internal/ecommons/runtime/core/RuntimeCorePlugin.java
@@ -25,6 +25,7 @@
import org.eclipse.statet.jcommons.lang.Disposable;
import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
import org.eclipse.statet.jcommons.runtime.AppEnvironment;
import org.eclipse.statet.jcommons.runtime.CommonsRuntime;
import org.eclipse.statet.jcommons.status.Status;
@@ -39,7 +40,7 @@
public static final String BUNDLE_ID= "org.eclipse.statet.ecommons.runtime.core"; //$NON-NLS-1$
- private static RuntimeCorePlugin instance;
+ private static @Nullable RuntimeCorePlugin instance;
/**
@@ -47,7 +48,7 @@
*
* @return the shared instance
*/
- public static RuntimeCorePlugin getInstance() {
+ public static @Nullable RuntimeCorePlugin getInstance() {
return instance;
}
@@ -58,13 +59,12 @@
public RuntimeCorePlugin() {
- instance= this;
}
-
@Override
public void start(final BundleContext context) throws Exception {
super.start(context);
+ instance= this;
synchronized (this) {
this.started= true;
diff --git a/ecommons/org.eclipse.statet.ecommons.text.core/src/org/eclipse/statet/internal/ecommons/text/core/ECommonsTextCorePlugin.java b/ecommons/org.eclipse.statet.ecommons.text.core/src/org/eclipse/statet/internal/ecommons/text/core/ECommonsTextCorePlugin.java
index 9b54780..0d8125e 100644
--- a/ecommons/org.eclipse.statet.ecommons.text.core/src/org/eclipse/statet/internal/ecommons/text/core/ECommonsTextCorePlugin.java
+++ b/ecommons/org.eclipse.statet.ecommons.text.core/src/org/eclipse/statet/internal/ecommons/text/core/ECommonsTextCorePlugin.java
@@ -19,21 +19,25 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
+
+@NonNullByDefault
public class ECommonsTextCorePlugin extends Plugin {
public static final String BUNDLE_ID= "org.eclipse.statet.ecommons.text.core"; //$NON-NLS-1$
- private static ECommonsTextCorePlugin instance;
+ private static @Nullable ECommonsTextCorePlugin instance;
/**
* Returns the shared plug-in instance
*
* @return the shared instance
*/
- public static ECommonsTextCorePlugin getInstance() {
+ public static @Nullable ECommonsTextCorePlugin getInstance() {
return instance;
}
@@ -49,6 +53,9 @@
private boolean started;
+ public ECommonsTextCorePlugin() {
+ }
+
@Override
public void start(final BundleContext context) throws Exception {
super.start(context);
diff --git a/ecommons/org.eclipse.statet.ecommons.uimisc/src/org/eclipse/statet/ecommons/ui/workbench/ResourceInputComposite.java b/ecommons/org.eclipse.statet.ecommons.uimisc/src/org/eclipse/statet/ecommons/ui/workbench/ResourceInputComposite.java
index 6cdf8a5..371208c 100644
--- a/ecommons/org.eclipse.statet.ecommons.uimisc/src/org/eclipse/statet/ecommons/ui/workbench/ResourceInputComposite.java
+++ b/ecommons/org.eclipse.statet.ecommons.uimisc/src/org/eclipse/statet/ecommons/ui/workbench/ResourceInputComposite.java
@@ -34,7 +34,7 @@
import org.eclipse.core.variables.IStringVariableManager;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.ui.StringVariableSelectionDialog.VariableFilter;
-import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.jface.databinding.swt.typed.WidgetProperties;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
diff --git a/ecommons/org.eclipse.statet.ecommons.uimisc/src/org/eclipse/statet/ecommons/ui/workbench/workspace/ResourceVariableUtil.java b/ecommons/org.eclipse.statet.ecommons.uimisc/src/org/eclipse/statet/ecommons/ui/workbench/workspace/ResourceVariableUtil.java
index b7bfc55..7be4334 100644
--- a/ecommons/org.eclipse.statet.ecommons.uimisc/src/org/eclipse/statet/ecommons/ui/workbench/workspace/ResourceVariableUtil.java
+++ b/ecommons/org.eclipse.statet.ecommons.uimisc/src/org/eclipse/statet/ecommons/ui/workbench/workspace/ResourceVariableUtil.java
@@ -28,10 +28,14 @@
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
+
import org.eclipse.statet.ecommons.resources.core.variables.ResourceVariableResolver;
import org.eclipse.statet.ecommons.ui.util.UIAccess;
+@NonNullByDefault
public class ResourceVariableUtil implements ResourceVariableResolver.Context {
@@ -42,11 +46,11 @@
*
* @return selected resource or <code>null</code>
*/
- public static IResource fetchSelectedResource() {
+ public static @Nullable IResource fetchSelectedResource() {
return fetchSelectedResource(null);
}
- private static IResource fetchSelectedResource(final IWorkbenchPart part) {
+ private static @Nullable IResource fetchSelectedResource(final @Nullable IWorkbenchPart part) {
// Compatible with DebugUITools.getSelectedResource
final Display display= UIAccess.getDisplay();
if (Thread.currentThread() == display.getThread()) {
@@ -55,7 +59,7 @@
else {
class DisplayRunnable implements Runnable {
- IResource resource;
+ @Nullable IResource resource;
@Override
public void run() {
@@ -69,7 +73,7 @@
}
}
- private static IResource getSelectedResource0(IWorkbenchPart part) {
+ private static @Nullable IResource getSelectedResource0(@Nullable IWorkbenchPart part) {
IResource resource= null;
if (part == null) {
final IWorkbenchPage page= UIAccess.getActiveWorkbenchPage(true);
@@ -112,11 +116,11 @@
private final IWorkbenchPage workbenchPage;
- private final IWorkbenchPart part;
+ private final @Nullable IWorkbenchPart part;
private byte state;
- private IResource resource;
+ private @Nullable IResource resource;
@@ -134,13 +138,13 @@
this.part= part;
}
- public ResourceVariableUtil(final IResource resource) {
+ public ResourceVariableUtil(final @Nullable IResource resource) {
this();
this.state|= S_RESOURCE_FETCHED;
this.resource= resource;
}
- public ResourceVariableUtil(final ResourceVariableUtil location, final IResource resource) {
+ public ResourceVariableUtil(final ResourceVariableUtil location, final @Nullable IResource resource) {
this.workbenchPage= location.getWorkbenchPage();
this.part= location.getWorkbenchPart();
this.state|= S_RESOURCE_FETCHED;
@@ -152,12 +156,12 @@
return this.workbenchPage;
}
- public IWorkbenchPart getWorkbenchPart() {
+ public @Nullable IWorkbenchPart getWorkbenchPart() {
return this.part;
}
@Override
- public IResource getResource() {
+ public @Nullable IResource getResource() {
if ((this.state & S_RESOURCE_FETCHED) == 0) {
this.state|= S_RESOURCE_FETCHED;
this.resource= fetchResource();
@@ -170,7 +174,7 @@
this.resource= null;
}
- protected IResource fetchResource() {
+ protected @Nullable IResource fetchResource() {
return fetchSelectedResource(getWorkbenchPart());
}