From f7553da76ba1f7389052dae54dcbea2f080e767c Mon Sep 17 00:00:00 2001 From: Artem Khvastunov Date: Tue, 26 Jun 2018 19:13:22 +0200 Subject: [PATCH] clarify that ValueEditor#parseValue is supposed to throw exception --- .../CommaSeparatedIntegersValueEditor.java | 18 ++-------------- .../valueEditors/IntegerValueEditor.java | 18 ++-------------- .../fields/valueEditors/ValueEditor.java | 21 ++++--------------- 3 files changed, 8 insertions(+), 49 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/components/fields/valueEditors/CommaSeparatedIntegersValueEditor.java b/platform/platform-api/src/com/intellij/ui/components/fields/valueEditors/CommaSeparatedIntegersValueEditor.java index 10042169ced0..bd94cca63d7b 100644 --- a/platform/platform-api/src/com/intellij/ui/components/fields/valueEditors/CommaSeparatedIntegersValueEditor.java +++ b/platform/platform-api/src/com/intellij/ui/components/fields/valueEditors/CommaSeparatedIntegersValueEditor.java @@ -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.ui.components.fields.valueEditors; import com.intellij.openapi.util.InvalidDataException; @@ -37,7 +23,7 @@ public class CommaSeparatedIntegersValueEditor extends TextFieldValueEditor parseValue(@Nullable String text) { + public List parseValue(@Nullable String text) throws InvalidDataException { if (text == null || text.isEmpty()) return Collections.emptyList(); String[] chunks = text.split("\\s*,\\s*"); List values = new ArrayList<>(chunks.length); diff --git a/platform/platform-api/src/com/intellij/ui/components/fields/valueEditors/IntegerValueEditor.java b/platform/platform-api/src/com/intellij/ui/components/fields/valueEditors/IntegerValueEditor.java index 371d2c8792d7..ae1584d93e8c 100644 --- a/platform/platform-api/src/com/intellij/ui/components/fields/valueEditors/IntegerValueEditor.java +++ b/platform/platform-api/src/com/intellij/ui/components/fields/valueEditors/IntegerValueEditor.java @@ -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.ui.components.fields.valueEditors; import com.intellij.openapi.application.ApplicationBundle; @@ -34,7 +20,7 @@ public class IntegerValueEditor extends TextFieldValueEditor { @NotNull @Override - public Integer parseValue(@Nullable String text) { + public Integer parseValue(@Nullable String text) throws InvalidDataException { try { if (StringUtil.isEmpty(text)) { if (!myCanBeEmpty) { diff --git a/platform/platform-api/src/com/intellij/ui/components/fields/valueEditors/ValueEditor.java b/platform/platform-api/src/com/intellij/ui/components/fields/valueEditors/ValueEditor.java index e2cb70223583..b4635068641a 100644 --- a/platform/platform-api/src/com/intellij/ui/components/fields/valueEditors/ValueEditor.java +++ b/platform/platform-api/src/com/intellij/ui/components/fields/valueEditors/ValueEditor.java @@ -1,22 +1,9 @@ -/* - * 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.ui.components.fields.valueEditors; import com.intellij.openapi.options.Configurable; import com.intellij.openapi.options.ConfigurationException; +import com.intellij.openapi.util.InvalidDataException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -67,10 +54,10 @@ public interface ValueEditor { * Try parsing the text and convert it to the object of type T. Throw InvalidDataException if parsing fails. * @param text The text to parse. * @return Parsed data. - * @throws com.intellij.openapi.util.InvalidDataException if parsing fails. + * @throws InvalidDataException if parsing fails. */ @NotNull - T parseValue(@Nullable String text); + T parseValue(@Nullable String text) throws InvalidDataException; /** * Convert the value to an equivalent text string.