1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 437067 - Hide read-only references in Search view

Change-Id: I0f6a864342d54dd3bae6563eba6ce72273d99647
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/28287
Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
Tested-by: Hudson CI
This commit is contained in:
Marc-Andre Laperle 2014-06-10 12:09:07 -04:00
parent 976806367d
commit 1f29931ff1
6 changed files with 91 additions and 6 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2009 QNX Software Systems and others.
* Copyright (c) 2006, 2014 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors:
* QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Marc-Andre Laperle (Ericsson)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.search;
@ -20,6 +21,7 @@ import org.eclipse.cdt.core.index.IIndexFileLocation;
*/
public class CSearchMatch extends Match {
private boolean fIsPolymorphicCall;
private boolean fIsWriteAccess;
public CSearchMatch(CSearchElement elem, int offset, int length) {
super(elem, offset, length);
@ -48,4 +50,12 @@ public class CSearchMatch extends Match {
public boolean isPolymorphicCall() {
return fIsPolymorphicCall;
}
public void setIsWriteAccess() {
fIsWriteAccess = true;
}
boolean isWriteAccess() {
return fIsWriteAccess;
}
}

View file

@ -9,6 +9,7 @@
* IBM Corp. - Rational Software - initial implementation
* Anton Leherbauer (Wind River Systems)
* Andrey Eremchenko (LEDAS)
* Marc-Andre Laperle (Ericsson)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.search;
@ -85,6 +86,9 @@ public final class CSearchMessages extends NLS {
public static String HidePolymorphicCalls_actionLabel;
public static String HidePolymorphicCalls_description;
public static String HidePolymorphicCalls_name;
public static String HideReadOnlyReferences_actionLabel;
public static String HideReadOnlyReferences_description;
public static String HideReadOnlyReferences_name;
public static String PDOMSearchViewPage_ShowEnclosingDefinitions_actionLabel;
public static String PDOMSearchViewPage_ShowEnclosingDefinitions_description;
public static String PDOMSearchViewPageLocationColumn_label;

View file

@ -10,6 +10,7 @@
# Ed Swartz (Nokia)
# Anton Leherbauer (Wind River Systems)
# Andrey Eremchenko (LEDAS)
# Marc-Andre Laperle (Ericsson)
###############################################################################
group_declarations=Dec&larations
@ -88,6 +89,9 @@ CSearchMessages_IndexRunningIncompleteWarning=(incomplete or inaccurate results:
HidePolymorphicCalls_actionLabel=Hide Potential Method Calls
HidePolymorphicCalls_description=Hides potential method calls to virtual overriders
HidePolymorphicCalls_name=Potential Method Calls
HideReadOnlyReferences_actionLabel=Hide Read-Only References
HideReadOnlyReferences_description=Hides read-only references so that only references with write access are displayed
HideReadOnlyReferences_name=Read-only references
PDOMSearchViewPage_ShowEnclosingDefinitions_actionLabel=Show Enclosing Definitions
PDOMSearchViewPage_ShowEnclosingDefinitions_description=Shows enclosing definitions for matches
PDOMSearchViewPageLocationColumn_label=Location

View file

@ -11,6 +11,7 @@
* Ed Swartz (Nokia)
* Andrey Eremchenko (LEDAS)
* Sergey Prigogin (Google)
* Marc-Andre Laperle (Ericsson)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.search;
@ -331,6 +332,9 @@ public abstract class CSearchQuery implements ISearchQuery {
CSearchMatch match = new CSearchMatch(searchElement, offset, length);
if (lineMatch.isPolymorphicCall())
match.setIsPolymorphicCall();
if (lineMatch.isWriteAccess()) {
match.setIsWriteAccess();
}
result.addMatch(match);
}
}
@ -489,6 +493,9 @@ public abstract class CSearchQuery implements ISearchQuery {
int offset = lineMatch.getOffset();
int length = lineMatch.getLength();
CSearchMatch match = new CSearchMatch(searchElement, offset, length);
if (lineMatch.isWriteAccess()) {
match.setIsWriteAccess();
}
result.addMatch(match);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2009 QNX Software Systems and others.
* Copyright (c) 2006, 2014 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -10,6 +10,7 @@
* Markus Schorn (Wind River Systems)
* Ed Swartz (Nokia)
* Sergey Prigogin (Google)
* Marc-Andre Laperle (Ericsson)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.search;
@ -48,8 +49,8 @@ import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
*/
public class CSearchResult extends AbstractTextSearchResult implements IEditorMatchAdapter, IFileMatchAdapter {
private static final String KEY_SHOW_POLYMORPHIC_CALLS = "ShowPolymorphicCalls"; //$NON-NLS-1$
final static MatchFilter[] ALL_FILTERS = new MatchFilter[] { HidePolymorphicCalls.FILTER };
final static MatchFilter[] NO_FILTERS = {};
private static final String KEY_HIDE_READ_ONLY_REFERENCES = "HideReadOnlyReferences"; //$NON-NLS-1$
final static MatchFilter[] ALL_FILTERS = new MatchFilter[] { HidePolymorphicCalls.FILTER, HideReadOnlyReferences.READ_ONLY_FILTER };
private CSearchQuery query;
private boolean indexerBusy;
@ -216,10 +217,14 @@ public class CSearchResult extends AbstractTextSearchResult implements IEditorMa
public MatchFilter[] getActiveMatchFilters() {
MatchFilter[] result = super.getActiveMatchFilters();
if (result == null) {
List<MatchFilter> filters = new ArrayList<>();
if (CUIPlugin.getDefault().getDialogSettings().getBoolean(KEY_SHOW_POLYMORPHIC_CALLS)) {
return ALL_FILTERS;
filters.add(HidePolymorphicCalls.FILTER);
}
return NO_FILTERS;
if (CUIPlugin.getDefault().getDialogSettings().getBoolean(KEY_HIDE_READ_ONLY_REFERENCES)) {
filters.add(HideReadOnlyReferences.READ_ONLY_FILTER);
}
return filters.toArray(new MatchFilter[filters.size()]);
}
return result;
}
@ -227,12 +232,17 @@ public class CSearchResult extends AbstractTextSearchResult implements IEditorMa
@Override
public void setActiveMatchFilters(MatchFilter[] filters) {
boolean showPoly= false;
boolean hideReadOnly= false;
for (int i = 0; i < filters.length; i++) {
if (filters[i] == HidePolymorphicCalls.FILTER) {
showPoly= true;
}
if (filters[i] == HideReadOnlyReferences.READ_ONLY_FILTER) {
hideReadOnly = true;
}
}
CUIPlugin.getDefault().getDialogSettings().put(KEY_SHOW_POLYMORPHIC_CALLS, showPoly);
CUIPlugin.getDefault().getDialogSettings().put(KEY_HIDE_READ_ONLY_REFERENCES, hideReadOnly);
super.setActiveMatchFilters(filters);
}
}

View file

@ -0,0 +1,50 @@
/*******************************************************************************
* Copyright (c) 2014 Ericsson, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Marc-Andre Laperle - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.search;
import org.eclipse.search.ui.text.Match;
import org.eclipse.search.ui.text.MatchFilter;
/**
* A filter class that implements hiding the Read-only references.
*/
public class HideReadOnlyReferences extends MatchFilter {
public static final MatchFilter READ_ONLY_FILTER = new HideReadOnlyReferences();
public HideReadOnlyReferences() {
super();
}
@Override
public boolean filters(Match match) {
return match instanceof CSearchMatch && !((CSearchMatch) match).isWriteAccess();
}
@Override
public String getActionLabel() {
return CSearchMessages.HideReadOnlyReferences_actionLabel;
}
@Override
public String getDescription() {
return CSearchMessages.HideReadOnlyReferences_description;
}
@Override
public String getID() {
return "HideReadOnlyReferences"; //$NON-NLS-1$
}
@Override
public String getName() {
return CSearchMessages.HideReadOnlyReferences_name;
}
}