diff --git a/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedBinaryField.java b/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedBinaryField.java index 1f12d2d47e..cc85f0d547 100644 --- a/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedBinaryField.java +++ b/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedBinaryField.java @@ -1,11 +1,11 @@ /* - * Copyright 2009-2017 the original author or authors. + * Copyright 2009-2022 the original author or authors. * * 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 + * https://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, @@ -16,9 +16,6 @@ package org.codehaus.groovy.eclipse.codebrowsing.elements; import org.codehaus.groovy.ast.ASTNode; -import org.codehaus.groovy.ast.ClassNode; -import org.codehaus.groovy.ast.MethodNode; -import org.codehaus.groovy.ast.Variable; import org.eclipse.jdt.internal.core.JavaElement; import org.eclipse.jdt.internal.core.ResolvedBinaryField; @@ -45,17 +42,4 @@ public String getExtraDoc() { public ASTNode getInferredElement() { return inferredElement; } - - @Override - public String getInferredElementName() { - if (inferredElement instanceof Variable) { - return ((Variable) inferredElement).getName(); - } else if (inferredElement instanceof MethodNode) { - return ((MethodNode) inferredElement).getName(); - } else if (inferredElement instanceof ClassNode) { - return ((ClassNode) inferredElement).getName(); - } else { - return inferredElement.getText(); - } - } } diff --git a/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedBinaryMethod.java b/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedBinaryMethod.java index a87d8dba49..49890c3883 100644 --- a/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedBinaryMethod.java +++ b/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedBinaryMethod.java @@ -1,11 +1,11 @@ /* - * Copyright 2009-2017 the original author or authors. + * Copyright 2009-2022 the original author or authors. * * 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 + * https://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, @@ -16,9 +16,6 @@ package org.codehaus.groovy.eclipse.codebrowsing.elements; import org.codehaus.groovy.ast.ASTNode; -import org.codehaus.groovy.ast.ClassNode; -import org.codehaus.groovy.ast.MethodNode; -import org.codehaus.groovy.ast.Variable; import org.eclipse.jdt.internal.core.JavaElement; import org.eclipse.jdt.internal.core.ResolvedBinaryMethod; @@ -45,17 +42,4 @@ public String getExtraDoc() { public ASTNode getInferredElement() { return inferredElement; } - - @Override - public String getInferredElementName() { - if (inferredElement instanceof Variable) { - return ((Variable) inferredElement).getName(); - } else if (inferredElement instanceof MethodNode) { - return ((MethodNode) inferredElement).getName(); - } else if (inferredElement instanceof ClassNode) { - return ((ClassNode) inferredElement).getName(); - } else { - return inferredElement.getText(); - } - } } diff --git a/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedBinaryType.java b/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedBinaryType.java index 428b099fcc..0abd19e70c 100644 --- a/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedBinaryType.java +++ b/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedBinaryType.java @@ -1,11 +1,11 @@ /* - * Copyright 2009-2017 the original author or authors. + * Copyright 2009-2022 the original author or authors. * * 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 + * https://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, @@ -18,8 +18,6 @@ import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.ClassHelper; import org.codehaus.groovy.ast.ClassNode; -import org.codehaus.groovy.ast.MethodNode; -import org.codehaus.groovy.ast.Variable; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.core.JavaElement; import org.eclipse.jdt.internal.core.ResolvedBinaryType; @@ -56,19 +54,6 @@ public ASTNode getInferredElement() { return inferredElement; } - @Override - public String getInferredElementName() { - if (inferredElement instanceof Variable) { - return ((Variable) inferredElement).getName(); - } else if (inferredElement instanceof MethodNode) { - return ((MethodNode) inferredElement).getName(); - } else if (inferredElement instanceof ClassNode) { - return ((ClassNode) inferredElement).getName(); - } else { - return inferredElement.getText(); - } - } - protected boolean isAnnotationCollector() { if (isAnnotationCollector == null) { isAnnotationCollector = (inferredElement instanceof ClassNode && !((ClassNode) inferredElement) diff --git a/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedSourceField.java b/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedSourceField.java index bdd1464a85..3515a073f2 100644 --- a/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedSourceField.java +++ b/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedSourceField.java @@ -1,11 +1,11 @@ /* - * Copyright 2009-2018 the original author or authors. + * Copyright 2009-2022 the original author or authors. * * 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 + * https://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, @@ -16,10 +16,7 @@ package org.codehaus.groovy.eclipse.codebrowsing.elements; import org.codehaus.groovy.ast.ASTNode; -import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.ast.FieldNode; -import org.codehaus.groovy.ast.MethodNode; -import org.codehaus.groovy.ast.Variable; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.core.JavaElement; import org.eclipse.jdt.internal.core.ResolvedSourceField; @@ -48,18 +45,6 @@ public ASTNode getInferredElement() { return inferredElement; } - @Override - public String getInferredElementName() { - if (inferredElement instanceof Variable) { - return ((Variable) inferredElement).getName(); - } else if (inferredElement instanceof MethodNode) { - return ((MethodNode) inferredElement).getName(); - } else if (inferredElement instanceof ClassNode) { - return ((ClassNode) inferredElement).getName(); - } - return inferredElement.getText(); - } - @Override public Object getElementInfo() throws JavaModelException { try { diff --git a/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedSourceMethod.java b/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedSourceMethod.java index de5a4b0a1d..3731a86507 100644 --- a/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedSourceMethod.java +++ b/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedSourceMethod.java @@ -1,11 +1,11 @@ /* - * Copyright 2009-2018 the original author or authors. + * Copyright 2009-2022 the original author or authors. * * 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 + * https://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, @@ -19,7 +19,6 @@ import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.ast.MethodNode; import org.codehaus.groovy.ast.Parameter; -import org.codehaus.groovy.ast.Variable; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.internal.core.JavaElement; @@ -50,18 +49,6 @@ public ASTNode getInferredElement() { return inferredElement; } - @Override - public String getInferredElementName() { - if (inferredElement instanceof Variable) { - return ((Variable) inferredElement).getName(); - } else if (inferredElement instanceof MethodNode) { - return ((MethodNode) inferredElement).getName(); - } else if (inferredElement instanceof ClassNode) { - return ((ClassNode) inferredElement).getName(); - } - return inferredElement.getText(); - } - @Override public Object getElementInfo() throws JavaModelException { try { diff --git a/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedSourceType.java b/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedSourceType.java index bf288002e2..c43b8076f1 100644 --- a/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedSourceType.java +++ b/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/GroovyResolvedSourceType.java @@ -1,11 +1,11 @@ /* - * Copyright 2009-2017 the original author or authors. + * Copyright 2009-2022 the original author or authors. * * 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 + * https://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, @@ -16,9 +16,6 @@ package org.codehaus.groovy.eclipse.codebrowsing.elements; import org.codehaus.groovy.ast.ASTNode; -import org.codehaus.groovy.ast.ClassNode; -import org.codehaus.groovy.ast.MethodNode; -import org.codehaus.groovy.ast.Variable; import org.eclipse.jdt.internal.core.JavaElement; import org.eclipse.jdt.internal.core.ResolvedSourceType; @@ -45,17 +42,4 @@ public String getExtraDoc() { public ASTNode getInferredElement() { return inferredElement; } - - @Override - public String getInferredElementName() { - if (inferredElement instanceof Variable) { - return ((Variable) inferredElement).getName(); - } else if (inferredElement instanceof MethodNode) { - return ((MethodNode) inferredElement).getName(); - } else if (inferredElement instanceof ClassNode) { - return ((ClassNode) inferredElement).getName(); - } else { - return inferredElement.getText(); - } - } } diff --git a/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/IGroovyResolvedElement.java b/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/IGroovyResolvedElement.java index 3dabb94f3c..6644545552 100644 --- a/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/IGroovyResolvedElement.java +++ b/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/elements/IGroovyResolvedElement.java @@ -1,11 +1,11 @@ /* - * Copyright 2009-2017 the original author or authors. + * Copyright 2009-2022 the original author or authors. * * 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 + * https://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, @@ -16,6 +16,9 @@ package org.codehaus.groovy.eclipse.codebrowsing.elements; import org.codehaus.groovy.ast.ASTNode; +import org.codehaus.groovy.ast.ClassNode; +import org.codehaus.groovy.ast.MethodNode; +import org.codehaus.groovy.ast.Variable; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.ISourceReference; @@ -23,22 +26,23 @@ * Allows Groovy elements to provide customized Javadoc hovers. */ public interface IGroovyResolvedElement extends IJavaElement, ISourceReference { + String getKey(); String getExtraDoc(); ASTNode getInferredElement(); - String getInferredElementName(); - /*default String getInferredElementName() { + default String getInferredElementName() { ASTNode element = getInferredElement(); if (element instanceof Variable) { return ((Variable) element).getName(); - } else if (element instanceof MethodNode) { - return ((MethodNode) element).getName(); } else if (element instanceof ClassNode) { return ((ClassNode) element).getName(); + } else if (element instanceof MethodNode) { + MethodNode method = (MethodNode) element; + return "".equals(method.getName()) ? method.getDeclaringClass().getName() : method.getName(); } return element.getText(); - }*/ + } } diff --git a/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/requestor/CodeSelectRequestor.java b/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/requestor/CodeSelectRequestor.java index e83d715c87..6a7ccfebff 100644 --- a/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/requestor/CodeSelectRequestor.java +++ b/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/requestor/CodeSelectRequestor.java @@ -50,6 +50,7 @@ import org.codehaus.groovy.eclipse.codebrowsing.elements.GroovyResolvedSourceType; import org.codehaus.groovy.eclipse.core.GroovyCore; import org.codehaus.groovy.transform.trait.Traits; +import org.codehaus.jdt.groovy.ast.MethodNodeWithNamedParams; import org.codehaus.jdt.groovy.internal.compiler.ast.JDTFieldNode; import org.codehaus.jdt.groovy.internal.compiler.ast.JDTMethodNode; import org.codehaus.jdt.groovy.model.GroovyCompilationUnit; @@ -518,7 +519,8 @@ else if (existsOnlyInGroovyModel(node.getField(), name, declaringType, jdtDeclar Parameter[] parameters = null; if (declaration instanceof MethodNode) { name = ((MethodNode) declaration).getName(); - parameters = ((MethodNode) declaration).getParameters(); + parameters = declaration instanceof MethodNodeWithNamedParams + ? ((MethodNodeWithNamedParams) declaration).getPositionalParams() : ((MethodNode) declaration).getParameters(); } maybeRequested = findElement(jdtDeclaringType, name, parameters); } @@ -733,11 +735,9 @@ private static void appendUniqueKeyForMethod(final StringBuilder sb, final Metho // call parameters sb.append(Signature.C_PARAM_START); - Parameter[] parameters = node.getParameters(); - if (parameters != null) { - for (Parameter p : parameters) { - sb.append(signer.apply(p.getType())); - } + Parameter[] parameters = (node instanceof MethodNodeWithNamedParams) ? ((MethodNodeWithNamedParams) node).getPositionalParams() : node.getParameters(); + for (Parameter p : parameters) { + sb.append(signer.apply(p.getType())); } sb.append(Signature.C_PARAM_END); @@ -747,7 +747,7 @@ private static void appendUniqueKeyForMethod(final StringBuilder sb, final Metho // type parameter resolution if (generics.length > 0) { // generics have been resolved for returnType, declaringType and parameterTypes; mappings can be recovered using original method reference - GenericsMapper mapper = GenericsMapper.gatherGenerics(GroovyUtils.getParameterTypes(node.getParameters()), declaringType, node.getOriginal()); + GenericsMapper mapper = GenericsMapper.gatherGenerics(GroovyUtils.getParameterTypes(parameters), declaringType, node.getOriginal()); sb.append('%'); sb.append(Signature.C_GENERIC_START); diff --git a/ide/org.codehaus.groovy.eclipse.ui/src/org/codehaus/groovy/eclipse/editor/GroovyExtraInformationHover.java b/ide/org.codehaus.groovy.eclipse.ui/src/org/codehaus/groovy/eclipse/editor/GroovyExtraInformationHover.java index bba413402e..781ba3e6ac 100644 --- a/ide/org.codehaus.groovy.eclipse.ui/src/org/codehaus/groovy/eclipse/editor/GroovyExtraInformationHover.java +++ b/ide/org.codehaus.groovy.eclipse.ui/src/org/codehaus/groovy/eclipse/editor/GroovyExtraInformationHover.java @@ -218,7 +218,7 @@ private String createMethodLabel(final MethodNode node) { sb.append(' '); sb.append(createTypeLabel(node.getDeclaringClass())); sb.append('.'); - sb.append(node.getName()); + sb.append("".equals(node.getName()) ? createTypeLabel(node.getDeclaringClass()) : node.getName()); sb.append('('); Parameter[] params = node.getParameters(); if (params != null) {