[platform] annotate some String parameters and methods with @NonNls

GitOrigin-RevId: 38e5366e0ecd3b9a31038836320639f7663606bf
This commit is contained in:
nik
2019-12-27 12:45:22 +03:00
committed by intellij-monorepo-bot
parent 5406669f39
commit 2b60c45994
13 changed files with 73 additions and 58 deletions

View File

@@ -18,6 +18,7 @@ import com.intellij.util.containers.DistinctRootsCollection;
import com.intellij.util.io.URLUtil;
import com.intellij.util.lang.UrlClassLoader;
import com.intellij.util.text.StringFactory;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -74,7 +75,7 @@ public class VfsUtilCore {
/**
* @return {@code true} if {@code url} is located under one of {@code rootUrls} or equal to one of them
*/
public static boolean isUnder(@NotNull String url, @Nullable Collection<String> rootUrls) {
public static boolean isUnder(@NotNull @NonNls String url, @Nullable @NonNls Collection<String> rootUrls) {
if (rootUrls == null || rootUrls.isEmpty()) return false;
for (String excludesUrl : rootUrls) {
@@ -85,7 +86,7 @@ public class VfsUtilCore {
return false;
}
public static boolean isEqualOrAncestor(@NotNull String ancestorUrl, @NotNull String fileUrl) {
public static boolean isEqualOrAncestor(@NotNull @NonNls String ancestorUrl, @NotNull @NonNls String fileUrl) {
if (ancestorUrl.equals(fileUrl)) return true;
if (StringUtil.endsWithChar(ancestorUrl, '/')) {
return fileUrl.startsWith(ancestorUrl);
@@ -239,7 +240,7 @@ public class VfsUtilCore {
* @throws IOException if file failed to be copied
*/
@NotNull
public static VirtualFile copyFile(Object requestor, @NotNull VirtualFile file, @NotNull VirtualFile toDir, @NotNull String newName) throws IOException {
public static VirtualFile copyFile(Object requestor, @NotNull VirtualFile file, @NotNull VirtualFile toDir, @NotNull @NonNls String newName) throws IOException {
VirtualFile newChild = toDir.createChildData(requestor, newName);
newChild.setBOM(file.getBOM());
newChild.setBinaryContent(file.contentsToByteArray(), -1, -1, requestor);

View File

@@ -16,6 +16,7 @@ import com.intellij.util.LineSeparator;
import com.intellij.util.text.CharArrayUtil;
import org.intellij.lang.annotations.MagicConstant;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -194,7 +195,7 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
* @param newName the new file name
* @throws IOException if file failed to be renamed
*/
public void rename(Object requestor, @NotNull String newName) throws IOException {
public void rename(Object requestor, @NotNull @NonNls String newName) throws IOException {
ApplicationManager.getApplication().assertWriteAccessAllowed();
if (getName().equals(newName)) return;
if (!getFileSystem().isValidName(newName)) {
@@ -295,7 +296,7 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
* @return the file if found any, {@code null} otherwise
*/
@Nullable
public VirtualFile findChild(@NotNull String name) {
public VirtualFile findChild(@NotNull @NonNls String name) {
VirtualFile[] children = getChildren();
if (children == null) return null;
for (VirtualFile child : children) {
@@ -307,7 +308,7 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
}
@NotNull
public VirtualFile findOrCreateChildData(Object requestor, @NotNull String name) throws IOException {
public VirtualFile findOrCreateChildData(Object requestor, @NotNull @NonNls String name) throws IOException {
final VirtualFile child = findChild(name);
if (child != null) return child;
return createChildData(requestor, name);
@@ -335,7 +336,7 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
* @return the file if found any, {@code null} otherwise
*/
@Nullable
public VirtualFile findFileByRelativePath(@NotNull String relPath) {
public VirtualFile findFileByRelativePath(@NotNull @NonNls String relPath) {
VirtualFile child = this;
int off = CharArrayUtil.shiftForward(relPath, 0, "/");
@@ -375,7 +376,7 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
* @throws IOException if directory failed to be created
*/
@NotNull
public VirtualFile createChildDirectory(Object requestor, @NotNull String name) throws IOException {
public VirtualFile createChildDirectory(Object requestor, @NotNull @NonNls String name) throws IOException {
if (!isDirectory()) {
throw new IOException(VfsBundle.message("directory.create.wrong.parent.error"));
}
@@ -406,7 +407,7 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
* @throws IOException if file failed to be created
*/
@NotNull
public VirtualFile createChildData(Object requestor, @NotNull String name) throws IOException {
public VirtualFile createChildData(Object requestor, @NotNull @NonNls String name) throws IOException {
if (!isDirectory()) {
throw new IOException(VfsBundle.message("file.create.wrong.parent.error"));
}
@@ -465,7 +466,7 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
}
@NotNull
public VirtualFile copy(final Object requestor, @NotNull final VirtualFile newParent, @NotNull final String copyName) throws IOException {
public VirtualFile copy(final Object requestor, @NotNull final VirtualFile newParent, @NotNull @NonNls String copyName) throws IOException {
if (getFileSystem() != newParent.getFileSystem()) {
throw new IOException(VfsBundle.message("file.copy.error", newParent.getPresentableUrl()));
}
@@ -673,7 +674,7 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
* @return whether file name equals to this name
* result depends on the filesystem specifics
*/
protected boolean nameEquals(@NotNull String name) {
protected boolean nameEquals(@NotNull @NonNls String name) {
return Comparing.equal(getNameSequence(), name);
}

View File

@@ -47,13 +47,13 @@ public interface ConfigurationType extends PossiblyDumbAware {
* The ID is used to store run configuration settings in a project or workspace file and
* must not change between plugin versions.
*/
@NotNull
@NotNull @NonNls
String getId();
/**
* The name of the run configuration group in a configuration file. The same rules as for id. Useful when id cannot be changed.
*/
@NotNull
@NotNull @NonNls
default String getTag() {
return getId();
}

View File

@@ -27,6 +27,7 @@ import com.intellij.openapi.util.ActionCallback;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentManager;
import com.intellij.ui.content.ContentManagerListener;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -50,15 +51,15 @@ public interface RunnerLayoutUi {
Content addContent(@NotNull Content content, int defaultTabId, @NotNull PlaceInGrid defaultPlace, boolean defaultIsMinimized);
@NotNull
Content createContent(@NotNull String contentId, @NotNull JComponent component, @NotNull String displayName, @Nullable Icon icon, @Nullable JComponent toFocus);
Content createContent(@NotNull @NonNls String contentId, @NotNull JComponent component, @NotNull String displayName, @Nullable Icon icon, @Nullable JComponent toFocus);
@NotNull
Content createContent(@NotNull String contentId, @NotNull ComponentWithActions contentWithActions, @NotNull String displayName, @Nullable Icon icon, @Nullable JComponent toFocus);
Content createContent(@NotNull @NonNls String contentId, @NotNull ComponentWithActions contentWithActions, @NotNull String displayName, @Nullable Icon icon, @Nullable JComponent toFocus);
boolean removeContent(@Nullable Content content, boolean dispose);
@Nullable
Content findContent(@NotNull String contentId);
Content findContent(@NotNull @NonNls String contentId);
@NotNull
ActionCallback selectAndFocus(@Nullable Content content, boolean requestFocus, final boolean forced);
@@ -70,8 +71,8 @@ public interface RunnerLayoutUi {
void removeListener(@NotNull final ContentManagerListener listener);
void attractBy(@NotNull String condition);
void clearAttractionBy(@NotNull String condition);
void attractBy(@NotNull @NonNls String condition);
void clearAttractionBy(@NotNull @NonNls String condition);
void setBouncing(@NotNull Content content, final boolean activate);

View File

@@ -1168,7 +1168,7 @@ public abstract class DialogWrapper {
*
* @return dimension service key
*/
@Nullable
@Nullable @NonNls
protected String getDimensionServiceKey() {
return null;
}

View File

@@ -16,6 +16,7 @@ import com.intellij.util.containers.JBIterable;
import com.intellij.util.execution.ParametersListUtil;
import com.intellij.util.text.CaseInsensitiveStringHashingStrategy;
import gnu.trove.THashMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
@@ -47,16 +48,16 @@ public final class ParametersList implements Cloneable {
private final List<ParamsGroup> myGroups = new SmartList<>();
private final NotNullLazyValue<Map<String, String>> myMacroMap = NotNullLazyValue.createValue(ParametersList::computeMacroMap);
public boolean hasParameter(@NotNull String parameter) {
public boolean hasParameter(@NotNull @NonNls String parameter) {
return myParameters.contains(parameter);
}
public boolean hasProperty(@NotNull String propertyName) {
public boolean hasProperty(@NotNull @NonNls String propertyName) {
return getPropertyValue(propertyName) != null;
}
@Nullable
public String getPropertyValue(@NotNull String propertyName) {
public String getPropertyValue(@NotNull @NonNls String propertyName) {
String exact = "-D" + propertyName;
String prefix = "-D" + propertyName + "=";
int index = indexOfParameter(o -> o.equals(exact) || o.startsWith(prefix));
@@ -71,7 +72,7 @@ public final class ParametersList implements Cloneable {
}
@NotNull
public Map<String, String> getProperties(String valueIfMissing) {
public Map<String, String> getProperties(@NonNls String valueIfMissing) {
Map<String, String> result = new LinkedHashMap<>();
JBIterable<Matcher> matchers = JBIterable.from(myParameters).map(PROPERTY_PATTERN::matcher).filter(Matcher::matches);
for (Matcher matcher : matchers) {
@@ -108,29 +109,29 @@ public final class ParametersList implements Cloneable {
myGroups.clear();
}
public void prepend(@NotNull String parameter) {
public void prepend(@NotNull @NonNls String parameter) {
addAt(0, parameter);
}
public void prependAll(@NotNull String... parameter) {
public void prependAll(@NotNull @NonNls String... parameter) {
addAll(parameter);
Collections.rotate(myParameters, parameter.length);
}
public void addParametersString(@Nullable String parameters) {
public void addParametersString(@Nullable @NonNls String parameters) {
if (StringUtil.isEmptyOrSpaces(parameters)) return;
for (String param : parse(parameters)) {
add(param);
}
}
public void add(@Nullable String parameter) {
public void add(@Nullable @NonNls String parameter) {
if (parameter == null) return;
myParameters.add(expandMacros(parameter));
}
@NotNull
public ParamsGroup addParamsGroup(@NotNull String groupId) {
public ParamsGroup addParamsGroup(@NotNull @NonNls String groupId) {
return addParamsGroup(new ParamsGroup(groupId));
}
@@ -147,7 +148,7 @@ public final class ParametersList implements Cloneable {
}
@NotNull
public ParamsGroup addParamsGroupAt(int index, @NotNull String groupId) {
public ParamsGroup addParamsGroupAt(int index, @NotNull @NonNls String groupId) {
ParamsGroup group = new ParamsGroup(groupId);
myGroups.add(index, group);
return group;
@@ -173,7 +174,7 @@ public final class ParametersList implements Cloneable {
}
@Nullable
public ParamsGroup getParamsGroup(@NotNull String name) {
public ParamsGroup getParamsGroup(@NotNull @NonNls String name) {
for (ParamsGroup group : myGroups) {
if (name.equals(group.getId())) return group;
}
@@ -185,21 +186,21 @@ public final class ParametersList implements Cloneable {
return myGroups.remove(index);
}
public void addAt(int index, @NotNull String parameter) {
public void addAt(int index, @NotNull @NonNls String parameter) {
myParameters.add(index, expandMacros(parameter));
}
/**
* Keeps the {@code <propertyName>} property if defined; or defines it with {@code System.getProperty()} as a value if present.
*/
public void defineSystemProperty(@NotNull String propertyName) {
public void defineSystemProperty(@NotNull @NonNls String propertyName) {
defineProperty(propertyName, System.getProperty(propertyName));
}
/**
* Keeps the {@code <propertyName>} property if defined; otherwise appends the new one ignoring null values.
*/
public void defineProperty(@NotNull String propertyName, @Nullable String propertyValue) {
public void defineProperty(@NotNull @NonNls String propertyName, @Nullable @NonNls String propertyValue) {
if (propertyValue == null) return;
String exact = "-D" + propertyName;
String prefix = "-D" + propertyName + "=";
@@ -212,7 +213,7 @@ public final class ParametersList implements Cloneable {
/**
* Adds {@code -D<propertyName>} to the list; replaces the value of the last property if defined.
*/
public void addProperty(@NotNull String propertyName) {
public void addProperty(@NotNull @NonNls String propertyName) {
String exact = "-D" + propertyName;
String prefix = "-D" + propertyName + "=";
replaceOrAddAt(exact, myParameters.size(), o -> o.equals(exact) || o.startsWith(prefix));
@@ -222,7 +223,7 @@ public final class ParametersList implements Cloneable {
* Adds {@code -D<propertyName>=<propertyValue>} to the list ignoring null values;
* replaces the value of the last property if defined.
*/
public void addProperty(@NotNull String propertyName, @Nullable String propertyValue) {
public void addProperty(@NotNull @NonNls String propertyName, @Nullable @NonNls String propertyValue) {
if (propertyValue == null) return;
String exact = "-D" + propertyName;
String prefix = "-D" + propertyName + "=";
@@ -234,7 +235,7 @@ public final class ParametersList implements Cloneable {
* Adds {@code -D<propertyName>=<propertyValue>} to the list ignoring null, empty and spaces-only values;
* replaces the value of the last property if defined.
*/
public void addNotEmptyProperty(@NotNull String propertyName, @Nullable String propertyValue) {
public void addNotEmptyProperty(@NotNull @NonNls String propertyName, @Nullable @NonNls String propertyValue) {
if (StringUtil.isEmptyOrSpaces(propertyValue)) return;
addProperty(propertyName, propertyValue);
}
@@ -243,7 +244,7 @@ public final class ParametersList implements Cloneable {
* Replaces the last parameter that starts with the {@code <parameterPrefix>} with {@code <replacement>};
* otherwise appends {@code <replacement>} to the list.
*/
public void replaceOrAppend(@NotNull String parameterPrefix, @NotNull String replacement) {
public void replaceOrAppend(@NotNull @NonNls String parameterPrefix, @NotNull @NonNls String replacement) {
replaceOrAddAt(expandMacros(replacement), myParameters.size(), o -> o.startsWith(parameterPrefix));
}
@@ -251,7 +252,7 @@ public final class ParametersList implements Cloneable {
* Replaces the last parameter that starts with the {@code <parameterPrefix>} with {@code <replacement>};
* otherwise prepends this list with {@code <replacement>}.
*/
public void replaceOrPrepend(@NotNull String parameterPrefix, @NotNull String replacement) {
public void replaceOrPrepend(@NotNull @NonNls String parameterPrefix, @NotNull @NonNls String replacement) {
replaceOrAddAt(expandMacros(replacement), 0, o -> o.startsWith(parameterPrefix));
}
@@ -271,11 +272,11 @@ public final class ParametersList implements Cloneable {
}
}
private int indexOfParameter(@NotNull Condition<? super String> condition) {
private int indexOfParameter(@NotNull @NonNls Condition<? super String> condition) {
return ContainerUtil.lastIndexOf(myParameters, condition);
}
public void set(int ind, @NotNull String value) {
public void set(int ind, @NotNull @NonNls String value) {
myParameters.set(ind, value);
}
@@ -288,16 +289,16 @@ public final class ParametersList implements Cloneable {
return myParameters.size() > 0 ? myParameters.get(myParameters.size() - 1) : null;
}
public void add(@NotNull String name, @NotNull String value) {
public void add(@NotNull @NonNls String name, @NotNull @NonNls String value) {
myParameters.add(name); // do not expand macros in parameter name
add(value);
}
public void addAll(@NotNull String... parameters) {
public void addAll(@NotNull @NonNls String... parameters) {
addAll(Arrays.asList(parameters));
}
public void addAll(@NotNull List<String> parameters) {
public void addAll(@NotNull @NonNls List<String> parameters) {
// Don't use myParameters.addAll(parameters) , it does not call expandMacros(parameter)
for (String parameter : parameters) {
add(parameter);
@@ -323,7 +324,7 @@ public final class ParametersList implements Cloneable {
* @see ParametersListUtil#join(List)
*/
@NotNull
public static String join(@NotNull List<String> parameters) {
public static String join(@NotNull @NonNls List<String> parameters) {
return ParametersListUtil.join(parameters);
}
@@ -331,7 +332,7 @@ public final class ParametersList implements Cloneable {
* @see ParametersListUtil#join(List)
*/
@NotNull
public static String join(@NotNull String... parameters) {
public static String join(@NotNull @NonNls String... parameters) {
return ParametersListUtil.join(parameters);
}
@@ -339,12 +340,12 @@ public final class ParametersList implements Cloneable {
* @see ParametersListUtil#parseToArray(String)
*/
@NotNull
public static String[] parse(@NotNull String string) {
public static String[] parse(@NotNull @NonNls String string) {
return ParametersListUtil.parseToArray(string);
}
@NotNull
public String expandMacros(@NotNull String text) {
public String expandMacros(@NotNull @NonNls String text) {
int start = text.indexOf("${");
if (start < 0) return text;
Map<String, String> macroMap = myMacroMap.getValue();
@@ -369,7 +370,7 @@ public final class ParametersList implements Cloneable {
private static Map<String, String> ourTestMacros;
@TestOnly
public static void setTestMacros(@Nullable Map<String, String> testMacros) {
public static void setTestMacros(@Nullable @NonNls Map<String, String> testMacros) {
ourTestMacros = testMacros;
}

View File

@@ -3,6 +3,7 @@ package com.intellij.openapi.components;
import com.intellij.openapi.util.Getter;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.lang.annotation.Retention;
@@ -16,7 +17,7 @@ public @interface State {
/**
* Component name.
*/
@NotNull
@NotNull @NonNls
String name();
/**

View File

@@ -2,6 +2,7 @@
package com.intellij.util.text;
import com.intellij.util.Function;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -118,11 +119,11 @@ public class VersionComparatorUtil {
* Examples: 1.0rc1 < 1.0release, 1.0 < 1.0.1, 1.1 > 1.02
* @return 0 if ver1 equals ver2, positive value if ver1 > ver2, negative value if ver1 < ver2
*/
public static int compare(@Nullable String ver1, @Nullable String ver2) {
public static int compare(@Nullable @NonNls String ver1, @Nullable @NonNls String ver2) {
return compare(ver1, ver2, DEFAULT_TOKEN_PRIORITY_PROVIDER);
}
public static int compare(@Nullable String ver1, @Nullable String ver2, Function<? super String, Integer> tokenPriorityProvider) {
public static int compare(@Nullable @NonNls String ver1, @Nullable @NonNls String ver2, Function<? super String, Integer> tokenPriorityProvider) {
// todo duplicates com.intellij.openapi.util.text.StringUtil.compareVersionNumbers()
// todo please refactor next time you make changes here
if (ver1 == null) {
@@ -162,7 +163,7 @@ public class VersionComparatorUtil {
return 0;
}
public static int comparePriorities(String ver1, String ver2, Function<? super String, Integer> tokenPriorityProvider) {
public static int comparePriorities(@NonNls String ver1, @NonNls String ver2, Function<? super String, Integer> tokenPriorityProvider) {
int priority1 = tokenPriorityProvider.fun(ver1);
int priority2 = tokenPriorityProvider.fun(ver2);

View File

@@ -15,6 +15,8 @@
*/
package com.intellij.util.xml;
import org.jetbrains.annotations.NonNls;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -33,5 +35,5 @@ public @interface Attribute {
/**
* XML attribute name if it can't be inferred from the getter name (see {@link NameStrategy}).
*/
String value() default "";
@NonNls String value() default "";
}

View File

@@ -15,6 +15,7 @@
*/
package com.intellij.util.xml;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -28,7 +29,7 @@ public interface GenericDomValue<T> extends DomElement, MutableGenericValue<T>{
@Override
@TagValue
void setStringValue(String value);
void setStringValue(@NonNls String value);
@Override
void setValue(T value);

View File

@@ -15,6 +15,8 @@
*/
package com.intellij.util.xml;
import org.jetbrains.annotations.NonNls;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -30,7 +32,7 @@ public @interface SubTag {
/**
* @return child XML tag name if it can't be inferred from the getter name (see {@link com.intellij.util.xml.NameStrategy})
*/
String value() default "";
@NonNls String value() default "";
/**
* @return if there are several child XML tags with the same name (e.g. always 2), the number of the child tag we should deal with

View File

@@ -15,6 +15,8 @@
*/
package com.intellij.util.xml;
import org.jetbrains.annotations.NonNls;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@@ -33,5 +35,5 @@ public @interface SubTagList {
/**
* @return child XML tag name if it can't be inferred from the getter name (see {@link com.intellij.util.xml.NameStrategy})
*/
String value() default "";
@NonNls String value() default "";
}

View File

@@ -15,6 +15,8 @@
*/
package com.intellij.util.xml;
import org.jetbrains.annotations.NonNls;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@@ -33,6 +35,6 @@ import java.lang.annotation.ElementType;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface SubTagsList {
String[] value();
String tagName() default "";
@NonNls String[] value();
@NonNls String tagName() default "";
}