mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Get rid of unused parameters
This commit is contained in:
@@ -410,17 +410,16 @@ public class JavaDocumentationProvider extends DocumentationProviderEx implement
|
||||
@Override
|
||||
public String generateDocumentationContentStub(PsiComment _comment) {
|
||||
final PsiJavaDocumentedElement commentOwner = ((PsiDocComment)_comment).getOwner();
|
||||
final Project project = _comment.getProject();
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
final CodeDocumentationAwareCommenter commenter =
|
||||
(CodeDocumentationAwareCommenter)LanguageCommenters.INSTANCE.forLanguage(_comment.getLanguage());
|
||||
if (commentOwner instanceof PsiMethod) {
|
||||
PsiMethod psiMethod = (PsiMethod)commentOwner;
|
||||
generateParametersTakingDocFromSuperMethods(project, builder, commenter, psiMethod);
|
||||
generateParametersTakingDocFromSuperMethods(builder, commenter, psiMethod);
|
||||
|
||||
final PsiTypeParameterList typeParameterList = psiMethod.getTypeParameterList();
|
||||
if (typeParameterList != null) {
|
||||
createTypeParamsListComment(builder, project, commenter, typeParameterList);
|
||||
createTypeParamsListComment(builder, commenter, typeParameterList);
|
||||
}
|
||||
if (psiMethod.getReturnType() != null && !PsiType.VOID.equals(psiMethod.getReturnType())) {
|
||||
builder.append(CodeDocumentationUtil.createDocCommentLine(RETURN_TAG, _comment.getContainingFile(), commenter));
|
||||
@@ -437,15 +436,15 @@ public class JavaDocumentationProvider extends DocumentationProviderEx implement
|
||||
else if (commentOwner instanceof PsiClass) {
|
||||
final PsiTypeParameterList typeParameterList = ((PsiClass)commentOwner).getTypeParameterList();
|
||||
if (typeParameterList != null) {
|
||||
createTypeParamsListComment(builder, project, commenter, typeParameterList);
|
||||
createTypeParamsListComment(builder, commenter, typeParameterList);
|
||||
}
|
||||
}
|
||||
return builder.length() > 0 ? builder.toString() : null;
|
||||
}
|
||||
|
||||
public static void generateParametersTakingDocFromSuperMethods(Project project,
|
||||
StringBuilder builder,
|
||||
CodeDocumentationAwareCommenter commenter, PsiMethod psiMethod) {
|
||||
public static void generateParametersTakingDocFromSuperMethods(StringBuilder builder,
|
||||
CodeDocumentationAwareCommenter commenter,
|
||||
PsiMethod psiMethod) {
|
||||
final PsiParameter[] parameters = psiMethod.getParameterList().getParameters();
|
||||
final Map<String, String> param2Description = new HashMap<>();
|
||||
final PsiMethod[] superMethods = psiMethod.findSuperMethods();
|
||||
@@ -456,19 +455,17 @@ public class JavaDocumentationProvider extends DocumentationProviderEx implement
|
||||
final PsiDocTag[] params = comment.findTagsByName("param");
|
||||
for (PsiDocTag param : params) {
|
||||
final PsiElement[] dataElements = param.getDataElements();
|
||||
if (dataElements != null) {
|
||||
String paramName = null;
|
||||
for (PsiElement dataElement : dataElements) {
|
||||
if (dataElement instanceof PsiDocParamRef) {
|
||||
//noinspection ConstantConditions
|
||||
paramName = dataElement.getReference().getCanonicalText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (paramName != null) {
|
||||
param2Description.put(paramName, param.getText());
|
||||
String paramName = null;
|
||||
for (PsiElement dataElement : dataElements) {
|
||||
if (dataElement instanceof PsiDocParamRef) {
|
||||
//noinspection ConstantConditions
|
||||
paramName = dataElement.getReference().getCanonicalText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (paramName != null) {
|
||||
param2Description.put(paramName, param.getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -489,9 +486,8 @@ public class JavaDocumentationProvider extends DocumentationProviderEx implement
|
||||
}
|
||||
|
||||
public static void createTypeParamsListComment(final StringBuilder buffer,
|
||||
final Project project,
|
||||
final CodeDocumentationAwareCommenter commenter,
|
||||
final PsiTypeParameterList typeParameterList) {
|
||||
final CodeDocumentationAwareCommenter commenter,
|
||||
final PsiTypeParameterList typeParameterList) {
|
||||
final PsiTypeParameter[] typeParameters = typeParameterList.getTypeParameters();
|
||||
for (PsiTypeParameter typeParameter : typeParameters) {
|
||||
buffer.append(CodeDocumentationUtil.createDocCommentLine(PARAM_TAG, typeParameterList.getContainingFile(), commenter));
|
||||
@@ -726,7 +722,7 @@ public class JavaDocumentationProvider extends DocumentationProviderEx implement
|
||||
String signature = PsiFormatUtil.formatMethod(method, PsiSubstitutor.EMPTY, options, parameterOptions, 999);
|
||||
|
||||
if (java8Format) {
|
||||
signature = signature.replaceAll("\\(|\\)|, ", "-").replaceAll("\\[\\]", ":A");
|
||||
signature = signature.replaceAll("\\(|\\)|, ", "-").replaceAll("\\[]", ":A");
|
||||
}
|
||||
|
||||
return signature;
|
||||
|
||||
+3
-17
@@ -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.documentation;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
@@ -495,7 +481,7 @@ public class GroovyDocumentationProvider implements CodeDocumentationProvider, E
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if (owner instanceof GrMethod) {
|
||||
final GrMethod method = (GrMethod)owner;
|
||||
JavaDocumentationProvider.generateParametersTakingDocFromSuperMethods(project, builder, commenter, method);
|
||||
JavaDocumentationProvider.generateParametersTakingDocFromSuperMethods(builder, commenter, method);
|
||||
|
||||
final PsiType returnType = method.getInferredReturnType();
|
||||
if ((returnType != null || method.getModifierList().hasModifierProperty(GrModifier.DEF)) && !PsiType.VOID.equals(returnType)) {
|
||||
@@ -513,7 +499,7 @@ public class GroovyDocumentationProvider implements CodeDocumentationProvider, E
|
||||
else if (owner instanceof GrTypeDefinition) {
|
||||
final PsiTypeParameterList typeParameterList = ((PsiClass)owner).getTypeParameterList();
|
||||
if (typeParameterList != null) {
|
||||
JavaDocumentationProvider.createTypeParamsListComment(builder, project, commenter, typeParameterList);
|
||||
JavaDocumentationProvider.createTypeParamsListComment(builder, commenter, typeParameterList);
|
||||
}
|
||||
}
|
||||
return builder.length() > 0 ? builder.toString() : null;
|
||||
|
||||
Reference in New Issue
Block a user