View | Details | Raw Unified | Return to bug 171019 | Differences between
and this patch

Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java (-2 / +196 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-21 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.codeassist;
11
package org.eclipse.jdt.internal.codeassist;
12
12
13
import java.util.ArrayList;
14
import java.util.Iterator;
13
import java.util.Locale;
15
import java.util.Locale;
14
import java.util.Map;
16
import java.util.Map;
15
17
16
import org.eclipse.core.resources.IFile;
18
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.runtime.IProgressMonitor;
19
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.OperationCanceledException;
20
import org.eclipse.core.runtime.OperationCanceledException;
21
import org.eclipse.jdt.core.IBuffer;
22
import org.eclipse.jdt.core.IMember;
23
import org.eclipse.jdt.core.IOpenable;
24
import org.eclipse.jdt.core.ISourceRange;
19
import org.eclipse.jdt.core.IType;
25
import org.eclipse.jdt.core.IType;
20
import org.eclipse.jdt.core.JavaModelException;
26
import org.eclipse.jdt.core.JavaModelException;
21
import org.eclipse.jdt.core.Signature;
27
import org.eclipse.jdt.core.Signature;
Lines 1106-1112 Link Here
1106
			}
1112
			}
1107
			this.acceptedAnswer = true;
1113
			this.acceptedAnswer = true;
1108
		} else if (binding instanceof MethodBinding) {
1114
		} else if (binding instanceof MethodBinding) {
1109
			MethodBinding methodBinding = (MethodBinding) binding;
1115
			MethodBinding methodBinding = getCorrectMethodBinding((MethodBinding) binding);
1110
			this.noProposal = false;
1116
			this.noProposal = false;
1111
1117
1112
			boolean isValuesOrValueOf = false;
1118
			boolean isValuesOrValueOf = false;
Lines 1608-1611 Link Here
1608
1614
1609
		return false;
1615
		return false;
1610
	}
1616
	}
1617
	
1618
	/*
1619
	 * Returns the correct method binding according to whether the selection is on the method declaration
1620
	 * or on the inheritDoc tag in its javadoc.
1621
	 */
1622
	private MethodBinding getCorrectMethodBinding(MethodBinding binding) {
1623
		if (this.parser.javadocParser instanceof SelectionJavadocParser) {
1624
			if (((SelectionJavadocParser)this.parser.javadocParser).inheritDocTagSelected){
1625
				try {
1626
					Object res = findMethodWithAttachedDocInHierarchy(binding);
1627
					if (res instanceof MethodBinding) {
1628
						return (MethodBinding) res;
1629
					}
1630
				} catch (JavaModelException e) {
1631
					return null;
1632
				}
1633
			}
1634
		}
1635
		return binding;
1636
	}
1637
	
1638
	protected MethodBinding findOverriddenMethodInType(ReferenceBinding overriddenType, MethodBinding overriding) throws JavaModelException {
1639
		if (overriddenType == null)
1640
			return null;
1641
		MethodBinding[] overriddenMethods= overriddenType.availableMethods();
1642
		LookupEnvironment lookupEnv = this.lookupEnvironment;
1643
		if (lookupEnv != null && overriddenMethods != null) {
1644
			for (int i= 0; i < overriddenMethods.length; i++) {
1645
				if (lookupEnv.methodVerifier().isMethodSubsignature(overriding, overriddenMethods[i])) {
1646
					return overriddenMethods[i];
1647
				}
1648
			}
1649
		}
1650
		return null;
1651
	}
1652
	
1653
	private Object findMethodWithAttachedDocInHierarchy(final MethodBinding method) throws JavaModelException {
1654
		ReferenceBinding type= method.declaringClass;
1655
		final SelectionRequestor requestor1 = (SelectionRequestor) this.requestor;
1656
		return new InheritDocVisitor() {
1657
			public Object visit(ReferenceBinding currType) throws JavaModelException {
1658
				MethodBinding overridden =  findOverriddenMethodInType(currType, method);
1659
				if (overridden == null)
1660
					return InheritDocVisitor.CONTINUE;
1661
				TypeBinding args[] = overridden.parameters;
1662
				String names[] = new String[args.length];
1663
				for (int i = 0; i < args.length; i++) {
1664
					names[i] = Signature.createTypeSignature(args[i].sourceName(), false);
1665
				}
1666
				IMember member = (IMember) requestor1.findMethodFromBinding(overridden, names, overridden.declaringClass);
1667
				if (member == null)
1668
					return InheritDocVisitor.CONTINUE;
1669
				if (member.getAttachedJavadoc(null) != null ) {  
1670
					// for binary methods with attached javadoc and no source attached
1671
					return overridden;
1672
				}
1673
				IOpenable openable = member.getOpenable();
1674
				if (openable == null)
1675
					return InheritDocVisitor.CONTINUE;
1676
				IBuffer buf= openable.getBuffer();
1677
				if (buf == null) {
1678
					// no source attachment found. This method maybe the one. Stop.
1679
					return InheritDocVisitor.STOP_BRANCH;
1680
				}
1681
1682
				ISourceRange javadocRange= member.getJavadocRange();
1683
				if (javadocRange == null)
1684
					return InheritDocVisitor.CONTINUE;	// this method doesn't have javadoc, continue to look.
1685
				String rawJavadoc= buf.getText(javadocRange.getOffset(), javadocRange.getLength());
1686
				if (rawJavadoc != null) {
1687
					return overridden;
1688
				}
1689
				return InheritDocVisitor.CONTINUE;
1690
			}
1691
		}.visitInheritDoc(type);
1692
	}
1693
	
1694
	/**
1695
	 * Implements the "Algorithm for Inheriting Method Comments" as specified for
1696
	 * <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/javadoc.html#inheritingcomments">1.4.2</a>,
1697
	 * <a href="http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javadoc.html#inheritingcomments">1.5</a>, and
1698
	 * <a href="http://java.sun.com/javase/6/docs/technotes/tools/windows/javadoc.html#inheritingcomments">1.6</a>.
1699
	 *
1700
	 * <p>
1701
	 * Unfortunately, the implementation is broken in Javadoc implementations since 1.5, see
1702
	 * <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6376959">Sun's bug</a>.
1703
	 * </p>
1704
	 *
1705
	 * <p>
1706
	 * We adhere to the spec.
1707
	 * </p>
1708
	 */
1709
	private static abstract class InheritDocVisitor {
1710
		public static final Object STOP_BRANCH= new Object() {
1711
			public String toString() { return "STOP_BRANCH"; } //$NON-NLS-1$
1712
		};
1713
		public static final Object CONTINUE= new Object() {
1714
			public String toString() { return "CONTINUE"; } //$NON-NLS-1$
1715
		};
1716
1717
		/**
1718
		 * Visits a type and decides how the visitor should proceed.
1719
		 *
1720
		 * @param currType the current type
1721
		 * @return <ul>
1722
		 *         <li>{@link #STOP_BRANCH} to indicate that no Javadoc has been found and visiting
1723
		 *         super types should stop here</li>
1724
		 *         <li>{@link #CONTINUE} to indicate that no Javadoc has been found and visiting
1725
		 *         super types should continue</li>
1726
		 *         <li>an {@link Object} or <code>null</code>, to indicate that visiting should be
1727
		 *         cancelled immediately. The returned value is the result of
1728
		 *         {@link #visitInheritDoc(ReferenceBinding)}</li>
1729
		 *         </ul>
1730
		 * @throws JavaModelException unexpected problem
1731
		 * @see #visitInheritDoc(ReferenceBinding)
1732
		 */
1733
		public abstract Object visit(ReferenceBinding currType) throws JavaModelException;
1734
1735
		/**
1736
		 * Visits the super types of the given <code>currentType</code>.
1737
		 *
1738
		 * @param currentType the starting type
1739
		 * @return the result from a call to {@link #visit(ReferenceBinding)}, or <code>null</code> if none of
1740
		 *         the calls returned a result
1741
		 * @throws JavaModelException unexpected problem
1742
		 */
1743
		public Object visitInheritDoc(ReferenceBinding currentType) throws JavaModelException {
1744
			ArrayList visited= new ArrayList();
1745
			visited.add(currentType);
1746
			Object result= visitInheritDocInterfaces(visited, currentType);
1747
			if (result != InheritDocVisitor.CONTINUE)
1748
				return result;
1749
1750
			ReferenceBinding superClass= currentType.superclass();
1751
1752
			while (superClass != null && ! visited.contains(superClass)) {
1753
				result= visit(superClass);
1754
				if (result == InheritDocVisitor.STOP_BRANCH) {
1755
					return null;
1756
				} else if (result == InheritDocVisitor.CONTINUE) {
1757
					visited.add(superClass);
1758
					result= visitInheritDocInterfaces(visited, superClass);
1759
					if (result != InheritDocVisitor.CONTINUE)
1760
						return result;
1761
					else
1762
						superClass= superClass.superclass();
1763
				} else {
1764
					return result;
1765
				}
1766
			}
1767
1768
			return null;
1769
		}
1770
1771
		/**
1772
		 * Visits the super interfaces of the given type in the given hierarchy, thereby skipping already visited types.
1773
		 * 
1774
		 * @param visited set of visited types
1775
		 * @param currentType type whose super interfaces should be visited
1776
		 * @return the result, or {@link #CONTINUE} if no result has been found
1777
		 * @throws JavaModelException unexpected problem
1778
		 */
1779
		private Object visitInheritDocInterfaces(ArrayList visited, ReferenceBinding currentType) throws JavaModelException {
1780
			ArrayList toVisitChildren= new ArrayList();
1781
			ReferenceBinding[] superInterfaces= currentType.superInterfaces();
1782
			for (int i= 0; i < superInterfaces.length; i++) {
1783
				ReferenceBinding superInterface= superInterfaces[i];
1784
				if (visited.contains(superInterface))
1785
					continue;
1786
				visited.add(superInterface);
1787
				Object result= visit(superInterface);
1788
				if (result == InheritDocVisitor.STOP_BRANCH) {
1789
					//skip
1790
				} else if (result == InheritDocVisitor.CONTINUE) {
1791
					toVisitChildren.add(superInterface);
1792
				} else {
1793
					return result;
1794
				}
1795
			}
1796
			for (Iterator iter= toVisitChildren.iterator(); iter.hasNext(); ) {
1797
				ReferenceBinding child= (ReferenceBinding) iter.next();
1798
				Object result= visitInheritDocInterfaces(visited, child);
1799
				if (result != InheritDocVisitor.CONTINUE)
1800
					return result;
1801
			}
1802
			return InheritDocVisitor.CONTINUE;
1803
		}
1804
	}
1611
}
1805
}
(-)codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionJavadoc.java (-1 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-16 Link Here
11
package org.eclipse.jdt.internal.codeassist.select;
11
package org.eclipse.jdt.internal.codeassist.select;
12
12
13
import org.eclipse.jdt.internal.compiler.ast.*;
13
import org.eclipse.jdt.internal.compiler.ast.*;
14
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
14
import org.eclipse.jdt.internal.compiler.lookup.*;
15
import org.eclipse.jdt.internal.compiler.lookup.*;
15
16
16
/**
17
/**
Lines 19-27 Link Here
19
public class SelectionJavadoc extends Javadoc {
20
public class SelectionJavadoc extends Javadoc {
20
21
21
	Expression selectedNode;
22
	Expression selectedNode;
23
	boolean inheritDocSelected;
22
24
23
	public SelectionJavadoc(int sourceStart, int sourceEnd) {
25
	public SelectionJavadoc(int sourceStart, int sourceEnd) {
24
		super(sourceStart, sourceEnd);
26
		super(sourceStart, sourceEnd);
27
		this.inheritDocSelected = false;
25
	}
28
	}
26
29
27
	/* (non-Javadoc)
30
	/* (non-Javadoc)
Lines 106-111 Link Here
106
				binding = this.selectedNode.resolvedType;
109
				binding = this.selectedNode.resolvedType;
107
			}
110
			}
108
			throw new SelectionNodeFound(binding);
111
			throw new SelectionNodeFound(binding);
112
		} else if (this.inheritDocSelected) {
113
			ReferenceContext referenceContext = scope.referenceContext();
114
			if (referenceContext instanceof MethodDeclaration) {
115
				throw new SelectionNodeFound(((MethodDeclaration) referenceContext).binding);
116
			}
109
		}
117
		}
110
	}
118
	}
111
119
(-)codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionJavadocParser.java (-1 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 25-36 Link Here
25
	int selectionStart;
25
	int selectionStart;
26
	int selectionEnd;
26
	int selectionEnd;
27
	ASTNode selectedNode;
27
	ASTNode selectedNode;
28
	public boolean inheritDocTagSelected;
28
29
29
	public SelectionJavadocParser(SelectionParser sourceParser) {
30
	public SelectionJavadocParser(SelectionParser sourceParser) {
30
		super(sourceParser);
31
		super(sourceParser);
31
		this.shouldReportProblems = false;
32
		this.shouldReportProblems = false;
32
		this.reportProblems = false;
33
		this.reportProblems = false;
33
		this.kind = SELECTION_PARSER | TEXT_PARSE;
34
		this.kind = SELECTION_PARSER | TEXT_PARSE;
35
		this.inheritDocTagSelected = false;
34
	}
36
	}
35
37
36
	/*
38
	/*
Lines 186-191 Link Here
186
	protected void updateDocComment() {
188
	protected void updateDocComment() {
187
		if (this.selectedNode instanceof Expression) {
189
		if (this.selectedNode instanceof Expression) {
188
			((SelectionJavadoc) this.docComment).selectedNode = (Expression) this.selectedNode;
190
			((SelectionJavadoc) this.docComment).selectedNode = (Expression) this.selectedNode;
191
		} else if (this.inheritDocTagSelected) {
192
			((SelectionJavadoc) this.docComment).inheritDocSelected = true;
189
		}
193
		}
190
	}
194
	}
195
	
196
	/*
197
	 * Sets a flag to denote that selection has taken place on an inheritDoc tag
198
	 */
199
	protected void parseInheritDocTag() {
200
		if (this.tagSourceStart == this.selectionStart && this.tagSourceEnd == this.selectionEnd)
201
			this.inheritDocTagSelected = true;
202
	}
191
}
203
}
(-)compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java (+8 lines)
Lines 568-573 Link Here
568
							if (this.reportProblems) {
568
							if (this.reportProblems) {
569
								recordInheritedPosition((((long) this.tagSourceStart) << 32) + this.tagSourceEnd);
569
								recordInheritedPosition((((long) this.tagSourceStart) << 32) + this.tagSourceEnd);
570
							}
570
							}
571
							if (this.inlineTagStarted) {
572
								// parse a 'valid' inheritDoc tag
573
								parseInheritDocTag();
574
							}
571
							break;
575
							break;
572
						default:
576
						default:
573
							valid = false;
577
							valid = false;
Lines 692-697 Link Here
692
		return valid;
696
		return valid;
693
	}
697
	}
694
698
699
	protected void parseInheritDocTag() {
700
		// do nothing
701
	}
702
695
	/*
703
	/*
696
	 * Parse @param tag declaration and flag missing description if corresponding option is enabled
704
	 * Parse @param tag declaration and flag missing description if corresponding option is enabled
697
	 */
705
	 */
(-)model/org/eclipse/jdt/internal/core/SelectionRequestor.java (-1 / +56 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 34-39 Link Here
34
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
34
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
35
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
35
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
36
import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
36
import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
37
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
37
import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
38
import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
38
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
39
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
39
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
40
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
Lines 842-847 Link Here
842
	}
843
	}
843
	return res;
844
	return res;
844
}
845
}
846
// TODO(Ayush): This can be an API in IType
847
private IMethod findMethod(IType type, char[] selector, String[] paramTypeNames) throws JavaModelException {
848
	IMethod method = null;
849
	int startingIndex = 0;
850
	String[] args;
851
	IType enclosingType = type.getDeclaringType();
852
	// If the method is a constructor of a non-static inner type, add the enclosing type as an 
853
	// additional parameter to the constructor
854
	if (enclosingType != null
855
			&& CharOperation.equals(type.getElementName().toCharArray(), selector)
856
			&& !Flags.isStatic(type.getFlags())) {
857
		args = new String[paramTypeNames.length+1];
858
		startingIndex = 1;
859
		args[0] = Signature.createTypeSignature(enclosingType.getFullyQualifiedName(), true);
860
	} else {
861
		args = new String[paramTypeNames.length];
862
	}
863
	int length = args.length;
864
	for(int i = startingIndex;	i< length ; i++){
865
		args[i] = new String(paramTypeNames[i-startingIndex]);
866
	}
867
	method = type.getMethod(new String(selector), args);
868
	
869
	IMethod[] methods = type.findMethods(method);
870
	if (methods != null && methods.length > 0) {
871
		method = methods[0];
872
	}
873
	return method;
874
}
875
876
/**
877
 * This method returns an IMethod element from the given binding. However,
878
 * unlike {@link #findMethod(IType, char[], String[])}, this does not require an IType to get 
879
 * the IMethod element.
880
 * @param method the given method binding
881
 * @param signatures the type signatures of the method arguments
882
 * @param declaringClass the binding of the method's declaring class
883
 * @return an IMethod corresponding to the method binding given, or null if none is found.
884
 */
