Mark RunProfile.getName as NotNull

A lot of clients not ready that name can be null and in most cases it is not convenient - just add more work to handle null value

In any case for run configuration empty name it is the same as null, we don't need to bother clients and use null
This commit is contained in:
Vladimir Krivosheev
2018-09-05 17:53:09 +02:00
parent 6444340048
commit e0a03f51eb
12 changed files with 22 additions and 44 deletions

View File

@@ -219,6 +219,7 @@ public abstract class TestDiscoveryConfigurationProducer extends JavaRunConfigur
return createProfile(myTestMethods, myModule, myConfiguration, environment);
}
@NotNull
@Override
public String getName() {
return myConfigurationName;
@@ -248,7 +249,7 @@ public abstract class TestDiscoveryConfigurationProducer extends JavaRunConfigur
}
@Override
public void setName(@Nullable String name) {
public void setName(@NotNull String name) {
}
@NotNull

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.javadoc;
import com.google.common.collect.Streams;
@@ -71,6 +71,7 @@ public class JavadocGeneratorRunProfile implements ModuleRunProfile {
return new MyJavaCommandLineState(myConfiguration, myProject, myGenerationScope, env);
}
@NotNull
@Override
public String getName() {
return JavadocBundle.message("javadoc.settings.title");

View File

@@ -47,7 +47,6 @@ import com.intellij.util.ui.UIUtil;
import com.intellij.xdebugger.*;
import com.sun.jdi.Location;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.ArrayList;
@@ -509,7 +508,7 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas
}
@Override
public void setName(@Nullable String name) { }
public void setName(@NotNull String name) { }
@NotNull
@Override
@@ -532,6 +531,7 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas
return null;
}
@NotNull
@Override
public String getName() {
return "";

View File

@@ -194,7 +194,7 @@ abstract class RunManager {
*/
fun setUniqueNameIfNeed(configuration: RunConfiguration): Boolean {
val oldName = configuration.name
configuration.name = suggestUniqueName(StringUtil.notNullize(oldName, UNNAMED), configuration.type)
configuration.setName(suggestUniqueName(StringUtil.notNullize(oldName, UNNAMED), configuration.type))
return oldName != configuration.name
}

View File

@@ -48,10 +48,8 @@ public interface RunConfiguration extends RunProfile, Cloneable {
/**
* Sets the name of the configuration.
*
* @param name the new name of the configuration.
*/
void setName(@Nullable String name);
void setName(@NotNull String name);
/**
* Returns the UI control for editing the run configuration settings. If additional control over validation is required, the object

View File

@@ -15,7 +15,6 @@ import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizerUtil;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.util.text.StringUtilRt;
import com.intellij.util.ReflectionUtil;
import com.intellij.util.SmartList;
@@ -85,8 +84,8 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements
}
@Override
public final void setName(@Nullable String name) {
myName = StringUtil.nullize(name);
public final void setName(@NotNull String name) {
myName = name;
}
@NotNull
@@ -101,10 +100,12 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements
return myFactory == null ? null : myFactory.getIcon();
}
@NotNull
@Override
@Transient
public final String getName() {
// todo is clients ready for null?
// a lot of clients not ready that name can be null and in most cases it is not convenient - just add more work to handle null value
// in any case for run configuration empty name it is the same as null, we don't need to bother clients and use null
return StringUtilRt.notNullize(myName);
}

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.configurations;
import com.intellij.execution.ExecutionException;
@@ -46,6 +32,7 @@ public interface RunProfile {
*
* @return the name of the run configuration.
*/
@NotNull
String getName();
/**

View File

@@ -55,7 +55,7 @@ public class UnknownRunConfiguration implements RunConfiguration, WithoutOwnBefo
}
@Override
public void setName(@Nullable final String name) {
public void setName(@NotNull final String name) {
myName = name;
}
@@ -89,12 +89,12 @@ public class UnknownRunConfiguration implements RunConfiguration, WithoutOwnBefo
throw new ExecutionException("Unknown run configuration type" + (factoryName.isEmpty() ? "" : " " + factoryName));
}
@NotNull
@Override
public String getName() {
if (myName == null) {
myName = String.format("Unknown%s", myUniqueName.getAndAdd(1));
}
return myName;
}

View File

@@ -28,6 +28,7 @@ public class RunAnythingRunProfile implements RunProfile {
return new RunAnythingRunProfileState(environment, myOriginalCommand);
}
@NotNull
@Override
public String getName() {
return myOriginalCommand;

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.tools;
import com.intellij.execution.ExecutionException;
@@ -59,6 +45,7 @@ public class ToolRunProfile implements ModuleRunProfile{
//}
}
@NotNull
@Override
public String getName() {
return expandMacrosInName(myTool, myContext);

View File

@@ -200,6 +200,7 @@ public abstract class AbstractImportTestsAction extends AnAction {
throw new ExecutionException("Unable to run the configuration: failed to detect test framework");
}
@NotNull
@Override
public String getName() {
return myImported && myConfiguration != null ? myConfiguration.getName() : myFile.getNameWithoutExtension();

View File

@@ -364,6 +364,7 @@ public final class PreviewFormAction extends AnAction{
};
}
@NotNull
@Override
public String getName() {
return UIDesignerBundle.message("title.form.preview");