From b1e8b301eecc6a686145e324489d8a61b5a7f3e8 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 27 Oct 2020 14:19:02 +0100 Subject: [PATCH] Cleanup (missing annotations; formatting) GitOrigin-RevId: 54745a667f128cd1d639da8e2e8db581ccb68b2d --- .../intellij/openapi/util/BuildNumber.java | 37 +++++---------- .../src/com/intellij/util/LocalFileUrl.java | 31 +++++------- .../src/com/intellij/util/Url.java | 26 ++++------ .../src/com/intellij/util/UrlImpl.java | 47 ++++++------------- 4 files changed, 49 insertions(+), 92 deletions(-) diff --git a/platform/core-api/src/com/intellij/openapi/util/BuildNumber.java b/platform/core-api/src/com/intellij/openapi/util/BuildNumber.java index 10210342667b..9f8efa20c20d 100644 --- a/platform/core-api/src/com/intellij/openapi/util/BuildNumber.java +++ b/platform/core-api/src/com/intellij/openapi/util/BuildNumber.java @@ -19,7 +19,7 @@ public final class BuildNumber implements Comparable { public static final int SNAPSHOT_VALUE = Integer.MAX_VALUE; - @NotNull private final String myProductCode; + private final @NotNull String myProductCode; private final int @NotNull [] myComponents; public BuildNumber(@NotNull String productCode, int baselineVersion, int buildNumber) { @@ -35,8 +35,7 @@ public final class BuildNumber implements Comparable { return "__BUILD_NUMBER__".equals(value) || "__BUILD__".equals(value); } - @NotNull - public String getProductCode() { + public @NotNull String getProductCode() { return myProductCode; } @@ -57,31 +56,24 @@ public final class BuildNumber implements Comparable { return false; } - @NotNull @Contract(pure = true) - public BuildNumber withoutProductCode() { + public @NotNull BuildNumber withoutProductCode() { return myProductCode.isEmpty() ? this : new BuildNumber("", myComponents); } - @NotNull - @NlsSafe - public String asString() { + public @NotNull @NlsSafe String asString() { return asString(true, true); } - @NotNull - @NlsSafe - public String asStringWithoutProductCode() { + public @NotNull @NlsSafe String asStringWithoutProductCode() { return asString(false, true); } - @NotNull - public String asStringWithoutProductCodeAndSnapshot() { + public @NotNull String asStringWithoutProductCodeAndSnapshot() { return asString(false, false); } - @NotNull - private String asString(boolean includeProductCode, boolean withSnapshotMarker) { + private @NotNull String asString(boolean includeProductCode, boolean withSnapshotMarker) { StringBuilder builder = new StringBuilder(); if (includeProductCode && !myProductCode.isEmpty()) { @@ -107,19 +99,17 @@ public final class BuildNumber implements Comparable { * Attempts to parse build number from the specified string. * Returns {@code null} if the string is not a valid build number. */ - @Nullable - public static BuildNumber fromStringOrNull(@NotNull @NonNls String version) { + public static @Nullable BuildNumber fromStringOrNull(@NotNull @NonNls String version) { try { return fromString(version); - } catch (RuntimeException ignored) { + } + catch (RuntimeException ignored) { return null; } } public static @Nullable BuildNumber fromString(@Nullable @NonNls String version) { - if (version == null) { - return null; - } + if (version == null) return null; version = version.trim(); return version.isEmpty() ? null : fromString(version, null, null); } @@ -292,8 +282,7 @@ public final class BuildNumber implements Comparable { * This method is for internal platform use only. In regular code use {@link com.intellij.openapi.application.ApplicationInfo#getBuild()} instead. */ @ApiStatus.Internal - @NotNull - public static BuildNumber currentVersion() { + public static @NotNull BuildNumber currentVersion() { return Holder.CURRENT_VERSION; } -} \ No newline at end of file +} diff --git a/platform/platform-util-io/src/com/intellij/util/LocalFileUrl.java b/platform/platform-util-io/src/com/intellij/util/LocalFileUrl.java index 5c3fed373942..a6f10fe59127 100644 --- a/platform/platform-util-io/src/com/intellij/util/LocalFileUrl.java +++ b/platform/platform-util-io/src/com/intellij/util/LocalFileUrl.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 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-2020 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.util; import com.intellij.openapi.util.text.StringUtil; @@ -10,27 +10,23 @@ import java.util.Map; public final class LocalFileUrl implements Url { private final String path; - /** - * Use {@link Urls#newLocalFileUrl(String)} instead - */ + /** Use {@link Urls#newLocalFileUrl(String)} instead */ public LocalFileUrl(@NotNull String path) { this.path = path; } @Override - public Url resolve(@NotNull String subPath) { + public @NotNull Url resolve(@NotNull String subPath) { return new LocalFileUrl(path.isEmpty() ? subPath : (path + "/" + subPath)); } - @NotNull @Override - public Url addParameters(@NotNull Map parameters) { + public @NotNull Url addParameters(@NotNull Map parameters) { throw new UnsupportedOperationException("File URL doesn't support parameters"); } - @NotNull @Override - public String getPath() { + public @NotNull String getPath() { return path; } @@ -44,33 +40,28 @@ public final class LocalFileUrl implements Url { return path; } - @NotNull @Override - public String toExternalForm() { + public @NotNull String toExternalForm() { return path; } - @Nullable @Override - public String getScheme() { + public @Nullable String getScheme() { return null; } - @Nullable @Override - public String getAuthority() { + public @Nullable String getAuthority() { return null; } - @Nullable @Override - public String getParameters() { + public @Nullable String getParameters() { return null; } - @NotNull @Override - public Url trimParameters() { + public @NotNull Url trimParameters() { return this; } @@ -103,4 +94,4 @@ public final class LocalFileUrl implements Url { public int hashCodeCaseInsensitive() { return StringUtil.stringHashCodeInsensitive(path); } -} \ No newline at end of file +} diff --git a/platform/platform-util-io/src/com/intellij/util/Url.java b/platform/platform-util-io/src/com/intellij/util/Url.java index 5533bdf7bf1e..6c00ec6c2c64 100644 --- a/platform/platform-util-io/src/com/intellij/util/Url.java +++ b/platform/platform-util-io/src/com/intellij/util/Url.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 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-2020 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.util; import com.intellij.openapi.util.NlsSafe; @@ -15,40 +15,34 @@ public interface Url { /** * System-independent path */ - @NotNull - String getPath(); + @NotNull String getPath(); @Contract(pure = true) boolean isInLocalFileSystem(); @NlsSafe String toDecodedForm(); - @NotNull - String toExternalForm(); + @NotNull String toExternalForm(); - @Nullable - String getScheme(); + @Nullable String getScheme(); - @Nullable - String getAuthority(); + @Nullable String getAuthority(); - @Nullable - String getParameters(); + @Nullable String getParameters(); boolean equalsIgnoreParameters(@Nullable Url url); boolean equalsIgnoreCase(@Nullable Url url); - @NotNull - Url trimParameters(); + @NotNull Url trimParameters(); int hashCodeCaseInsensitive(); - Url resolve(@NotNull String subPath); + @NotNull Url resolve(@NotNull String subPath); /** * Creates a new url with added parameters. */ - @NotNull - Url addParameters(@NotNull Map parameters); + @Contract(pure = true) + @NotNull Url addParameters(@NotNull Map parameters); } diff --git a/platform/platform-util-io/src/com/intellij/util/UrlImpl.java b/platform/platform-util-io/src/com/intellij/util/UrlImpl.java index d846ce4cff71..ae5fb447ef7c 100644 --- a/platform/platform-util-io/src/com/intellij/util/UrlImpl.java +++ b/platform/platform-util-io/src/com/intellij/util/UrlImpl.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 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-2020 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.util; import com.intellij.openapi.util.text.StringUtil; @@ -20,9 +20,7 @@ public final class UrlImpl implements Url { private String externalForm; private UrlImpl withoutParameters; - /** - * @deprecated Use {@link Urls#newUnparsable(String)} - */ + /** @deprecated Use {@link Urls#newUnparsable(String)} */ @Deprecated public UrlImpl(@NotNull String path) { this(null, null, path, null); @@ -40,13 +38,12 @@ public final class UrlImpl implements Url { } @Override - public Url resolve(@NotNull String subPath) { + public @NotNull Url resolve(@NotNull String subPath) { return new UrlImpl(scheme, authority, path.isEmpty() ? subPath : (path + "/" + subPath), parameters); } - @NotNull @Override - public Url addParameters(@NotNull Map parameters) { + public @NotNull Url addParameters(@NotNull Map parameters) { if (parameters.isEmpty()) { return this; } @@ -63,24 +60,21 @@ public final class UrlImpl implements Url { return new UrlImpl(scheme, authority, path, builder.toString()); } - @NotNull @Override - public String getPath() { + public @NotNull String getPath() { if (decodedPath == null) { decodedPath = URLUtil.unescapePercentSequences(path); } return decodedPath; } - @Nullable @Override - public String getScheme() { + public @Nullable String getScheme() { return scheme; } @Override - @Nullable - public String getAuthority() { + public @Nullable String getAuthority() { return authority; } @@ -89,9 +83,8 @@ public final class UrlImpl implements Url { return URLUtil.FILE_PROTOCOL.equals(scheme); } - @Nullable @Override - public String getParameters() { + public @Nullable String getParameters() { return parameters; } @@ -119,8 +112,7 @@ public final class UrlImpl implements Url { } @Override - @NotNull - public String toExternalForm() { + public @NotNull String toExternalForm() { if (externalForm != null) { return externalForm; } @@ -142,8 +134,7 @@ public final class UrlImpl implements Url { } @Override - @NotNull - public Url trimParameters() { + public @NotNull Url trimParameters() { if (parameters == null) { return this; } @@ -160,12 +151,8 @@ public final class UrlImpl implements Url { @Override public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof UrlImpl)) { - return false; - } + if (this == o) return true; + if (!(o instanceof UrlImpl)) return false; UrlImpl url = (UrlImpl)o; return StringUtil.equals(scheme, url.scheme) && StringUtil.equals(authority, url.authority) && getPath().equals(url.getPath()) && StringUtil.equals(parameters, url.parameters); @@ -173,12 +160,8 @@ public final class UrlImpl implements Url { @Override public boolean equalsIgnoreCase(@Nullable Url o) { - if (this == o) { - return true; - } - if (!(o instanceof UrlImpl)) { - return false; - } + if (this == o) return true; + if (!(o instanceof UrlImpl)) return false; UrlImpl url = (UrlImpl)o; return StringUtil.equalsIgnoreCase(scheme, url.scheme) && @@ -213,4 +196,4 @@ public final class UrlImpl implements Url { public int hashCodeCaseInsensitive() { return computeHashCode(false); } -} \ No newline at end of file +}