885
public IJavaElement findMethodFromBinding(MethodBinding method, String[] signatures, ReferenceBinding declaringClass) {
886
	IType foundType = this.resolveType(declaringClass.qualifiedPackageName(), declaringClass.qualifiedSourceName(), NameLookup.ACCEPT_CLASSES & NameLookup.ACCEPT_INTERFACES);
887
	if (foundType != null) {
888
		if (foundType instanceof BinaryType) {
889
			try {
890
				return this.findMethod(foundType, method.selector, signatures);
891
			} catch (JavaModelException e) {
892
				return null;
893
			}
894
		} else {
895
			return foundType.getMethod(new String(method.selector), signatures);
896
		}
897
	}
898
	return null;
899
}
845
/**
900
/**
846
 * Returns the resolved elements.
901
 * Returns the resolved elements.
847
 */
902
 */
(-)src/org/eclipse/jdt/core/tests/model/SelectionJavadocModelTests.java (-1 / +171 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 1311-1314 Link Here
1311
			elements
1311
			elements
1312
		);
1312
		);
1313
	}
1313
	}
1314
	
1315
	public void testBug171019() throws CoreException {
1316
		this.wcOwner = new WorkingCopyOwner() {};
1317
		this.workingCopies = new ICompilationUnit[1];
1318
		this.workingCopies[0] = getWorkingCopy("/Tests/b171019/X.java",
1319
			"package b171019;\n" +
1320
			"interface X {\n" +
1321
			"   /**\n" +
1322
			"	 * Main desc of foo..\n" +
1323
			"	 */\n" +
1324
			"	void foo(int x);\n" +
1325
			"}\n" +
1326
			"interface Y extends X {\n" +
1327
			"   /**\n" +
1328
			"	 * {@inheritDoc}\n" +	// should navigate to X.foo(int)
1329
			"	 */\n" +
1330
			"	void foo(int x);\n\n" +
1331
			"   /**\n" +
1332
			"	 * {@inheritDoc}\n" +	// should navigate to Y.foo(String)
1333
			"	 */\n" +
1334
			"	void foo(String s);\n" +
1335
			"}\n"
1336
		);
1337
		IJavaElement[] elements = new IJavaElement[2];
1338
		elements[0] = selectMethod(this.workingCopies[0], "@inheritDoc", 1);
1339
		elements[1] = selectMethod(this.workingCopies[0], "@inheritDoc", 2);
1340
		assertElementsEqual("Invalid selection(s)",
1341
			"foo(int) [in X [in [Working copy] X.java [in b171019 [in <project root> [in Tests]]]]]\n" + 
1342
			"foo(String) [in Y [in [Working copy] X.java [in b171019 [in <project root> [in Tests]]]]]",
1343
			elements
1344
		);
1345
	}
1346
	
1347
	public void testBug171019b() throws CoreException {
1348
		this.wcOwner = new WorkingCopyOwner() {};
1349
		this.workingCopies = new ICompilationUnit[1];
1350
		this.workingCopies[0] = getWorkingCopy("/Tests/b171019/X.java",
1351
			"package b171019;\n" +
1352
			"interface X {\n" +
1353
			"   /**\n" +
1354
			"	 * Main desc of foo..\n" +
1355
			"	 */\n" +
1356
			"	void foo(int x);\n" +
1357
			"}\n" +
1358
			"class X1 implements X{\n" +
1359
			"	void foo(int x){}\n" +
1360
			"}\n" +
1361
			"class Y extends X1 {\n" +
1362
			"   /**\n" +
1363
			"	 * {@inheritDoc}\n" +	// should navigate to X.foo(int)
1364
			"	 */\n" +
1365
			"	void foo(int x);\n\n" +
1366
			"   /**\n" +
1367
			"	 * {@inheritDoc}\n" +	// should navigate to Y.foo(String)
1368
			"	 */\n" +
1369
			"	void foo(String s);\n" +
1370
			"}\n"
1371
		);
1372
		IJavaElement[] elements = new IJavaElement[2];
1373
		elements[0] = selectMethod(this.workingCopies[0], "@inheritDoc", 1);
1374
		elements[1] = selectMethod(this.workingCopies[0], "@inheritDoc", 2);
1375
		assertElementsEqual("Invalid selection(s)",
1376
			"foo(int) [in X [in [Working copy] X.java [in b171019 [in <project root> [in Tests]]]]]\n" + 
1377
			"foo(String) [in Y [in [Working copy] X.java [in b171019 [in <project root> [in Tests]]]]]",
1378
			elements
1379
		);
1380
	}
1381
	
