From 1290e08cebe46b74b7e8cbdb940ba9a57530e821 Mon Sep 17 00:00:00 2001 From: develar Date: Mon, 29 Apr 2019 17:12:32 +0200 Subject: [PATCH] cleanup - notnull GitOrigin-RevId: 8e7186bd62c257a64315fa83e7cf9fc8f4e9ed33 --- .../navigation/JBProtocolNavigateCommand.kt | 2 +- .../application/JBProtocolCommand.java | 22 +++--------- .../JBProtocolShutdownCommand.java | 27 ++++----------- .../impl/JBProtocolOpenProjectCommand.java | 34 ++++++++----------- .../application/JetBrainsProtocolHandler.java | 21 +++--------- .../checkout/JBProtocolCheckoutCommand.java | 23 +++---------- 6 files changed, 37 insertions(+), 92 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/navigation/JBProtocolNavigateCommand.kt b/platform/lang-impl/src/com/intellij/navigation/JBProtocolNavigateCommand.kt index d1e1b6b26241..40dfdd130d7f 100644 --- a/platform/lang-impl/src/com/intellij/navigation/JBProtocolNavigateCommand.kt +++ b/platform/lang-impl/src/com/intellij/navigation/JBProtocolNavigateCommand.kt @@ -25,7 +25,7 @@ import com.intellij.openapi.wm.IdeFocusManager import java.io.File import java.util.regex.Pattern -class JBProtocolNavigateCommand : JBProtocolCommand(NAVIGATE_COMMAND) { +internal class JBProtocolNavigateCommand : JBProtocolCommand(NAVIGATE_COMMAND) { override fun perform(target: String, parameters: Map) { // handles URLs of the following types: diff --git a/platform/platform-impl/src/com/intellij/openapi/application/JBProtocolCommand.java b/platform/platform-impl/src/com/intellij/openapi/application/JBProtocolCommand.java index f48b440f1a29..a4c029535d75 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/JBProtocolCommand.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/JBProtocolCommand.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 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-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. package com.intellij.openapi.application; import com.intellij.openapi.extensions.ExtensionPointName; @@ -25,7 +11,7 @@ import java.util.Map; * @author Konstantin Bulenkov */ public abstract class JBProtocolCommand { - public static final ExtensionPointName EP_NAME = new ExtensionPointName<>("com.intellij.jbProtocolCommand"); + private static final ExtensionPointName EP_NAME = new ExtensionPointName<>("com.intellij.jbProtocolCommand"); private final String myCommand; public JBProtocolCommand(@NotNull String command) { @@ -37,12 +23,12 @@ public abstract class JBProtocolCommand { return myCommand; } - public abstract void perform(String target, Map parameters); + public abstract void perform(String target, @NotNull Map parameters); @Nullable public static JBProtocolCommand findCommand(@Nullable String commandName) { if (commandName != null) { - for (JBProtocolCommand command : EP_NAME.getExtensions()) { + for (JBProtocolCommand command : EP_NAME.getExtensionList()) { if (command.getCommandName().equals(commandName)) { return command; } diff --git a/platform/platform-impl/src/com/intellij/openapi/application/JBProtocolShutdownCommand.java b/platform/platform-impl/src/com/intellij/openapi/application/JBProtocolShutdownCommand.java index c463ee907d6e..8567eed53e2f 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/JBProtocolShutdownCommand.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/JBProtocolShutdownCommand.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 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-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. package com.intellij.openapi.application; import com.intellij.CommonBundle; @@ -20,23 +6,24 @@ import com.intellij.openapi.application.ex.ApplicationManagerEx; import com.intellij.openapi.ui.MessageDialogBuilder; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.text.StringUtil; +import org.jetbrains.annotations.NotNull; import java.util.Map; /** * @author Konstantin Bulenkov */ -public class JBProtocolShutdownCommand extends JBProtocolCommand { - - public JBProtocolShutdownCommand() { +final class JBProtocolShutdownCommand extends JBProtocolCommand { + JBProtocolShutdownCommand() { super("shutdown"); } @Override - public void perform(String target, Map parameters) { + public void perform(String target, @NotNull Map parameters) { if (StringUtil.isEmpty(target)) { ApplicationManager.getApplication().exit(); - } else { + } + else { MessageDialogBuilder.YesNo confirmExitDialog = MessageDialogBuilder.yesNo(ApplicationBundle.message("exit.confirm.title"), target) .yesText(ApplicationBundle.message("command.exit")).noText( CommonBundle.message("button.cancel")); diff --git a/platform/platform-impl/src/com/intellij/openapi/project/impl/JBProtocolOpenProjectCommand.java b/platform/platform-impl/src/com/intellij/openapi/project/impl/JBProtocolOpenProjectCommand.java index 9306509f500e..a879e31e280a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/impl/JBProtocolOpenProjectCommand.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/impl/JBProtocolOpenProjectCommand.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 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-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. package com.intellij.openapi.project.impl; import com.intellij.ide.impl.ProjectUtil; @@ -21,21 +7,31 @@ import com.intellij.openapi.application.JBProtocolCommand; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.LocalFileSystem; +import org.jetbrains.annotations.NotNull; +import java.io.UnsupportedEncodingException; import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.util.Map; /** * @author Konstantin Bulenkov */ -public class JBProtocolOpenProjectCommand extends JBProtocolCommand { - public JBProtocolOpenProjectCommand() { +final class JBProtocolOpenProjectCommand extends JBProtocolCommand { + JBProtocolOpenProjectCommand() { super("open"); } @Override - public void perform(String target, Map parameters) { - String path = URLDecoder.decode(target); + public void perform(String target, @NotNull Map parameters) { + String path; + try { + path = URLDecoder.decode(target, StandardCharsets.UTF_8.name()); + } + catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + String projectPath = StringUtil.trimStart(path, LocalFileSystem.PROTOCOL_PREFIX); ApplicationManager.getApplication().invokeLater( () -> ProjectUtil.openProject(projectPath, null, true), ModalityState.NON_MODAL); diff --git a/platform/util/src/com/intellij/openapi/application/JetBrainsProtocolHandler.java b/platform/util/src/com/intellij/openapi/application/JetBrainsProtocolHandler.java index d771b130938c..16c83f402704 100644 --- a/platform/util/src/com/intellij/openapi/application/JetBrainsProtocolHandler.java +++ b/platform/util/src/com/intellij/openapi/application/JetBrainsProtocolHandler.java @@ -1,22 +1,9 @@ -/* - * Copyright 2000-2016 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-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. package com.intellij.openapi.application; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Collections; @@ -64,7 +51,8 @@ public class JetBrainsProtocolHandler { } else { ourParameters.put(key, value); } - } else { + } + else { ourParameters.put(keyValue, ""); } } @@ -102,6 +90,7 @@ public class JetBrainsProtocolHandler { ourCommand = null; } + @NotNull public static Map getParameters() { init(); return Collections.unmodifiableMap(ourParameters); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/checkout/JBProtocolCheckoutCommand.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/checkout/JBProtocolCheckoutCommand.java index 0cd83adee2a5..f0cf24069d40 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/checkout/JBProtocolCheckoutCommand.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/checkout/JBProtocolCheckoutCommand.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 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-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. package com.intellij.openapi.vcs.checkout; import com.intellij.openapi.application.JBProtocolCommand; @@ -23,22 +9,23 @@ import com.intellij.openapi.vcs.CheckoutProvider; import com.intellij.openapi.vcs.CheckoutProviderEx; import com.intellij.openapi.vcs.ProjectLevelVcsManager; import com.intellij.ui.AppIcon; +import org.jetbrains.annotations.NotNull; import java.util.Map; /** * @author Konstantin Bulenkov */ -public class JBProtocolCheckoutCommand extends JBProtocolCommand { +final class JBProtocolCheckoutCommand extends JBProtocolCommand { private static final String REPOSITORY_NAME_KEY = "checkout.repo"; - public JBProtocolCheckoutCommand() { + JBProtocolCheckoutCommand() { super("checkout"); } @Override - public void perform(String vcsId, Map parameters) { + public void perform(String vcsId, @NotNull Map parameters) { String repository = parameters.get(REPOSITORY_NAME_KEY); if (StringUtil.isEmpty(repository)) {