mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 15:05:36 +02:00
Bug 473576 - If the enclosing element of a search result is a class
member, include the class name in the search view Change-Id: Idbf86a22c9000328aecbab50f3f562f721bb64f6 Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
This commit is contained in:
parent
3b4d359fa6
commit
7237fa8ac6
1 changed files with 9 additions and 1 deletions
|
@ -16,6 +16,7 @@ package org.eclipse.cdt.internal.ui.search;
|
||||||
import org.eclipse.jface.viewers.StyledString;
|
import org.eclipse.jface.viewers.StyledString;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.IStructure;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.model.TranslationUnit;
|
import org.eclipse.cdt.internal.core.model.TranslationUnit;
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ public class CSearchTreeLabelProvider extends CSearchLabelProvider {
|
||||||
String enclosingName = ""; //$NON-NLS-1$
|
String enclosingName = ""; //$NON-NLS-1$
|
||||||
ICElement enclosingElement = lineElement.getMatches()[0].getEnclosingElement();
|
ICElement enclosingElement = lineElement.getMatches()[0].getEnclosingElement();
|
||||||
if (fPage.isShowEnclosingDefinitions() && enclosingElement != null) {
|
if (fPage.isShowEnclosingDefinitions() && enclosingElement != null) {
|
||||||
enclosingName = enclosingElement.getElementName() + ", "; //$NON-NLS-1$
|
enclosingName = getElementDescription(enclosingElement) + ", "; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
Integer lineNumber = lineElement.getLineNumber();
|
Integer lineNumber = lineElement.getLineNumber();
|
||||||
String prefix = Messages.format(CSearchMessages.CSearchResultCollector_line, enclosingName, lineNumber);
|
String prefix = Messages.format(CSearchMessages.CSearchResultCollector_line, enclosingName, lineNumber);
|
||||||
|
@ -65,4 +66,11 @@ public class CSearchTreeLabelProvider extends CSearchLabelProvider {
|
||||||
return location.append(super.getStyledText(element));
|
return location.append(super.getStyledText(element));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getElementDescription(ICElement element) {
|
||||||
|
ICElement parent = element.getParent();
|
||||||
|
if (parent instanceof IStructure) {
|
||||||
|
return parent.getElementName() + "::" + element.getElementName(); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
return element.getElementName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue