From 2a6d11af1b2bcb7500504d797c2a247ef8085497 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 30 Aug 2018 21:06:36 +0300 Subject: [PATCH] Cleanup (inlines needlessly extracted core classes) --- java/java-impl/src/META-INF/JavaPlugin.xml | 1 - .../psi/impl/source/tree/JavaASTFactory.java | 34 ----------- .../src/META-INF/JavaPsiPlugin.xml | 1 + .../core/JavaCoreApplicationEnvironment.java | 23 ++----- .../javadoc/CorePsiDocTagValueImpl.java | 54 ---------------- .../source/javadoc/PsiDocTagValueImpl.java | 61 ++++++++++++------- ...avaASTFactory.java => JavaASTFactory.java} | 27 +++----- 7 files changed, 50 insertions(+), 151 deletions(-) delete mode 100644 java/java-impl/src/com/intellij/psi/impl/source/tree/JavaASTFactory.java delete mode 100644 java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/CorePsiDocTagValueImpl.java rename java/java-psi-impl/src/com/intellij/psi/impl/source/tree/{CoreJavaASTFactory.java => JavaASTFactory.java} (65%) diff --git a/java/java-impl/src/META-INF/JavaPlugin.xml b/java/java-impl/src/META-INF/JavaPlugin.xml index 07bcc1d19bf3..e987d111610f 100644 --- a/java/java-impl/src/META-INF/JavaPlugin.xml +++ b/java/java-impl/src/META-INF/JavaPlugin.xml @@ -479,7 +479,6 @@ - diff --git a/java/java-impl/src/com/intellij/psi/impl/source/tree/JavaASTFactory.java b/java/java-impl/src/com/intellij/psi/impl/source/tree/JavaASTFactory.java deleted file mode 100644 index af52572abe40..000000000000 --- a/java/java-impl/src/com/intellij/psi/impl/source/tree/JavaASTFactory.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2000-2012 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. - */ -package com.intellij.psi.impl.source.tree; - -import com.intellij.psi.impl.source.javadoc.PsiDocTagValueImpl; -import com.intellij.psi.tree.IElementType; -import org.jetbrains.annotations.NotNull; - -/** - * @author max - */ -public class JavaASTFactory extends CoreJavaASTFactory { - @Override - public CompositeElement createComposite(@NotNull final IElementType type) { - if (type == JavaDocElementType.DOC_TAG_VALUE_ELEMENT) { - return new PsiDocTagValueImpl(); - } - - return null; - } -} diff --git a/java/java-psi-impl/src/META-INF/JavaPsiPlugin.xml b/java/java-psi-impl/src/META-INF/JavaPsiPlugin.xml index ec9b388163f0..a716aad9aeb3 100644 --- a/java/java-psi-impl/src/META-INF/JavaPsiPlugin.xml +++ b/java/java-psi-impl/src/META-INF/JavaPsiPlugin.xml @@ -114,6 +114,7 @@ + diff --git a/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java b/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java index 58d890c32088..17f42ba1143b 100644 --- a/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java +++ b/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.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.core; import com.intellij.codeInsight.ContainerProvider; @@ -33,7 +19,6 @@ import com.intellij.openapi.Disposable; import com.intellij.openapi.fileTypes.PlainTextFileType; import com.intellij.openapi.fileTypes.PlainTextLanguage; import com.intellij.openapi.fileTypes.PlainTextParserDefinition; -import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.JavaVersionService; import com.intellij.psi.*; import com.intellij.psi.impl.EmptySubstitutorImpl; @@ -42,7 +27,7 @@ import com.intellij.psi.impl.PsiExpressionEvaluator; import com.intellij.psi.impl.compiled.ClassFileStubBuilder; import com.intellij.psi.impl.file.PsiPackageImplementationHelper; import com.intellij.psi.impl.search.MethodSuperSearcher; -import com.intellij.psi.impl.source.tree.CoreJavaASTFactory; +import com.intellij.psi.impl.source.tree.JavaASTFactory; import com.intellij.psi.impl.source.tree.PlainTextASTFactory; import com.intellij.psi.presentation.java.*; import com.intellij.psi.search.searches.SuperMethodsSearch; @@ -73,7 +58,7 @@ public class JavaCoreApplicationEnvironment extends CoreApplicationEnvironment { addExplicitExtension(FileTypeFileViewProviders.INSTANCE, JavaClassFileType.INSTANCE, new ClassFileViewProviderFactory()); addExplicitExtension(BinaryFileStubBuilders.INSTANCE, JavaClassFileType.INSTANCE, new ClassFileStubBuilder()); - addExplicitExtension(LanguageASTFactory.INSTANCE, JavaLanguage.INSTANCE, new CoreJavaASTFactory()); + addExplicitExtension(LanguageASTFactory.INSTANCE, JavaLanguage.INSTANCE, new JavaASTFactory()); addExplicitExtension(LanguageParserDefinitions.INSTANCE, JavaLanguage.INSTANCE, new JavaParserDefinition()); addExplicitExtension(LanguageConstantExpressionEvaluator.INSTANCE, JavaLanguage.INSTANCE, new PsiExpressionEvaluator()); @@ -113,4 +98,4 @@ public class JavaCoreApplicationEnvironment extends CoreApplicationEnvironment { protected CoreJavaDirectoryService createJavaDirectoryService() { return new CoreJavaDirectoryService(); } -} +} \ No newline at end of file diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/CorePsiDocTagValueImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/CorePsiDocTagValueImpl.java deleted file mode 100644 index a6f2d0bce0b7..000000000000 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/CorePsiDocTagValueImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2000-2012 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. - */ -package com.intellij.psi.impl.source.javadoc; - -import com.intellij.lang.ASTNode; -import com.intellij.psi.JavaDocTokenType; -import com.intellij.psi.JavaElementVisitor; -import com.intellij.psi.PsiElementVisitor; -import com.intellij.psi.impl.source.tree.ChildRole; -import com.intellij.psi.impl.source.tree.CompositePsiElement; -import com.intellij.psi.impl.source.tree.JavaDocElementType; -import com.intellij.psi.javadoc.PsiDocTagValue; -import org.jetbrains.annotations.NotNull; - -/** - * @author yole - */ -public class CorePsiDocTagValueImpl extends CompositePsiElement implements PsiDocTagValue { - public CorePsiDocTagValueImpl() { - super(JavaDocElementType.DOC_TAG_VALUE_ELEMENT); - } - - @Override - public void accept(@NotNull PsiElementVisitor visitor) { - if (visitor instanceof JavaElementVisitor) { - ((JavaElementVisitor)visitor).visitDocTagValue(this); - } - else { - visitor.visitElement(this); - } - } - - @Override - public int getChildRole(@NotNull ASTNode child) { - if (child.getElementType() == JavaDocTokenType.DOC_TAG_VALUE_COMMA) { - return ChildRole.COMMA; - } - - return super.getChildRole(child); - } -} diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocTagValueImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocTagValueImpl.java index eeb2fd2896f3..8171850ac156 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocTagValueImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocTagValueImpl.java @@ -1,41 +1,56 @@ -/* - * 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-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.psi.impl.source.javadoc; +import com.intellij.lang.ASTNode; +import com.intellij.psi.JavaDocTokenType; +import com.intellij.psi.JavaElementVisitor; +import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.PsiReference; +import com.intellij.psi.impl.source.tree.ChildRole; +import com.intellij.psi.impl.source.tree.CompositePsiElement; +import com.intellij.psi.impl.source.tree.JavaDocElementType; import com.intellij.psi.javadoc.JavadocManager; import com.intellij.psi.javadoc.JavadocTagInfo; import com.intellij.psi.javadoc.PsiDocTag; +import com.intellij.psi.javadoc.PsiDocTagValue; import com.intellij.psi.util.PsiTreeUtil; +import org.jetbrains.annotations.NotNull; /** * @author mike */ -public class PsiDocTagValueImpl extends CorePsiDocTagValueImpl { +public class PsiDocTagValueImpl extends CompositePsiElement implements PsiDocTagValue { + public PsiDocTagValueImpl() { + super(JavaDocElementType.DOC_TAG_VALUE_ELEMENT); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof JavaElementVisitor) { + ((JavaElementVisitor)visitor).visitDocTagValue(this); + } + else { + visitor.visitElement(this); + } + } + + @Override + public int getChildRole(@NotNull ASTNode child) { + if (child.getElementType() == JavaDocTokenType.DOC_TAG_VALUE_COMMA) { + return ChildRole.COMMA; + } + + return super.getChildRole(child); + } + @Override public PsiReference getReference() { PsiDocTag docTag = PsiTreeUtil.getParentOfType(this, PsiDocTag.class); - if (docTag == null) { - return null; - } - final String name = docTag.getName(); - final JavadocManager manager = JavadocManager.SERVICE.getInstance(getProject()); - final JavadocTagInfo info = manager.getTagInfo(name); + if (docTag == null) return null; + + JavadocTagInfo info = JavadocManager.SERVICE.getInstance(getProject()).getTagInfo(docTag.getName()); if (info == null) return null; return info.getReference(this); } -} +} \ No newline at end of file diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/CoreJavaASTFactory.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaASTFactory.java similarity index 65% rename from java/java-psi-impl/src/com/intellij/psi/impl/source/tree/CoreJavaASTFactory.java rename to java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaASTFactory.java index 20e94043a5ac..8e1eeb75ac27 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/CoreJavaASTFactory.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaASTFactory.java @@ -1,25 +1,11 @@ -/* - * Copyright 2000-2015 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.psi.impl.source.tree; import com.intellij.lang.ASTFactory; import com.intellij.lang.DefaultASTFactory; import com.intellij.openapi.components.ServiceManager; import com.intellij.psi.JavaTokenType; -import com.intellij.psi.impl.source.javadoc.CorePsiDocTagValueImpl; +import com.intellij.psi.impl.source.javadoc.PsiDocTagValueImpl; import com.intellij.psi.impl.source.javadoc.PsiDocTokenImpl; import com.intellij.psi.impl.source.tree.java.PsiIdentifierImpl; import com.intellij.psi.impl.source.tree.java.PsiJavaTokenImpl; @@ -32,11 +18,11 @@ import org.jetbrains.annotations.NotNull; /** * @author yole */ -public class CoreJavaASTFactory extends ASTFactory { +public class JavaASTFactory extends ASTFactory { private final DefaultASTFactory myDefaultASTFactory = ServiceManager.getService(DefaultASTFactory.class); @Override - public LeafElement createLeaf(@NotNull final IElementType type, @NotNull final CharSequence text) { + public LeafElement createLeaf(@NotNull IElementType type, @NotNull CharSequence text) { if (type == JavaTokenType.C_STYLE_COMMENT || type == JavaTokenType.END_OF_LINE_COMMENT) { return myDefaultASTFactory.createComment(type, text); } @@ -60,8 +46,9 @@ public class CoreJavaASTFactory extends ASTFactory { @Override public CompositeElement createComposite(@NotNull IElementType type) { if (type == JavaDocElementType.DOC_TAG_VALUE_ELEMENT) { - return new CorePsiDocTagValueImpl(); + return new PsiDocTagValueImpl(); } + return null; } -} +} \ No newline at end of file