diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMatch.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMatch.java index ba3ad1cd3b3..607fc5670ee 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMatch.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMatch.java @@ -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; + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java index d52c3fed8d8..3e659d76b20 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java @@ -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; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties index 800cf1b0104..946c0cbf1a2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties @@ -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 diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java index 45ff1824971..88147b3f600 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java @@ -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); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResult.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResult.java index c1e17273238..047a94bd09d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResult.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResult.java @@ -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 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); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/HideReadOnlyReferences.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/HideReadOnlyReferences.java new file mode 100644 index 00000000000..f24eefa68c4 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/HideReadOnlyReferences.java @@ -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; + } +}