mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 09:55:29 +02:00
Bug 312515: Fix selection for qualified names in info control.
This commit is contained in:
parent
2900e91389
commit
7a11f618c6
1 changed files with 25 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2009 IBM Corporation and others.
|
* Copyright (c) 2000, 2010 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.text;
|
package org.eclipse.cdt.internal.ui.text;
|
||||||
|
|
||||||
|
@ -68,13 +69,13 @@ import org.eclipse.cdt.internal.ui.util.StringMatcher;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractInformationControl extends PopupDialog implements IInformationControl, IInformationControlExtension, IInformationControlExtension2, DisposeListener {
|
public abstract class AbstractInformationControl extends PopupDialog implements IInformationControl, IInformationControlExtension, IInformationControlExtension2, DisposeListener {
|
||||||
|
private final String COLON_COLON = String.valueOf(Keywords.cpCOLONCOLON);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The NamePatternFilter selects the elements which
|
* The NamePatternFilter selects the elements which
|
||||||
* match the given string patterns.
|
* match the given string patterns.
|
||||||
*/
|
*/
|
||||||
protected class NamePatternFilter extends ViewerFilter {
|
protected class NamePatternFilter extends ViewerFilter {
|
||||||
private final String COLON_COLON = String.valueOf(Keywords.cpCOLONCOLON);
|
|
||||||
|
|
||||||
public NamePatternFilter() {
|
public NamePatternFilter() {
|
||||||
}
|
}
|
||||||
|
@ -91,11 +92,7 @@ public abstract class AbstractInformationControl extends PopupDialog implements
|
||||||
|
|
||||||
String matchName= ((ILabelProvider) treeViewer.getLabelProvider()).getText(element);
|
String matchName= ((ILabelProvider) treeViewer.getLabelProvider()).getText(element);
|
||||||
if (matchName != null) {
|
if (matchName != null) {
|
||||||
if (matcher.match(matchName))
|
if (nameMatches(matchName, matcher))
|
||||||
return true;
|
|
||||||
// check for qualified name
|
|
||||||
int idx= matchName.lastIndexOf(COLON_COLON);
|
|
||||||
if (idx >= 0 && matcher.match(matchName.substring(idx+COLON_COLON.length())))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,19 +419,19 @@ public abstract class AbstractInformationControl extends PopupDialog implements
|
||||||
|
|
||||||
private ICElement findElement(TreeItem[] items) {
|
private ICElement findElement(TreeItem[] items) {
|
||||||
ILabelProvider labelProvider= (ILabelProvider)fTreeViewer.getLabelProvider();
|
ILabelProvider labelProvider= (ILabelProvider)fTreeViewer.getLabelProvider();
|
||||||
for (TreeItem item2 : items) {
|
for (TreeItem treeItem : items) {
|
||||||
Object item= item2.getData();
|
Object data= treeItem.getData();
|
||||||
ICElement element= null;
|
ICElement element= null;
|
||||||
if (item instanceof ICElement) {
|
if (data instanceof ICElement) {
|
||||||
element= (ICElement)item;
|
element= (ICElement)data;
|
||||||
if (fStringMatcher == null)
|
if (fStringMatcher == null)
|
||||||
return element;
|
return element;
|
||||||
|
|
||||||
String label= labelProvider.getText(element);
|
String label= labelProvider.getText(element);
|
||||||
if (fStringMatcher.match(label))
|
if (label != null && nameMatches(label, fStringMatcher))
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
element= findElement(item2.getItems());
|
element= findElement(treeItem.getItems());
|
||||||
if (element != null)
|
if (element != null)
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
@ -677,4 +674,19 @@ public abstract class AbstractInformationControl extends PopupDialog implements
|
||||||
composite.setTabList(new Control[] { fViewMenuButtonComposite, fTreeViewer.getTree() });
|
composite.setTabList(new Control[] { fViewMenuButtonComposite, fTreeViewer.getTree() });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether a given name is selected by the matcher
|
||||||
|
*/
|
||||||
|
boolean nameMatches(String name, StringMatcher matcher) {
|
||||||
|
if (matcher.match(name))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Check last segment of a qualified name
|
||||||
|
int idx= name.lastIndexOf(COLON_COLON);
|
||||||
|
if (idx >= 0 && matcher.match(name.substring(idx+COLON_COLON.length())))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue