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 / +78 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 1106-1112 Link Here
1106
			}
1106
			}
1107
			this.acceptedAnswer = true;
1107
			this.acceptedAnswer = true;
1108
		} else if (binding instanceof MethodBinding) {
1108
		} else if (binding instanceof MethodBinding) {
1109
			MethodBinding methodBinding = (MethodBinding) binding;
1109
			MethodBinding methodBinding = getCorrectMethodBinding((MethodBinding) binding);
1110
			this.noProposal = false;
1110
			this.noProposal = false;
1111
1111
1112
			boolean isValuesOrValueOf = false;
1112
			boolean isValuesOrValueOf = false;
Lines 1608-1611 Link Here
1608
1608
1609
		return false;
1609
		return false;
1610
	}
1610
	}
1611
	
1612
	private MethodBinding getCorrectMethodBinding(MethodBinding binding) {
1613
		if (this.parser.javadocParser instanceof SelectionJavadocParser) {
1614
			if (((SelectionJavadocParser)this.parser.javadocParser).inheritDocTagSelected){
1615
				ReferenceBinding superclass = binding.declaringClass.superclass();
1616
				try {
1617
					MethodBinding res = null;
1618
					res = findOverriddenMethodInHierarchy(superclass, binding);
1619
					if (res != null)
1620
						return res;
1621
					if (!binding.isConstructor()) {
1622
						ReferenceBinding[] superInterfaces= binding.declaringClass.superInterfaces();
1623
						for (int i= 0; i < superInterfaces.length; i++) {
1624
							res= findOverriddenMethodInHierarchy(superInterfaces[i], binding);
1625
							if (res != null) {
1626
								return res;
1627
							}
1628
						}
1629
					}
1630
					
1631
				} catch (JavaModelException e) {
1632
					return null;
1633
				}
1634
			}
1635
		}
1636
		return binding;
1637
	}
1638
	
1639
	private MethodBinding findOverriddenMethodInType(ReferenceBinding overriddenType, MethodBinding overriding) throws JavaModelException {
1640
		if (overriddenType == null)
1641
			return null;
1642
		MethodBinding[] overriddenMethods= overriddenType.availableMethods();
1643
		LookupEnvironment lookupEnv = this.lookupEnvironment;
1644
		if (lookupEnv != null && overriddenMethods != null) {
1645
			for (int i= 0; i < overriddenMethods.length; i++) {
1646
				if (lookupEnv.methodVerifier().isMethodSubsignature(overriding, overriddenMethods[i])) {
1647
					return overriddenMethods[i];
1648
				}
1649
			}
1650
		}
1651
		return null;
1652
	}
1653
	
1654
	/**
1655
	 * Finds the directly overridden method in a type and its super types. First the super class is examined and then the implemented interfaces.
1656
	 * With generics it is possible that 2 methods in the same type are overidden at the same time. In that case, the first overridden method found is returned.
1657
	 * 	@param type The type to find methods in
1658
	 * @param overriding The overriding method
1659
	 * @return The first overridden method or <code>null</code> if no method is overridden
1660
	 * @throws JavaModelException
1661
	 */
1662
	private MethodBinding findOverriddenMethodInHierarchy(ReferenceBinding type, MethodBinding overriding) throws JavaModelException {
1663
		if (type == null)
1664
			return null;
1665
		MethodBinding method= findOverriddenMethodInType(type, overriding);
1666
		if (method != null) {
1667
			return method;
1668
		}
1669
		ReferenceBinding superClass= type.superclass();
1670
		if (superClass != null) {
1671
			MethodBinding res=  findOverriddenMethodInHierarchy(superClass, overriding);
1672
			if (res != null) {
1673
				return res;
1674
			}
1675
		}
1676
		if (!overriding.isConstructor()) {
1677
			ReferenceBinding[] superInterfaces= type.superInterfaces();
1678
			for (int i= 0; i < superInterfaces.length; i++) {
1679
				MethodBinding res= findOverriddenMethodInHierarchy(superInterfaces[i], overriding);
1680
				if (res != null) {
1681
					return res;
1682
				}
1683
			}
1684
		}
1685
		return method;
1686
	}
1611
}
1687
}
(-)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 / +10 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
	protected void parseInheritDocTag() {
197
		if (this.tagSourceStart == this.selectionStart && this.tagSourceEnd == this.selectionEnd)
198
			this.inheritDocTagSelected = true;
199
	}
191
}
200
}
(-)compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java (+5 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
							parseInheritDocTag();
571
							break;
572
							break;
572
						default:
573
						default:
573
							valid = false;
574
							valid = false;
Lines 692-697 Link Here
692
		return valid;
693
		return valid;
693
	}
694
	}
694
695
696
	protected void parseInheritDocTag() {
697
		// do nothing
698
	}
699
695
	/*
700
	/*
696
	 * Parse @param tag declaration and flag missing description if corresponding option is enabled
701
	 * Parse @param tag declaration and flag missing description if corresponding option is enabled
697
	 */
702
	 */

Return to bug 171019