make DocumentationProvider methods default and remove dummy implementations

GitOrigin-RevId: 69056c1ee25ac3631f87e5b924f181921660ad38
This commit is contained in:
Daniil Ovchinnikov
2019-05-29 18:12:53 +03:00
committed by intellij-monorepo-bot
parent 00a3f1cf43
commit f7e8e0b065
15 changed files with 42 additions and 356 deletions
@@ -31,12 +31,6 @@ public class JsonSchemaDocumentationProvider implements DocumentationProvider {
return findSchemaAndGenerateDoc(element, originalElement, true, null);
}
@Nullable
@Override
public List<String> getUrlFor(PsiElement element, PsiElement originalElement) {
return null;
}
@Nullable
@Override
public String generateDoc(PsiElement element, @Nullable PsiElement originalElement) {
@@ -213,12 +207,6 @@ public class JsonSchemaDocumentationProvider implements DocumentationProvider {
return null;
}
@Nullable
@Override
public PsiElement getDocumentationElementForLink(PsiManager psiManager, String link, PsiElement context) {
return null;
}
private static class FakeDocElement extends FakePsiElement {
private final PsiElement myContextElement;
private final String myAltName;
@@ -1,19 +1,4 @@
/*
* 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-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.lang.documentation;
import com.intellij.codeInsight.documentation.DocumentationManagerProtocol;
@@ -47,24 +32,29 @@ public interface DocumentationProvider {
* a method reference, this will be the method to which the reference is resolved).
* @param originalElement the element under the mouse cursor
* @return the documentation to show, or null if the provider can't provide any documentation for this element. Documentation can contain
* HTML markup. If HTML special characters need to be shown in popup, they should be properly escaped.
* HTML markup. If HTML special characters need to be shown in popup, they should be properly escaped.
*/
@Nullable
String getQuickNavigateInfo(PsiElement element, PsiElement originalElement);
default String getQuickNavigateInfo(PsiElement element, PsiElement originalElement) {
return null;
}
/**
* Returns the list of possible URLs to show as external documentation for the specified element.
*
* @param element the element for which the documentation is requested (for example, if the mouse is over
* a method reference, this will be the method to which the reference is resolved).
* @param originalElement the element under the mouse cursor
* @return the list of URLs to open in the browser or to use for showing documentation internally ({@link ExternalDocumentationProvider}).
* If the list contains a single URL, it will be opened.
* If the list contains multiple URLs, the user will be prompted to choose one of them.
* For {@link ExternalDocumentationProvider}, first URL, yielding non-empty result in
* {@link ExternalDocumentationProvider#fetchExternalDocumentation(Project, PsiElement, List)} will be used.
* If the list contains a single URL, it will be opened.
* If the list contains multiple URLs, the user will be prompted to choose one of them.
* For {@link ExternalDocumentationProvider}, first URL, yielding non-empty result in
* {@link ExternalDocumentationProvider#fetchExternalDocumentation(Project, PsiElement, List)} will be used.
*/
@Nullable
List<String> getUrlFor(PsiElement element, PsiElement originalElement);
default List<String> getUrlFor(PsiElement element, PsiElement originalElement) {
return null;
}
/**
* Callback for asking the doc provider for the complete documentation.
@@ -85,14 +75,18 @@ public interface DocumentationProvider {
* @param element the element for which the documentation is requested (for example, if the mouse is over
* a method reference, this will be the method to which the reference is resolved).
* @param originalElement the element under the mouse cursor
* @return target element's documentation, or {@code null} if provider is unable to generate documentation
* for the given element
* @return target element's documentation, or {@code null} if provider is unable to generate documentation
* for the given element
*/
@Nullable
String generateDoc(PsiElement element, @Nullable PsiElement originalElement);
default String generateDoc(PsiElement element, @Nullable PsiElement originalElement) {
return null;
}
@Nullable
PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, Object object, PsiElement element);
default PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, Object object, PsiElement element) {
return null;
}
/**
* Returns the target element for a link in a documentation comment. The link needs to use the
@@ -105,5 +99,7 @@ public interface DocumentationProvider {
* @see DocumentationManagerUtil#createHyperlink(StringBuilder, String, String, boolean)
*/
@Nullable
PsiElement getDocumentationElementForLink(PsiManager psiManager, String link, PsiElement context);
default PsiElement getDocumentationElementForLink(PsiManager psiManager, String link, PsiElement context) {
return null;
}
}
@@ -1,59 +1,18 @@
/*
* 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.
*/
// 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.lang.documentation;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
import java.util.List;
/**
* @author peter
*/
public class DocumentationProviderEx implements DocumentationProvider {
@Nullable
@Override
public String getQuickNavigateInfo(PsiElement element, PsiElement originalElement) {
return null;
}
@Override
public List<String> getUrlFor(PsiElement element, PsiElement originalElement) {
return null;
}
@Override
public String generateDoc(PsiElement element, @Nullable PsiElement originalElement) {
return null;
}
@Override
public PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, Object object, PsiElement element) {
return null;
}
@Override
public PsiElement getDocumentationElementForLink(PsiManager psiManager, String link, PsiElement context) {
return null;
}
/**
* @param contextElement the leaf PSI element in {@code file} at the editor's caret offset.
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2010 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.lang.ant.doc;
import com.intellij.lang.ant.AntFilesProvider;
@@ -29,7 +15,6 @@ import com.intellij.pom.PomTarget;
import com.intellij.pom.PomTargetPsiElement;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.XmlElement;
import com.intellij.psi.xml.XmlTag;
@@ -251,14 +236,4 @@ public class AntDomDocumentationProvider implements DocumentationProvider {
}
return Collections.singletonList(helpFile.getUrl());
}
@Override
public PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, Object object, PsiElement element) {
return null;
}
@Override
public PsiElement getDocumentationElementForLink(PsiManager psiManager, String link, PsiElement context) {
return null;
}
}
@@ -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-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 org.jetbrains.plugins.gradle.documentation;
import com.intellij.codeInsight.javadoc.JavaDocUtil;
@@ -34,8 +20,6 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrCall;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightVariable;
import java.util.List;
/**
* @author Vladislav.Soroka
*/
@@ -56,12 +40,6 @@ public class GradleDocumentationProvider implements DocumentationProvider {
return null;
}
@Nullable
@Override
public List<String> getUrlFor(PsiElement element, PsiElement originalElement) {
return null;
}
@Nullable
@Override
public String generateDoc(PsiElement element, PsiElement originalElement) {
@@ -1,24 +1,13 @@
/*
* Copyright 2000-2009 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 org.jetbrains.idea.maven.dom;
import com.intellij.lang.documentation.DocumentationProvider;
import com.intellij.lang.findUsages.DescriptiveNameUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.ElementDescriptionLocation;
import com.intellij.psi.ElementDescriptionProvider;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.impl.FakePsiElement;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.XmlTag;
@@ -55,16 +44,6 @@ public class MavenModelDocumentationProvider implements DocumentationProvider, E
return getDoc(element, true);
}
@Override
public PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, Object object, PsiElement element) {
return null;
}
@Override
public PsiElement getDocumentationElementForLink(PsiManager psiManager, String link, PsiElement context) {
return null;
}
@Nullable
private static String getDoc(PsiElement element, boolean html) {
return getMavenElementDescription(element, DescKind.TYPE_NAME_VALUE, html);
@@ -1,25 +1,8 @@
/*
* Copyright 2000-2009 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 org.jetbrains.idea.maven.dom;
import com.intellij.lang.documentation.DocumentationProvider;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;
import java.util.List;
public class MavenPluginModelDocumentationProvider implements DocumentationProvider {
@Override
@@ -27,26 +10,11 @@ public class MavenPluginModelDocumentationProvider implements DocumentationProvi
return getDocForMavenPluginParameter(element, false);
}
@Override
public List<String> getUrlFor(PsiElement element, PsiElement originalElement) {
return null;
}
@Override
public String generateDoc(PsiElement element, PsiElement originalElement) {
return getDocForMavenPluginParameter(element, true);
}
@Override
public PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, Object object, PsiElement element) {
return null;
}
@Override
public PsiElement getDocumentationElementForLink(PsiManager psiManager, String link, PsiElement context) {
return null;
}
private String getDocForMavenPluginParameter(PsiElement element, boolean html) {
MavenPluginConfigurationDomExtender.ParameterData p = element.getUserData(MavenPluginConfigurationDomExtender.PLUGIN_PARAMETER_KEY);
if (p == null) return null;
@@ -1,18 +1,4 @@
/*
* 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.
*/
// 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 org.jetbrains.idea.maven.dom;
import com.intellij.lang.documentation.DocumentationProvider;
@@ -80,10 +66,4 @@ public class MavenPomXmlDocumentationProvider implements DocumentationProvider {
return myDelegate.getDocumentationElementForLookupItem(psiManager, object, element);
}
@Nullable
@Override
public PsiElement getDocumentationElementForLink(PsiManager psiManager, String link, PsiElement context) {
return null;
}
}
@@ -230,12 +230,6 @@ public class XsltDocumentationProvider implements DocumentationProvider {
return null;
}
@Override
@Nullable
public String getQuickNavigateInfo(PsiElement element, PsiElement originalElement) {
return null;
}
static class DocElement extends LightElement implements PsiNamedElement {
private final PsiElement myElement;
private final String myCategory;
@@ -1,6 +1,4 @@
/*
* 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.
*/
// 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 org.jetbrains.yaml.meta.impl;
import com.intellij.lang.documentation.AbstractDocumentationProvider;
@@ -28,11 +26,6 @@ import java.util.Objects;
@ApiStatus.Experimental
public abstract class YamlDocumentationProviderBase extends AbstractDocumentationProvider {
@Override
@Nullable
public String getQuickNavigateInfo(PsiElement element, PsiElement originalElement) {
return null;
}
@Override
public String generateDoc(PsiElement element, @Nullable PsiElement originalElement) {
@@ -1,19 +1,16 @@
// 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.
// 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 org.jetbrains.yaml.schema;
import com.intellij.lang.documentation.DocumentationProviderEx;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.jetbrains.jsonSchema.ide.JsonSchemaService;
import com.jetbrains.jsonSchema.impl.JsonSchemaDocumentationProvider;
import com.jetbrains.jsonSchema.impl.JsonSchemaObject;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class YamlJsonSchemaDocumentationProvider extends DocumentationProviderEx {
@Nullable
@Override
@@ -21,12 +18,6 @@ public class YamlJsonSchemaDocumentationProvider extends DocumentationProviderEx
return findSchemaAndGenerateDoc(element, true);
}
@Nullable
@Override
public List<String> getUrlFor(PsiElement element, PsiElement originalElement) {
return null;
}
@Nullable
@Override
public String generateDoc(PsiElement element, @Nullable PsiElement originalElement) {
@@ -43,18 +34,6 @@ public class YamlJsonSchemaDocumentationProvider extends DocumentationProviderEx
return JsonSchemaDocumentationProvider.generateDoc(element, schemaObject, preferShort, null);
}
@Nullable
@Override
public PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, Object object, PsiElement element) {
return null;
}
@Nullable
@Override
public PsiElement getDocumentationElementForLink(PsiManager psiManager, String link, PsiElement context) {
return null;
}
@Nullable
@Override
public PsiElement getCustomDocumentationElement(@NotNull Editor editor,
@@ -1,18 +1,4 @@
/*
* 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-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.util.xml;
import com.intellij.lang.documentation.DocumentationProvider;
@@ -20,25 +6,12 @@ import com.intellij.pom.PomTarget;
import com.intellij.pom.PomTargetPsiElement;
import com.intellij.psi.DelegatePsiTarget;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;
import java.util.List;
/**
* @author Dmitry Avdeev
*/
public class DomDocumentationProvider implements DocumentationProvider {
@Override
public String getQuickNavigateInfo(final PsiElement element, PsiElement originalElement) {
return null;
}
@Override
public List<String> getUrlFor(final PsiElement element, final PsiElement originalElement) {
return null;
}
@Override
public String generateDoc(PsiElement element, final PsiElement originalElement) {
if (element instanceof PomTargetPsiElement) {
@@ -58,14 +31,4 @@ public class DomDocumentationProvider implements DocumentationProvider {
}
return ElementPresentationManager.getDocumentationForElement(domElement);
}
@Override
public PsiElement getDocumentationElementForLookupItem(final PsiManager psiManager, final Object object, final PsiElement element) {
return null;
}
@Override
public PsiElement getDocumentationElementForLink(final PsiManager psiManager, final String link, final PsiElement context) {
return null;
}
}
@@ -1,18 +1,4 @@
/*
* 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-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.xml.util.documentation;
import com.intellij.lang.Language;
@@ -461,11 +447,6 @@ public class XmlDocumentationProvider implements DocumentationProvider {
return null;
}
@Override
public PsiElement getDocumentationElementForLink(final PsiManager psiManager, String link, PsiElement context) {
return null;
}
private static class MyPsiElementProcessor implements PsiElementProcessor {
String result;
String version;
@@ -13,13 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.intellij.plugins.relaxNG;
import com.intellij.lang.documentation.DocumentationProvider;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlElement;
@@ -37,7 +35,6 @@ import org.jetbrains.annotations.Nullable;
import org.kohsuke.rngom.digested.DElementPattern;
import java.util.Collection;
import java.util.List;
public class RngDocumentationProvider implements DocumentationProvider {
private static final Logger LOG = Logger.getInstance(RngDocumentationProvider.class);
@@ -130,29 +127,6 @@ public class RngDocumentationProvider implements DocumentationProvider {
return null;
}
@Override
@Nullable
public PsiElement getDocumentationElementForLink(PsiManager psiManager, String link, PsiElement context) {
return null;
}
@Override
@Nullable
public PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, Object object, PsiElement element) {
return null;
}
@Override
@Nullable
public String getQuickNavigateInfo(PsiElement element, PsiElement originalElement) {
return null;
}
@Override
public List<String> getUrlFor(PsiElement element, PsiElement originalElement) {
return null;
}
public int hashCode() {
return 0; // CompositeDocumentationProvider uses a HashSet that doesn't preserve order. We want to be the first one.
}
@@ -25,7 +25,10 @@ import com.intellij.lang.refactoring.NamesValidator;
import com.intellij.openapi.fileTypes.SingleLazyInstanceSyntaxHighlighterFactory;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.PsiComment;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiWhiteSpace;
import com.intellij.psi.tree.IElementType;
import org.intellij.plugins.relaxNG.compact.psi.RncDefine;
import org.intellij.plugins.relaxNG.compact.psi.RncElement;
@@ -34,8 +37,6 @@ import org.intellij.plugins.relaxNG.compact.psi.util.RenameUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class RngCompactLanguage extends Language {
public static final String ID = "RELAX-NG";
@@ -116,16 +117,6 @@ public class RngCompactLanguage extends Language {
}
public static class MyDocumentationProvider implements DocumentationProvider {
@Override
@Nullable
public String getQuickNavigateInfo(PsiElement element, PsiElement originalElement) {
return null;
}
@Override
public List<String> getUrlFor(PsiElement element, PsiElement originalElement) {
return null;
}
@Override
@Nullable
@@ -151,18 +142,6 @@ public class RngCompactLanguage extends Language {
}
return null;
}
@Override
@Nullable
public PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, Object object, PsiElement element) {
return null;
}
@Override
@Nullable
public PsiElement getDocumentationElementForLink(PsiManager psiManager, String link, PsiElement context) {
return null;
}
}
public static class MySyntaxHighlighterFactory extends SingleLazyInstanceSyntaxHighlighterFactory {