From cbbaa8141460ddb6f82d38969827baed22dbed0e Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 24 Nov 2017 17:15:45 +0100 Subject: [PATCH] Cleanup (docs; formatting; arrangement) --- .../configurations/ParametersList.java | 51 +++++++------------ .../execution/configurations/ParamsGroup.java | 30 +++-------- 2 files changed, 26 insertions(+), 55 deletions(-) diff --git a/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java b/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java index 279149f50d84..0a01f293c382 100644 --- a/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java +++ b/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2013 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-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. package com.intellij.execution.configurations; import com.intellij.openapi.application.Application; @@ -40,32 +26,25 @@ import java.util.regex.Pattern; /** * A list of command-line parameters featuring the following: * - * + * * @see ParametersList#defineProperty(String, String) - * @see ParametersList#expandMacros(String) - * @see ParametersList#addParamsGroup(String) - * @see ParametersList#addParametersString(String) - * @see ParamsGroup + * @see ParametersList#expandMacros(String) + * @see ParametersList#addParamsGroup(String) + * @see ParametersList#addParametersString(String) + * @see ParamsGroup */ public final class ParametersList implements Cloneable { - private static final Pattern PROPERTY_PATTERN = Pattern.compile("-D(\\S+?)(?:=(.+))?"); private static final Pattern MACRO_PATTERN = Pattern.compile("\\$\\{([^}]+)}"); - private static Map ourTestMacros; private final List myParameters = new ArrayList<>(); private final List myGroups = new SmartList<>(); private final NotNullLazyValue> myMacroMap = NotNullLazyValue.createValue(ParametersList::computeMacroMap); - - @TestOnly - public static void setTestMacros(@Nullable Map testMacros) { - ourTestMacros = testMacros; - } public boolean hasParameter(@NotNull String parameter) { return myParameters.contains(parameter); @@ -74,7 +53,7 @@ public final class ParametersList implements Cloneable { public boolean hasProperty(@NotNull String propertyName) { return getPropertyValue(propertyName) != null; } - + @Nullable public String getPropertyValue(@NotNull String propertyName) { String exact = "-D" + propertyName; @@ -87,7 +66,7 @@ public final class ParametersList implements Cloneable { @NotNull public Map getProperties() { - LinkedHashMap result = new LinkedHashMap<>(); + Map result = new LinkedHashMap<>(); JBIterable matchers = JBIterable.from(myParameters).map(PROPERTY_PATTERN::matcher).filter(Matcher::matches); for (Matcher matcher : matchers) { result.put(matcher.group(1), StringUtil.notNullize(matcher.group(2), "")); @@ -271,7 +250,7 @@ public final class ParametersList implements Cloneable { } private void replaceOrAddAt(@NotNull String replacement, - int position, + int position, @NotNull Condition existingCondition) { int index = indexOfParameter(existingCondition); boolean setNewValue = StringUtil.isNotEmpty(replacement); @@ -377,6 +356,13 @@ public final class ParametersList implements Cloneable { return sb == null ? text : sb.append(text, start, text.length()).toString(); } + private static Map ourTestMacros; + + @TestOnly + public static void setTestMacros(@Nullable Map testMacros) { + ourTestMacros = testMacros; + } + @NotNull private static Map computeMacroMap() { // ApplicationManager.getApplication() will return null if executed in ParameterListTest @@ -402,5 +388,4 @@ public final class ParametersList implements Cloneable { public String toString() { return myParameters + (myGroups.isEmpty() ? "" : " and " + myGroups); } - -} +} \ No newline at end of file diff --git a/platform/platform-api/src/com/intellij/execution/configurations/ParamsGroup.java b/platform/platform-api/src/com/intellij/execution/configurations/ParamsGroup.java index 5eaf5f65d75f..c7fae96614d7 100644 --- a/platform/platform-api/src/com/intellij/execution/configurations/ParamsGroup.java +++ b/platform/platform-api/src/com/intellij/execution/configurations/ParamsGroup.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2011 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-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. package com.intellij.execution.configurations; import org.jetbrains.annotations.NotNull; @@ -20,14 +6,14 @@ import org.jetbrains.annotations.NotNull; import java.util.List; /** - * @author Roman.Chernyatchik - * * Group of linked params. Sometime it's much more convenient to split cmdline in logical groups. - * In this case it will be easier to patch such grouped argements using custom extentions + * In this case it will be easier to patch such grouped arguments using custom extensions. * - * E.g.: we want to add Coverage support to all existing Ruby run configurations(ruby applications, - * different kinds of ruby tests, rails configuration, etc). Coverage support require to reorder args - * in cmdline, add rcov runner script, etc. Without groups it would be harder to parse abstract list of arguments + * E.g.: we want to add Coverage support to all existing Ruby run configurations (Ruby applications, + * different kinds of tests, Rails configuration, etc). Adding coverage support requires reordering args + * in command line, adding RCov runner script, etc. Without groups it would be harder to parse abstract list of arguments. + * + * @author Roman.Chernyatchik */ public final class ParamsGroup implements Cloneable { @@ -90,4 +76,4 @@ public final class ParamsGroup implements Cloneable { public String toString() { return myGroupId + ":" + myParamList; } -} +} \ No newline at end of file