1382
	public void testBug171019c() throws CoreException {
1383
		this.wcOwner = new WorkingCopyOwner() {};
1384
		this.workingCopies = new ICompilationUnit[1];
1385
		this.workingCopies[0] = getWorkingCopy("/Tests/b171019/X.java",
1386
			"package b171019;\n" +
1387
			"interface X1 {\n" +
1388
			"   /**\n" +
1389
			"	 * Main desc of foo in X1..\n" +
1390
			"	 */\n" +
1391
			"	void foo(int x);\n" +
1392
			"}\n" +
1393
			"interface X2 {\n" +
1394
			"   /**\n" +
1395
			"	 * Main desc of foo in X2..\n" +
1396
			"	 */\n" +
1397
			"	void foo(int x);\n" +
1398
			"}\n" +
1399
			"class X implements X1 {\n" +
1400
			"   /**\n" +
1401
			"	 * X desc of foo..\n" +
1402
			"	 */\n" +
1403
			"	void foo(int x){}\n" +
1404
			"}\n" +
1405
			"class Y extends X implements X2 {\n" +
1406
			"   /**\n" +
1407
			"	 * {@inheritDoc}\n" +	// should navigate to X2.foo(int)
1408
			"	 */\n" +
1409
			"	void foo(int x);\n\n" +
1410
			"}\n"
1411
		);
1412
		IJavaElement[] elements = new IJavaElement[1];
1413
		elements[0] = selectMethod(this.workingCopies[0], "@inheritDoc", 1);
1414
		assertElementsEqual("Invalid selection(s)",
1415
			"foo(int) [in X2 [in [Working copy] X.java [in b171019 [in <project root> [in Tests]]]]]",
1416
			elements
1417
		);
1418
	}
1419
	
1420
	public void testBug171019d() throws CoreException {
1421
		this.wcOwner = new WorkingCopyOwner() {};
1422
		this.workingCopies = new ICompilationUnit[1];
1423
		this.workingCopies[0] = getWorkingCopy("/Tests/b171019/X.java",
1424
			"package b171019;\n" +
1425
			"interface X1 {\n" +
1426
			"   /**\n" +
1427
			"	 * Main desc of foo in X1..\n" +
1428
			"	 */\n" +
1429
			"	void foo(int x);\n" +
1430
			"}\n" +
1431
			"interface X2 {\n" +
1432
			"	void foo(int x);\n" +
1433
			"}\n" +
1434
			"class X implements X1 {\n" +
1435
			"   /**\n" +
1436
			"	 * X desc of foo..\n" +
1437
			"	 */\n" +
1438
			"	void foo(int x){}\n" +
1439
			"}\n" +
1440
			"class Y extends X implements X2 {\n" +
1441
			"   /**\n" +
1442
			"	 * {@inheritDoc}\n" +	// should navigate to X.foo(int)
1443
			"	 */\n" +
1444
			"	void foo(int x);\n\n" +
1445
			"}\n"
1446
		);
1447
		IJavaElement[] elements = new IJavaElement[1];
1448
		elements[0] = selectMethod(this.workingCopies[0], "@inheritDoc", 1);
1449
		assertElementsEqual("Invalid selection(s)",
1450
			"foo(int) [in X [in [Working copy] X.java [in b171019 [in <project root> [in Tests]]]]]",
1451
			elements
1452
		);
1453
	}
1454
	
1455
	public void testBug171019e() throws CoreException {
1456
		this.wcOwner = new WorkingCopyOwner() {};
1457
		this.workingCopies = new ICompilationUnit[1];
1458
		this.workingCopies[0] = getWorkingCopy("/Tests/b171019/X.java",
1459
			"package b171019;\n" +
1460
			"interface X {\n" +
1461
			"   /**\n" +
1462
			"	 * Main desc of foo..\n" +
1463
			"	 */\n" +
1464
			"	void foo(int x);\n" +
1465
			"}\n" +
1466
			"interface Y {\n" +
1467
			"	void foo(String str);\n" +
1468
			"}\n" +
1469
			"abstract class Z implements X, Y {\n" +
1470
			"	/**\n" +
1471
			"	 * {@inheritDoc}\n" +	// navigates to X.foo(int)
1472
			"	 */\n" +
1473
			"	void foo(int x) {\n" +
1474
			"	}\n" +
1475
			"}"
1476
		);
1477
		IJavaElement[] elements = new IJavaElement[1];
1478
		elements[0] = selectMethod(this.workingCopies[0], "@inheritDoc", 1);
1479
		assertElementsEqual("Invalid selection(s)",
1480
			"foo(int) [in X [in [Working copy] X.java [in b171019 [in <project root> [in Tests]]]]]",
1481
			elements
1482
		);
1483
	}
1314
}
1484
}

Return to bug 171019