From 2fec26eada624283f4b1d87d9cca899e52b48c71 Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Mon, 4 Jun 2018 21:43:37 +0300 Subject: [PATCH] [groovy] get rid of duplicate code in GrClosureType inheritors --- .../groovy/lang/psi/impl/GrClosureType.java | 6 ----- .../lang/psi/impl/GrLiteralClassType.java | 5 +++- .../groovy/lang/psi/impl/GrMapType.java | 22 +----------------- .../groovy/lang/psi/impl/GrRangeType.java | 23 +------------------ .../groovy/lang/psi/impl/GrTupleType.java | 23 +------------------ .../lang/psi/impl/LazyFqnClassType.java | 23 +------------------ 6 files changed, 8 insertions(+), 94 deletions(-) diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrClosureType.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrClosureType.java index 8cd2b1d8888d..fc5667ebb400 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrClosureType.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrClosureType.java @@ -57,12 +57,6 @@ public class GrClosureType extends GrLiteralClassType { myClosure = closure; } - @Override - @NotNull - public String getClassName() { - return "Closure"; - } - @Override public int getParameterCount() { PsiClass resolved = resolve(); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrLiteralClassType.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrLiteralClassType.java index a81c54be94e4..6d8b77889c53 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrLiteralClassType.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrLiteralClassType.java @@ -13,6 +13,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil; import static com.intellij.openapi.util.RecursionManager.doPreventingRecursion; +import static com.intellij.openapi.util.text.StringUtil.getShortName; /** * @author peter @@ -105,7 +106,9 @@ public abstract class GrLiteralClassType extends PsiClassType { @Override @NotNull - public abstract String getClassName() ; + public String getClassName() { + return getShortName(getJavaClassName()); + } @Override @NotNull diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrMapType.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrMapType.java index e76cc4f8d952..ee24aa28a4a5 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrMapType.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrMapType.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 org.jetbrains.plugins.groovy.lang.psi.impl; @@ -68,12 +54,6 @@ public abstract class GrMapType extends GrLiteralClassType { return GroovyCommonClassNames.JAVA_UTIL_LINKED_HASH_MAP; } - @Override - @NotNull - public String getClassName() { - return "LinkedHashMap"; - } - @Nullable public abstract PsiType getTypeByStringKey(String key); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrRangeType.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrRangeType.java index f86ea05460bf..400ff548aab2 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrRangeType.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrRangeType.java @@ -1,21 +1,6 @@ -/* - * Copyright 2000-2014 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 org.jetbrains.plugins.groovy.lang.psi.impl; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.JavaPsiFacade; import com.intellij.psi.PsiClass; @@ -68,12 +53,6 @@ public class GrRangeType extends GrLiteralClassType { return myQualifiedName; } - @NotNull - @Override - public String getClassName() { - return StringUtil.getShortName(myQualifiedName); - } - @NotNull @Override public PsiType[] getParameters() { diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrTupleType.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrTupleType.java index 1a7a4f9b64bb..42d82be60d36 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrTupleType.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrTupleType.java @@ -1,24 +1,9 @@ -/* - * Copyright 2000-2014 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 org.jetbrains.plugins.groovy.lang.psi.impl; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.VolatileNotNullLazyValue; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.CommonClassNames; import com.intellij.psi.JavaPsiFacade; @@ -68,12 +53,6 @@ public abstract class GrTupleType extends GrLiteralClassType { return CommonClassNames.JAVA_UTIL_LIST; } - @Override - @NotNull - public String getClassName() { - return StringUtil.getShortName(getJavaClassName()); - } - @Override @NotNull public PsiType[] getParameters() { diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/LazyFqnClassType.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/LazyFqnClassType.java index 5d6dac9217c4..68cdb36ed3ea 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/LazyFqnClassType.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/LazyFqnClassType.java @@ -1,21 +1,6 @@ -/* - * Copyright 2000-2014 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 org.jetbrains.plugins.groovy.lang.psi.impl; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.JavaPsiFacade; import com.intellij.psi.PsiClassType; @@ -42,12 +27,6 @@ public class LazyFqnClassType extends GrLiteralClassType { return myFqn; } - @NotNull - @Override - public String getClassName() { - return StringUtil.getShortName(myFqn); - } - @NotNull @Override public PsiType[] getParameters() {