[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] More C/C++ Searc framework
|
This patch contains more of the C/C++
framework. Along with the beginning of the implementation regarding
the MatchLocator and patterns.
Also included is some of the framework
to support the search pane and sorting search results.
-AndrewAttachment:
cdt.ui.icons.zip
Description: Zip archive
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.112
diff -u -r1.112 ChangeLog
--- ChangeLog 27 Jun 2003 14:31:32 -0000 1.112
+++ ChangeLog 27 Jun 2003 20:41:17 -0000
@@ -1,3 +1,25 @@
+2003-06-27 Andrew Niefer
+ Changes for C/C++ Search:
+ Added:
+ * src/org/eclipse/cdt/internal/ui/search/CElementLabels.java
+ * src/org/eclipse/cdt/internal/ui/search/CSearchResultLabelProvider.java
+ * src/org/eclipse/cdt/internal/ui/search/CSearchViewActionGroup.java
+ * src/org/eclipse/cdt/internal/ui/search/ElementNameSorter.java
+ * src/org/eclipse/cdt/internal/ui/search/GotoMarkerAction.java
+ * src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java
+ * src/org/eclipse/cdt/internal/ui/search/ParentNameSorter.java
+ * src/org/eclipse/cdt/internal/ui/search/PathNameSorter.java
+ * icons/full/clcl16/search_sortmatch.gif
+ * icons/full/obj16/search_decl_obj.gif
+ * icons/full/obj16/search_ref_obj.gif
+ Modified:
+ * src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java
+ * src/org/eclipse/cdt/internal/ui/search/CSearchPage.java
+ * src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java
+ * src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties.java
+ * plugin.xml
+ * plugin.properties
+
2003-06-26 Sean Evoy
Added a tab to the new standard make project wizard and CNature project
property page. User interacts with two list controls to add include paths
Index: plugin.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/plugin.properties,v
retrieving revision 1.20
diff -u -r1.20 plugin.properties
--- plugin.properties 20 Jun 2003 17:00:19 -0000 1.20
+++ plugin.properties 27 Jun 2003 20:41:17 -0000
@@ -90,3 +90,13 @@
ToolName.archiver = Archiver
ToolName.linker = Linker
ToolName.command = Command Line
+
+#C/C++ Search
+CSearchPage.label= C/C++ Search
+ElementNameSorter.label= &Name
+ElementNameSorter.tooltip= Sort the view by C Element Name
+ParentNameSorter.label= &Parent Name
+ParentNameSorter.tooltip= Sort the view by C Element Parent Name
+PathNameSorter.label= P&ath
+PathNameSorter.tooltip= Sort the view by Resource Path
+
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/plugin.xml,v
retrieving revision 1.30
diff -u -r1.30 plugin.xml
--- plugin.xml 23 Jun 2003 14:36:26 -0000 1.30
+++ plugin.xml 27 Jun 2003 20:41:17 -0000
@@ -933,12 +933,39 @@
point="org.eclipse.search.searchPages">
<page
showScopeSection="true"
- label="C/CPP Search"
+ label="%CSearchPage.label"
icon="icons/full/obj16/csearch_obj.gif"
class="org.eclipse.cdt.internal.ui.search.CSearchPage"
sizeHint="460, 160"
id="org.eclipse.cdt.ui.CSearchPage">
</page>
+ </extension>
+ <extension
+ point="org.eclipse.search.searchResultSorters">
+ <sorter
+ pageId="org.eclipse.cdt.ui.CSearchPage"
+ label="%ElementNameSorter.label"
+ class="org.eclipse.cdt.internal.ui.search.ElementNameSorter"
+ tooltip="%ElementNameSorter.tooltip"
+ icon="icons/full/clcl16/search_sortmatch.gif"
+ id="org.eclipse.search.internal.ui.ElementNameSorter" >
+ </sorter>
+ <sorter
+ id="org.eclipse.search.internal.ui.ParentNameSorter"
+ pageId="org.eclipse.cdt.ui.CSearchPage"
+ label="%ParentNameSorter.label"
+ tooltip="%ParentNameSorter.tooltip"
+ icon="icons/full/clcl16/search_sortmatch.gif"
+ class="org.eclipse.cdt.internal.ui.search.ParentNameSorter">
+ </sorter>
+ <sorter
+ id="org.eclipse.search.internal.ui.PathNameSorter"
+ pageId="org.eclipse.cdt.ui.JavaSearchPage"
+ label="%PathNameSorter.label"
+ tooltip="%PathNameSorter.tooltip"
+ icon="icons/full/clcl16/search_sortmatch.gif"
+ class="org.eclipse.cdt.internal.ui.search.PathNameSorter">
+ </sorter>
</extension>
</plugin>
Index: icons/full/clcl16/search_sortmatch.gif
===================================================================
RCS file: icons/full/clcl16/search_sortmatch.gif
diff -N icons/full/clcl16/search_sortmatch.gif
Binary files /dev/null and search_sortmatch.gif differ
Index: icons/full/obj16/search_decl_obj.gif
===================================================================
RCS file: icons/full/obj16/search_decl_obj.gif
diff -N icons/full/obj16/search_decl_obj.gif
Binary files /dev/null and search_decl_obj.gif differ
Index: icons/full/obj16/search_ref_obj.gif
===================================================================
RCS file: icons/full/obj16/search_ref_obj.gif
diff -N icons/full/obj16/search_ref_obj.gif
Binary files /dev/null and search_ref_obj.gif differ
Index: src/org/eclipse/cdt/internal/ui/CPluginImages.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java,v
retrieving revision 1.17
diff -u -r1.17 CPluginImages.java
--- src/org/eclipse/cdt/internal/ui/CPluginImages.java 9 Jun 2003 19:22:19 -0000 1.17
+++ src/org/eclipse/cdt/internal/ui/CPluginImages.java 27 Jun 2003 20:41:18 -0000
@@ -164,6 +164,13 @@
public static final String IMG_BUILD_TOOL = NAME_PREFIX + "config-tool.gif";
public static final ImageDescriptor DESC_BUILD_TOOL = createManaged(T_BUILD, IMG_BUILD_TOOL);
+ //for search
+ public static final String IMG_OBJS_SEARCH_REF = NAME_PREFIX + "search_ref_obj.gif";
+ public static final String IMG_OBJS_SEARCH_DECL = NAME_PREFIX + "search_decl_obj.gif";
+
+ public static final ImageDescriptor DESC_OBJS_SEARCH_DECL = createManaged(T_OBJ, IMG_OBJS_SEARCH_DECL);
+ public static final ImageDescriptor DESC_OBJS_SEARCH_REF = createManaged(T_OBJ, IMG_OBJS_SEARCH_REF);
+
public static void initialize() {
//createManaged(registry, T_OBJ, IMG_OBJS_TUNIT);
//createManaged(registry, T_OBJ, IMG_OBJS_FIELD);
Index: src/org/eclipse/cdt/internal/ui/search/CElementLabels.java
===================================================================
RCS file: src/org/eclipse/cdt/internal/ui/search/CElementLabels.java
diff -N src/org/eclipse/cdt/internal/ui/search/CElementLabels.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/internal/ui/search/CElementLabels.java 27 Jun 2003 20:41:18 -0000
@@ -0,0 +1,362 @@
+/*******************************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Corp. - Rational Software - initial implementation
+ ******************************************************************************/
+/*
+ * Created on Jun 24, 2003
+ */
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IMethod;
+import org.eclipse.cdt.core.model.IStructure;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+/**
+ * @author aniefer
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class CElementLabels {
+
+ /**
+ * Method names contain parameter types.
+ * e.g. <code>foo(int)</code>
+ */
+ public final static int M_PARAMETER_TYPES= 1 << 0;
+
+ /**
+ * Method names contain parameter names.
+ * e.g. <code>foo(index)</code>
+ */
+ public final static int M_PARAMETER_NAMES= 1 << 1;
+
+ /**
+ * Method names contain thrown exceptions.
+ * e.g. <code>foo throw( IOException )</code>
+ */
+ public final static int M_EXCEPTIONS= 1 << 2;
+
+ /**
+ * Method names contain return type (appended)
+ * e.g. <code>foo : int</code>
+ */
+ public final static int M_APP_RETURNTYPE= 1 << 3;
+
+ /**
+ * Method names contain return type (appended)
+ * e.g. <code>int foo</code>
+ */
+ public final static int M_PRE_RETURNTYPE= 1 << 4;
+
+ /**
+ * Method names are fully qualified.
+ * e.g. <code>java.util.Vector.size</code>
+ */
+ public final static int M_FULLY_QUALIFIED= 1 << 5;
+
+ /**
+ * Method names are post qualified.
+ * e.g. <code>size - java.util.Vector</code>
+ */
+ public final static int M_POST_QUALIFIED= 1 << 6;
+
+ /**
+ * Initializer names are fully qualified.
+ * e.g. <code>java.util.Vector.{ ... }</code>
+ */
+ public final static int I_FULLY_QUALIFIED= 1 << 7;
+
+ /**
+ * Type names are post qualified.
+ * e.g. <code>{ ... } - java.util.Map</code>
+ */
+ public final static int I_POST_QUALIFIED= 1 << 8;
+
+ /**
+ * Field names contain the declared type (appended)
+ * e.g. <code>int fHello</code>
+ */
+ public final static int F_APP_TYPE_SIGNATURE= 1 << 9;
+
+ /**
+ * Field names contain the declared type (prepended)
+ * e.g. <code>fHello : int</code>
+ */
+ public final static int F_PRE_TYPE_SIGNATURE= 1 << 10;
+
+ /**
+ * Fields names are fully qualified.
+ * e.g. <code>java.lang.System.out</code>
+ */
+ public final static int F_FULLY_QUALIFIED= 1 << 11;
+
+ /**
+ * Fields names are post qualified.
+ * e.g. <code>out - java.lang.System</code>
+ */
+ public final static int F_POST_QUALIFIED= 1 << 12;
+
+ /**
+ * Type names are fully qualified.
+ * e.g. <code>java.util.Map.MapEntry</code>
+ */
+ public final static int T_FULLY_QUALIFIED= 1 << 13;
+
+ /**
+ * Type names are type container qualified.
+ * e.g. <code>Map.MapEntry</code>
+ */
+ public final static int T_CONTAINER_QUALIFIED= 1 << 14;
+
+ /**
+ * Type names are post qualified.
+ * e.g. <code>MapEntry - java.util.Map</code>
+ */
+ public final static int T_POST_QUALIFIED= 1 << 15;
+
+ /**
+ * Declarations (import container / declarartion, package declarartion) are qualified.
+ * e.g. <code>java.util.Vector.class/import container</code>
+ */
+ public final static int D_QUALIFIED= 1 << 16;
+
+ /**
+ * Declarations (import container / declarartion, package declarartion) are post qualified.
+ * e.g. <code>import container - java.util.Vector.class</code>
+ */
+ public final static int D_POST_QUALIFIED= 1 << 17;
+
+ /**
+ * Class file names are fully qualified.
+ * e.g. <code>java.util.Vector.class</code>
+ */
+ public final static int CF_QUALIFIED= 1 << 18;
+
+ /**
+ * Class file names are post qualified.
+ * e.g. <code>Vector.class - java.util</code>
+ */
+ public final static int CF_POST_QUALIFIED= 1 << 19;
+
+ /**
+ * Compilation unit names are fully qualified.
+ * e.g. <code>java.util.Vector.java</code>
+ */
+ public final static int CU_QUALIFIED= 1 << 20;
+
+ /**
+ * Compilation unit names are post qualified.
+ * e.g. <code>Vector.java - java.util</code>
+ */
+ public final static int CU_POST_QUALIFIED= 1 << 21;
+
+ /**
+ * Package names are qualified.
+ * e.g. <code>MyProject/src/java.util</code>
+ */
+ public final static int P_QUALIFIED= 1 << 22;
+
+ /**
+ * Package names are post qualified.
+ * e.g. <code>java.util - MyProject/src</code>
+ */
+ public final static int P_POST_QUALIFIED= 1 << 23;
+
+ /**
+ * Package Fragment Roots contain variable name if from a variable.
+ * e.g. <code>JRE_LIB - c:\java\lib\rt.jar</code>
+ */
+ public final static int ROOT_VARIABLE= 1 << 24;
+
+ /**
+ * Package Fragment Roots contain the project name if not an archive (prepended).
+ * e.g. <code>MyProject/src</code>
+ */
+ public final static int ROOT_QUALIFIED= 1 << 25;
+
+ /**
+ * Package Fragment Roots contain the project name if not an archive (appended).
+ * e.g. <code>src - MyProject</code>
+ */
+ public final static int ROOT_POST_QUALIFIED= 1 << 26;
+
+ /**
+ * Add root path to all elements except Package Fragment Roots and Java projects.
+ * e.g. <code>java.lang.Vector - c:\java\lib\rt.jar</code>
+ * Option only applies to getElementLabel
+ */
+ public final static int APPEND_ROOT_PATH= 1 << 27;
+
+ /**
+ * Add root path to all elements except Package Fragment Roots and Java projects.
+ * e.g. <code>java.lang.Vector - c:\java\lib\rt.jar</code>
+ * Option only applies to getElementLabel
+ */
+ public final static int PREPEND_ROOT_PATH= 1 << 28;
+
+ /**
+ * Package names are compressed.
+ * e.g. <code>o*.e*.search</code>
+ */
+ public final static int P_COMPRESSED= 1 << 29;
+
+ /**
+ * Post qualify referenced package fragement roots. For example
+ * <code>jdt.jar - org.eclipse.jdt.ui</code> if the jar is referenced
+ * from another project.
+ */
+ public final static int REFERENCED_ROOT_POST_QUALIFIED= 1 << 30;
+
+ /**
+ * Qualify all elements
+ */
+ public final static int ALL_FULLY_QUALIFIED= F_FULLY_QUALIFIED | M_FULLY_QUALIFIED | I_FULLY_QUALIFIED | T_FULLY_QUALIFIED | D_QUALIFIED | CF_QUALIFIED | CU_QUALIFIED | P_QUALIFIED | ROOT_QUALIFIED;
+
+ /**
+ * Post qualify all elements
+ */
+ public final static int ALL_POST_QUALIFIED= F_POST_QUALIFIED | M_POST_QUALIFIED | I_POST_QUALIFIED | T_POST_QUALIFIED | D_POST_QUALIFIED | CF_POST_QUALIFIED | CU_POST_QUALIFIED | P_POST_QUALIFIED | ROOT_POST_QUALIFIED;
+
+ /**
+ * Default options (M_PARAMETER_TYPES enabled)
+ */
+ public final static int ALL_DEFAULT= M_PARAMETER_TYPES;
+
+ /**
+ * Default qualify options (All except Root and Package)
+ */
+ public final static int DEFAULT_QUALIFIED= F_FULLY_QUALIFIED | M_FULLY_QUALIFIED | I_FULLY_QUALIFIED | T_FULLY_QUALIFIED | D_QUALIFIED | CF_QUALIFIED | CU_QUALIFIED;
+
+ /**
+ * Default post qualify options (All except Root and Package)
+ */
+ public final static int DEFAULT_POST_QUALIFIED= F_POST_QUALIFIED | M_POST_QUALIFIED | I_POST_QUALIFIED | T_POST_QUALIFIED | D_POST_QUALIFIED | CF_POST_QUALIFIED | CU_POST_QUALIFIED;
+
+
+ public final static String CONCAT_STRING= CSearchMessages.getString("CElementLabels.concat_string"); // " - "; //$NON-NLS-1$
+ public final static String COMMA_STRING = CSearchMessages.getString("CElementLabels.comma_string"); // ", "; //$NON-NLS-1$
+ public final static String DECL_STRING = CSearchMessages.getString("CElementLabels.declseparator_string"); // " "; // use for return type //$NON-NLS-1$
+
+ public static String getTextLabel(Object obj, int flags) {
+ if (obj instanceof ICElement) {
+ return getElementLabel((ICElement) obj, flags);
+ } else if (obj instanceof IAdaptable) {
+ IWorkbenchAdapter wbadapter= (IWorkbenchAdapter) ((IAdaptable)obj).getAdapter(IWorkbenchAdapter.class);
+ if (wbadapter != null) {
+ return wbadapter.getLabel(obj);
+ }
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ public static String getElementLabel(ICElement element, int flags) {
+ StringBuffer buf= new StringBuffer(60);
+ getElementLabel(element, flags, buf);
+ return buf.toString();
+ }
+
+ public static void getElementLabel(ICElement element, int flags, StringBuffer buf) {
+ int type= element.getElementType();
+
+ switch( type ){
+ case ICElement.C_METHOD :
+ getMethodLabel( (IMethod) element, flags, buf );
+ break;
+ case ICElement.C_CLASS:
+ case ICElement.C_STRUCT:
+ case ICElement.C_UNION:
+ case ICElement.C_ENUMERATION:
+ // getTypeLabel( (IType) element, flags, buf );
+ }
+ }
+
+ public static void getMethodLabel( IMethod method, int flags, StringBuffer buf ) {
+ //return type
+ if( getFlag( flags, M_PRE_RETURNTYPE ) && method.exists() && !method.isConstructor() ) {
+ buf.append( method.getReturnType() );
+ buf.append( ' ' );
+ }
+
+ //qualification
+ if( getFlag( flags, M_FULLY_QUALIFIED ) ){
+ getTypeLabel( method.getParent(), T_FULLY_QUALIFIED | (flags & P_COMPRESSED), buf );
+ buf.append( "::" );
+ }
+
+ buf.append( method.getElementName() );
+
+ //parameters
+ if( getFlag( flags, M_PARAMETER_TYPES | M_PARAMETER_NAMES ) ) {
+ buf.append('(');
+
+ String[] types = getFlag(flags, M_PARAMETER_TYPES) ? method.getParameterTypes() : null;
+ String[] names = null;//(getFlag(flags, M_PARAMETER_NAMES) && method.exists()) ? method.getParameterNames() : null;
+
+ int nParams = ( types != null ) ? types.length : names.length;
+
+ for (int i= 0; i < nParams; i++) {
+ if (i > 0) {
+ buf.append( COMMA_STRING ); //$NON-NLS-1$
+ }
+
+ if (types != null) {
+ buf.append( types[i] );
+ }
+
+ if (names != null) {
+ if (types != null) {
+ buf.append(' ');
+ }
+ buf.append( names[i] );
+ }
+ }
+ buf.append(')');
+ }
+
+ //exceptions
+ if( getFlag( flags, M_EXCEPTIONS ) && method.exists() ){
+ String [] types = method.getExceptions();
+ if (types.length > 0) {
+ buf.append(" throw( "); //$NON-NLS-1$
+ for (int i= 0; i < types.length; i++) {
+ if (i > 0) {
+ buf.append(COMMA_STRING);
+ }
+ buf.append( types[i] );
+ }
+ buf.append( " )" );
+ }
+ }
+
+ if( getFlag( flags, M_APP_RETURNTYPE ) && method.exists() && !method.isConstructor()) {
+ buf.append( DECL_STRING );
+ buf.append( method.getReturnType() );
+ }
+
+ // post qualification
+ if( getFlag(flags, M_POST_QUALIFIED)) {
+ buf.append( CONCAT_STRING );
+ getTypeLabel( method.getParent(), T_FULLY_QUALIFIED | (flags & P_COMPRESSED), buf );
+ }
+ }
+
+ public static void getTypeLabel(ICElement type, int flags, StringBuffer buf) {
+ if( !(type instanceof IStructure) ){
+ return;
+ }
+ }
+
+
+ private static boolean getFlag(int flags, int flag) {
+ return (flags & flag) != 0;
+ }
+}
Index: src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties,v
retrieving revision 1.1
diff -u -r1.1 CSearchMessages.properties
--- src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties 16 Jun 2003 17:35:44 -0000 1.1
+++ src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties 27 Jun 2003 20:41:18 -0000
@@ -39,32 +39,32 @@
SearchElementSelectionDialog.title=Search
SearchElementSelectionDialog.message=Select the element to search for.
-SearchResultCollector.match= 1 match
-SearchResultCollector.matches= {0} matches
-SearchResultCollector.done= Search done: {0}.
-SearchResultCollector.searching= Searching...
+CSearchResultCollector.match= 1 match
+CSearchResultCollector.matches= {0} matches
+CSearchResultCollector.done= Search done: {0}.
+CSearchResultCollector.searching= Searching...
Search.potentialMatchDialog.title.foundPotentialMatch= Search: Found 1 Inexact Match
Search.potentialMatchDialog.title.foundPotentialMatches= Search: Found {0} Inexact Matches
Search.potentialMatchDialog.message= Inexact matches were found and will be displayed with a different\nforeground color. This can be configured on the Search preference page.
-SearchPage.searchFor.label= Search For
-SearchPage.searchFor.type= &Type
-SearchPage.searchFor.method= &Method
-SearchPage.searchFor.field= &Field
-SearchPage.searchFor.package= &Package
-SearchPage.searchFor.constructor= Co&nstructor
-
-SearchPage.limitTo.label= Limit To
-SearchPage.limitTo.declarations= Dec&larations
-SearchPage.limitTo.implementors= &Implementors
-SearchPage.limitTo.references= &References
-SearchPage.limitTo.allOccurrences= All &Occurrences
-SearchPage.limitTo.readReferences= Read A&ccess
-SearchPage.limitTo.writeReferences= Writ&e Access
+CSearchPage.searchFor.label= Search For
+CSearchPage.searchFor.type= &Type
+CSearchPage.searchFor.method= &Method
+CSearchPage.searchFor.field= &Field
+CSearchPage.searchFor.namespace= N&amespace
+CSearchPage.searchFor.constructor= Co&nstructor
+
+CSearchPage.limitTo.label= Limit To
+CSearchPage.limitTo.declarations= Dec&larations
+CSearchPage.limitTo.implementors= &Implementors
+CSearchPage.limitTo.references= &References
+CSearchPage.limitTo.allOccurrences= All &Occurrences
+CSearchPage.limitTo.readReferences= Read A&ccess
+CSearchPage.limitTo.writeReferences= Writ&e Access
-SearchPage.expression.label= Se&arch string (* = any string, ? = any character):
-SearchPage.expression.caseSensitive= Case sens&itive
+CSearchPage.expression.label= Se&arch string (* = any string, ? = any character):
+CSearchPage.expression.caseSensitive= Case sens&itive
# Concatenate two working set names e.g. "Source, Lib"
SearchUtil.workingSetConcatenation= {0}, {1}
@@ -125,20 +125,20 @@
JavaSearchOperation.default_package=(default package)
# The first argument will be replaced by the pattern and the second by the scope
-JavaSearchOperation.singularDeclarationsPostfix={0} - 1 Declaration in {1}
-JavaSearchOperation.singularReferencesPostfix={0} - 1 Reference in {1}
-JavaSearchOperation.singularReadReferencesPostfix={0} - 1 Read Reference in {1}
-JavaSearchOperation.singularWriteReferencesPostfix={0} - 1 Write Reference in {1}
-JavaSearchOperation.singularImplementorsPostfix={0} - 1 Implementor in {1}
-JavaSearchOperation.singularOccurrencesPostfix={0} - 1 Occurrence in {1}
+CSearchOperation.singularDeclarationsPostfix={0} - 1 Declaration in {1}
+CSearchOperation.singularReferencesPostfix={0} - 1 Reference in {1}
+CSearchOperation.singularReadReferencesPostfix={0} - 1 Read Reference in {1}
+CSearchOperation.singularWriteReferencesPostfix={0} - 1 Write Reference in {1}
+CSearchOperation.singularImplementorsPostfix={0} - 1 Implementor in {1}
+CSearchOperation.singularOccurrencesPostfix={0} - 1 Occurrence in {1}
# The first argument will be replaced by the pattern, the second by the count and the last by the scope
-JavaSearchOperation.pluralDeclarationsPostfix={0} - {1} Declarations in {2}
-JavaSearchOperation.pluralReferencesPostfix={0} - {1} References in {2}
-JavaSearchOperation.pluralReadReferencesPostfix={0} - {1} Read References in {2}
-JavaSearchOperation.pluralWriteReferencesPostfix={0} - {1} Write References in {2}
-JavaSearchOperation.pluralImplementorsPostfix={0} - {1} Implementors in {2}
-JavaSearchOperation.pluralOccurrencesPostfix={0} - {1} Occurrences in {2}
+CSearchOperation.pluralDeclarationsPostfix={0} - {1} Declarations in {2}
+CSearchOperation.pluralReferencesPostfix={0} - {1} References in {2}
+CSearchOperation.pluralReadReferencesPostfix={0} - {1} Read References in {2}
+CSearchOperation.pluralWriteReferencesPostfix={0} - {1} Write References in {2}
+CSearchOperation.pluralImplementorsPostfix={0} - {1} Implementors in {2}
+CSearchOperation.pluralOccurrencesPostfix={0} - {1} Occurrences in {2}
# The first argument will be replaced by the element name and the second one by the file name
JavaSearchInFile.singularPostfix={0} - 1 Occurrence in {1}
@@ -154,9 +154,13 @@
JavaElementAction.operationUnavailable.field= The operation is unavailable on the current selection. Please select the name of a field.
JavaElementAction.operationUnavailable.interface= The operation is unavailable on the current selection. Please select the name of an interface.
-JavaSearchResultLabelProvider.potentialMatch= \ (inexact)
+CSearchResultLabelProvider.potentialMatch= \ (inexact)
WorkspaceScope= Workspace
WorkingSetScope= Working Set - {0}
SelectionScope= Selection
HierarchyScope= Hierarchy - {0}
+
+CElementLabels.concat_string=\ -\
+CElementLabels.comma_string=,\
+CElementLabels.declseparator_string=\ :\
\ No newline at end of file
Index: src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java,v
retrieving revision 1.1
diff -u -r1.1 CSearchOperation.java
--- src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java 16 Jun 2003 17:35:44 -0000 1.1
+++ src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java 27 Jun 2003 20:41:18 -0000
@@ -16,12 +16,15 @@
import java.lang.reflect.InvocationTargetException;
import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.search.ICSearchConstants;
import org.eclipse.cdt.core.search.ICSearchPattern;
import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.core.search.SearchEngine;
+import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
/**
@@ -48,7 +51,7 @@
_workspace = workspace;
_limitTo = limitTo;
_scope = scope;
- _scopeDecsription = scopeDescription;
+ _scopeDescription = scopeDescription;
_collector = collector;
_collector.setOperation( this );
}
@@ -70,16 +73,73 @@
}
}
+
+ /**
+ * @return
+ */
+ public String getSingularLabel() {
+ String desc = null;
+
+ if( _elementPattern != null ){
+ desc = _elementPattern.getElementName();
+ } else {
+ desc = _stringPattern;
+ }
+
+ String [] args = new String [] { desc, _scopeDescription };
+ switch( _limitTo ){
+ case ICSearchConstants.DECLARATIONS :
+ return CSearchMessages.getFormattedString( "CSearchOperation.singularDeclarationsPostfix", args ); //$NON_NLS-1$
+ case ICSearchConstants.REFERENCES :
+ return CSearchMessages.getFormattedString( "CSearchOperation.singularReferencesPostfix", args ); //$NON_NLS-1$
+ default:
+ return CSearchMessages.getFormattedString( "CSearchOperation.singularOccurencesPostfix", args ); //$NON_NLS-1$
+ }
+ }
+ /**
+ * @return
+ */
+ public String getPluralLabelPattern() {
+ String desc = null;
+
+ if( _elementPattern != null ){
+ desc = _elementPattern.getElementName();
+ } else {
+ desc = _stringPattern;
+ }
+
+ String [] args = new String [] { desc, "{0}", _scopeDescription };
+ switch( _limitTo ){
+ case ICSearchConstants.DECLARATIONS :
+ return CSearchMessages.getFormattedString( "CSearchOperation.pluralDeclarationsPostfix", args ); //$NON_NLS-1$
+ case ICSearchConstants.REFERENCES :
+ return CSearchMessages.getFormattedString( "CSearchOperation.pluralReferencesPostfix", args ); //$NON_NLS-1$
+ default:
+ return CSearchMessages.getFormattedString( "CSearchOperation.pluralOccurencesPostfix", args ); //$NON_NLS-1$
+ }
+ }
+
+ /**
+ * @return
+ */
+ public ImageDescriptor getImageDescriptor() {
+ if( _limitTo == ICSearchConstants.DECLARATIONS ){
+ return CPluginImages.DESC_OBJS_SEARCH_DECL;
+ } else {
+ return CPluginImages.DESC_OBJS_SEARCH_REF;
+ }
+ }
private CSearchResultCollector _collector;
private IWorkspace _workspace;
private ICElement _elementPattern;
private ICSearchScope _scope;
private String _stringPattern;
- private String _scopeDecsription;
+ private String _scopeDescription;
private boolean _caseSensitive;
private int _limitTo;
private int _searchFor;
+
}
Index: src/org/eclipse/cdt/internal/ui/search/CSearchPage.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java,v
retrieving revision 1.2
diff -u -r1.2 CSearchPage.java
--- src/org/eclipse/cdt/internal/ui/search/CSearchPage.java 27 Jun 2003 14:31:32 -0000 1.2
+++ src/org/eclipse/cdt/internal/ui/search/CSearchPage.java 27 Jun 2003 20:41:18 -0000
@@ -160,11 +160,9 @@
}
};
- fSearchFor[ TYPE ].addSelectionListener(cElementInitializer);
- fSearchFor[ FUNCTION ].addSelectionListener(cElementInitializer);
- fSearchFor[ MEMBER ].addSelectionListener(cElementInitializer);
- fSearchFor[CONSTRUCTOR].addSelectionListener(cElementInitializer);
- //fSearchFor[ PACKAGE ].addSelectionListener(cElementInitializer);
+ for( int i = 0; i < fSearchFor.length; i++ ){
+ fSearchFor[ i ].addSelectionListener( cElementInitializer );
+ }
setControl( result );
@@ -183,7 +181,7 @@
// Pattern text + info
Label label = new Label( result, SWT.LEFT );
- label.setText( CSearchMessages.getString( "SearchPage.expression.label" ) ); //$NON-NLS-1$
+ label.setText( CSearchMessages.getString( "CSearchPage.expression.label" ) ); //$NON-NLS-1$
gd = new GridData( GridData.BEGINNING );
gd.horizontalSpan = 2;
label.setLayoutData( gd );
@@ -210,7 +208,7 @@
// Ignore case checkbox
fCaseSensitive= new Button(result, SWT.CHECK);
- fCaseSensitive.setText(CSearchMessages.getString("SearchPage.expression.caseSensitive")); //$NON-NLS-1$
+ fCaseSensitive.setText(CSearchMessages.getString("CSearchPage.expression.caseSensitive")); //$NON-NLS-1$
gd= new GridData();
fCaseSensitive.setLayoutData(gd);
fCaseSensitive.addSelectionListener( new SelectionAdapter() {
@@ -259,7 +257,7 @@
private Control createLimitTo( Composite parent ) {
Group result = new Group(parent, SWT.NONE);
- result.setText( CSearchMessages.getString("SearchPage.limitTo.label") ); //$NON-NLS-1$
+ result.setText( CSearchMessages.getString("CSearchPage.limitTo.label") ); //$NON-NLS-1$
GridLayout layout = new GridLayout();
layout.numColumns = 2;
result.setLayout( layout );
@@ -315,7 +313,7 @@
private Control createSearchFor(Composite parent) {
Group result= new Group(parent, SWT.NONE);
- result.setText(CSearchMessages.getString("SearchPage.searchFor.label")); //$NON-NLS-1$
+ result.setText(CSearchMessages.getString("CSearchPage.searchFor.label")); //$NON-NLS-1$
GridLayout layout= new GridLayout();
layout.numColumns= 3;
result.setLayout(layout);
@@ -566,8 +564,8 @@
pattern= p;
isCaseSensitive= i;
cElement= element;
- this.scope= scope;
- this.workingSets= workingSets;
+ this.scope = scope;
+ this.workingSets = workingSets;
}
}
@@ -579,20 +577,20 @@
private Button[] fSearchFor;
private String[] fSearchForText= {
- CSearchMessages.getString("SearchPage.searchFor.type"), //$NON-NLS-1$
- CSearchMessages.getString("SearchPage.searchFor.method"), //$NON-NLS-1$
- //CSearchMessages.getString("SearchPage.searchFor.package"), //$NON-NLS-1$
- CSearchMessages.getString("SearchPage.searchFor.constructor"), //$NON-NLS-1$
- CSearchMessages.getString("SearchPage.searchFor.field")}; //$NON-NLS-1$
-
+ CSearchMessages.getString("CSearchPage.searchFor.type"), //$NON-NLS-1$
+ CSearchMessages.getString("CSearchPage.searchFor.method"), //$NON-NLS-1$
+ CSearchMessages.getString("CSearchPage.searchFor.namespace"), //$NON-NLS-1$
+ CSearchMessages.getString("CSearchPage.searchFor.constructor"), //$NON-NLS-1$
+ CSearchMessages.getString("CSearchPage.searchFor.field")}; //$NON-NLS-1$
+
private Button[] fLimitTo;
private String[] fLimitToText= {
- CSearchMessages.getString("SearchPage.limitTo.declarations"), //$NON-NLS-1$
- CSearchMessages.getString("SearchPage.limitTo.implementors"), //$NON-NLS-1$
- CSearchMessages.getString("SearchPage.limitTo.references"), //$NON-NLS-1$
- CSearchMessages.getString("SearchPage.limitTo.allOccurrences"), //$NON-NLS-1$
- CSearchMessages.getString("SearchPage.limitTo.readReferences"), //$NON-NLS-1$
- CSearchMessages.getString("SearchPage.limitTo.writeReferences")}; //$NON-NLS-1$
+ CSearchMessages.getString("CSearchPage.limitTo.declarations"), //$NON-NLS-1$
+ CSearchMessages.getString("CSearchPage.limitTo.implementors"), //$NON-NLS-1$
+ CSearchMessages.getString("CSearchPage.limitTo.references"), //$NON-NLS-1$
+ CSearchMessages.getString("CSearchPage.limitTo.allOccurrences"), //$NON-NLS-1$
+ CSearchMessages.getString("CSearchPage.limitTo.readReferences"), //$NON-NLS-1$
+ CSearchMessages.getString("CSearchPage.limitTo.writeReferences")}; //$NON-NLS-1$
private SearchPatternData fInitialData;
private IStructuredSelection fStructuredSelection;
Index: src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java,v
retrieving revision 1.1
diff -u -r1.1 CSearchResultCollector.java
--- src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java 16 Jun 2003 17:35:44 -0000 1.1
+++ src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java 27 Jun 2003 20:41:18 -0000
@@ -13,10 +13,19 @@
*/
package org.eclipse.cdt.internal.ui.search;
+import java.text.MessageFormat;
+import java.util.HashMap;
+
+import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.search.ICSearchResultCollector;
+import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.search.ui.IActionGroupFactory;
+import org.eclipse.search.ui.ISearchResultView;
+import org.eclipse.search.ui.SearchUI;
+import org.eclipse.ui.actions.ActionGroup;
/**
* @author aniefer
@@ -38,8 +47,24 @@
* @see org.eclipse.cdt.core.search.ICSearchResultCollector#aboutToStart()
*/
public void aboutToStart() {
- // TODO Auto-generated method stub
-
+ _view = SearchUI.getSearchResultView();
+ _matchCount = 0;
+ if( _view != null ){
+ _view.searchStarted(
+ new ActionGroupFactory(),
+ _operation.getSingularLabel(),
+ _operation.getPluralLabelPattern(),
+ _operation.getImageDescriptor(),
+ CSearchPage.EXTENSION_POINT_ID,
+ new CSearchResultLabelProvider(),
+ new GotoMarkerAction(),
+ new GroupByKeyComputer(),
+ _operation
+ );
+ }
+ if( !getProgressMonitor().isCanceled() ){
+ getProgressMonitor().subTask( SEARCHING );
+ }
}
/* (non-Javadoc)
@@ -49,19 +74,47 @@
IResource resource,
int start,
int end,
- Object enclosingElement,
+ ICElement enclosingElement,
int accuracy)
- throws CoreException {
- // TODO Auto-generated method stub
-
+ throws CoreException
+ {
+ IMarker marker = resource.createMarker( SearchUI.SEARCH_MARKER );
+
+ Object groupKey = enclosingElement;
+
+ HashMap markerAttributes = new HashMap( 2 );
+
+ //we can hang any other info we want off the marker
+ markerAttributes.put( IMarker.CHAR_START, new Integer( Math.max( start, 0 ) ) );
+ markerAttributes.put( IMarker.CHAR_END, new Integer( Math.max( end, 0 ) ) );
+
+ marker.setAttributes( markerAttributes );
+
+ _view.addMatch( enclosingElement.getElementName(), groupKey, resource, marker );
+ _matchCount++;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.search.ICSearchResultCollector#done()
*/
public void done() {
- // TODO Auto-generated method stub
-
+ if( !getProgressMonitor().isCanceled() ){
+ String matchesString;
+ if( _matchCount == 1 ){
+ matchesString = MATCH;
+ } else {
+ matchesString = MessageFormat.format( MATCHES, new Integer[]{ new Integer(_matchCount) } );
+ }
+
+ getProgressMonitor().setTaskName( MessageFormat.format( DONE, new String[]{ matchesString } ) );
+ }
+
+ if( _view != null ){
+ _view.searchFinished();
+ }
+
+ _view = null;
+ _monitor = null;
}
/* (non-Javadoc)
@@ -71,22 +124,28 @@
return _monitor;
}
- /**
- * @param monitor
- */
public void setProgressMonitor(IProgressMonitor monitor) {
this._monitor = monitor;
}
- private IProgressMonitor _monitor;
-
- /**
- * @param operation
- */
public void setOperation( CSearchOperation operation ) {
_operation = operation;
}
+ private class ActionGroupFactory implements IActionGroupFactory {
+ public ActionGroup createActionGroup( ISearchResultView part ){
+ return new CSearchViewActionGroup( part );
+ }
+ }
+
+ private static final String SEARCHING = CSearchMessages.getString("CSearchResultCollector.searching"); //$NON-NLS-1$
+ private static final String MATCH = CSearchMessages.getString("CSearchResultCollector.match"); //$NON-NLS-1$
+ private static final String MATCHES = CSearchMessages.getString("CSearchResultCollector.matches"); //$NON-NLS-1$
+ private static final String DONE = CSearchMessages.getString("CSearchResultCollector.done"); //$NON-NLS-1$
+
- private CSearchOperation _operation;
+ private IProgressMonitor _monitor;
+ private CSearchOperation _operation;
+ private ISearchResultView _view;
+ private int _matchCount;
}
Index: src/org/eclipse/cdt/internal/ui/search/CSearchResultLabelProvider.java
===================================================================
RCS file: src/org/eclipse/cdt/internal/ui/search/CSearchResultLabelProvider.java
diff -N src/org/eclipse/cdt/internal/ui/search/CSearchResultLabelProvider.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/internal/ui/search/CSearchResultLabelProvider.java 27 Jun 2003 20:41:18 -0000
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Corp. - Rational Software - initial implementation
+ ******************************************************************************/
+/*
+ * Created on Jun 18, 2003
+ */
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.search.ui.ISearchResultViewEntry;
+import org.eclipse.search.ui.SearchUI;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @author aniefer
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class CSearchResultLabelProvider extends LabelProvider {
+
+ public static final int SHOW_ELEMENT_CONTAINER = 1; //default
+ public static final int SHOW_CONTAINER_ELEMENT = 2;
+ public static final int SHOW_PATH = 3;
+
+ public final static int DEFAULT_TEXTFLAGS = CElementLabels.ROOT_VARIABLE |
+ CElementLabels.M_PARAMETER_TYPES |
+ CElementLabels.M_APP_RETURNTYPE |
+ CElementLabels.REFERENCED_ROOT_POST_QUALIFIED;
+
+ public static final String POTENTIAL_MATCH = CSearchMessages.getString("CSearchResultLabelProvider.potentialMatch"); //$NON-NLS-1$
+
+ public Image getImage( Object element ) {
+ return null;
+ }
+
+ public String getText( Object element ) {
+ _lastMarker = null;
+
+ ICElement cElement = getCElement( element );
+
+ boolean isPotentialMatch = _lastMarker != null && _lastMarker.getAttribute( SearchUI.POTENTIAL_MATCH, false );
+
+ if( cElement == null ){
+ if( _lastMarker != null ){
+ if( isPotentialMatch )
+ return super.getText( _lastMarker.getResource() ) + POTENTIAL_MATCH;
+ else
+ return super.getText( _lastMarker.getResource() );
+ } else {
+ return "";
+ }
+ }
+
+ String text = "";
+ if( isPotentialMatch ){
+ text = CElementLabels.getTextLabel( element, _textFlags ) + POTENTIAL_MATCH;
+ } else {
+ text = CElementLabels.getTextLabel( element, _textFlags );
+ }
+ //if( cElement instanceof )
+
+ return element == null ? "" : element.toString();//$NON-NLS-1$
+ }
+
+ public void setOrder(int orderFlag) {
+ int flags = DEFAULT_TEXTFLAGS | CElementLabels.P_COMPRESSED;
+
+ switch( orderFlag ){
+ case SHOW_ELEMENT_CONTAINER:
+ flags |= CElementLabels.ALL_POST_QUALIFIED | CElementLabels.M_PARAMETER_TYPES;
+ break;
+ case SHOW_PATH:
+ flags |= CElementLabels.PREPEND_ROOT_PATH;
+ /*fall through to SHOW_CONTAINER_ELEMENT*/
+ case SHOW_CONTAINER_ELEMENT:
+ flags |= CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.M_PARAMETER_TYPES;
+ break;
+ }
+
+ _textFlags = flags;
+ }
+
+ protected IMarker getMarker( Object o ){
+ if( !( o instanceof ISearchResultViewEntry ) ){
+ return null;
+ }
+
+ return ( (ISearchResultViewEntry)o ).getSelectedMarker();
+ }
+
+ private ICElement getCElement( Object o ){
+ if( o instanceof ICElement )
+ return (ICElement) o;
+
+ IMarker marker = getMarker( o );
+ if( marker == null )
+ return null;
+
+ return getCElement( marker, (ISearchResultViewEntry) o );
+ }
+
+ private ICElement getCElement( IMarker marker, ISearchResultViewEntry entry ) {
+ if( _lastMarker != marker ){
+ boolean canUseGroupByKey = false;
+
+ if( canUseGroupByKey && entry.getGroupByKey() instanceof ICElement ){
+ _lastCElement = (ICElement) entry.getGroupByKey();
+ } else {
+ _lastCElement = CSearchUtil.getCElement( marker );
+ }
+
+ _lastMarker = marker;
+ }
+ return _lastCElement;
+ }
+
+ private IMarker _lastMarker;
+ private ICElement _lastCElement;
+
+ private int _textFlags;
+ private int _imageFlags;
+
+}
Index: src/org/eclipse/cdt/internal/ui/search/CSearchViewActionGroup.java
===================================================================
RCS file: src/org/eclipse/cdt/internal/ui/search/CSearchViewActionGroup.java
diff -N src/org/eclipse/cdt/internal/ui/search/CSearchViewActionGroup.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/internal/ui/search/CSearchViewActionGroup.java 27 Jun 2003 20:41:18 -0000
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Corp. - Rational Software - initial implementation
+ ******************************************************************************/
+/*
+ * Created on Jun 18, 2003
+ */
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.search.ui.ISearchResultView;
+import org.eclipse.ui.actions.ActionGroup;
+
+/**
+ * @author aniefer
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class CSearchViewActionGroup extends ActionGroup {
+
+ /**
+ * @param part
+ */
+ public CSearchViewActionGroup(ISearchResultView part) {
+
+ // TODO Auto-generated constructor stub
+ }
+
+}
Index: src/org/eclipse/cdt/internal/ui/search/ElementNameSorter.java
===================================================================
RCS file: src/org/eclipse/cdt/internal/ui/search/ElementNameSorter.java
diff -N src/org/eclipse/cdt/internal/ui/search/ElementNameSorter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/internal/ui/search/ElementNameSorter.java 27 Jun 2003 20:41:18 -0000
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Corp. - Rational Software - initial implementation
+ ******************************************************************************/
+/*
+ * Created on Jun 24, 2003
+ */
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.search.ui.ISearchResultView;
+import org.eclipse.search.ui.ISearchResultViewEntry;
+import org.eclipse.search.ui.SearchUI;
+
+/**
+ * @author aniefer
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class ElementNameSorter extends ViewerSorter {
+
+ public int compare( Viewer viewer, Object e1, Object e2 ){
+ String name1 = null, name2 = null;
+
+ if (e1 instanceof ISearchResultViewEntry)
+ name1= _labelProvider.getText( e1 );
+
+ if (e2 instanceof ISearchResultViewEntry)
+ name2= _labelProvider.getText( e2 );
+
+ if (name1 == null)
+ name1= ""; //$NON-NLS-1$
+
+ if (name2 == null)
+ name2= ""; //$NON-NLS-1$
+
+ return getCollator().compare(name1, name2);
+ }
+
+ public boolean isSorterProperty( Object element, String property ){
+ return true;
+ }
+
+ public void sort( Viewer viewer, Object[] elements ) {
+ // Set label provider to show "element - path"
+ ISearchResultView view = SearchUI.getSearchResultView();
+ if (view == null)
+ return;
+
+ _labelProvider = view.getLabelProvider();
+
+ if( _labelProvider instanceof CSearchResultLabelProvider ) {
+ ((CSearchResultLabelProvider)_labelProvider).setOrder( CSearchResultLabelProvider.SHOW_ELEMENT_CONTAINER );
+ super.sort( viewer, elements );
+ }
+ }
+
+ private ILabelProvider _labelProvider;
+}
Index: src/org/eclipse/cdt/internal/ui/search/GotoMarkerAction.java
===================================================================
RCS file: src/org/eclipse/cdt/internal/ui/search/GotoMarkerAction.java
diff -N src/org/eclipse/cdt/internal/ui/search/GotoMarkerAction.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/internal/ui/search/GotoMarkerAction.java 27 Jun 2003 20:41:18 -0000
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Corp. - Rational Software - initial implementation
+ ******************************************************************************/
+/*
+ * Created on Jun 18, 2003
+ */
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+import org.eclipse.cdt.internal.ui.util.SelectionUtil;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.Action;
+import org.eclipse.search.ui.ISearchResultView;
+import org.eclipse.search.ui.ISearchResultViewEntry;
+import org.eclipse.search.ui.SearchUI;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * @author aniefer
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class GotoMarkerAction extends Action {
+
+ public GotoMarkerAction(){
+
+ }
+
+ public void run() {
+ ISearchResultView view = SearchUI.getSearchResultView();
+ Object element = SelectionUtil.getSingleElement( view.getSelection() );
+ if( element instanceof ISearchResultViewEntry ) {
+ ISearchResultViewEntry entry = (ISearchResultViewEntry) element;
+ show( entry.getSelectedMarker() );
+ }
+ }
+
+ private void show( IMarker marker ){
+ IResource resource = marker.getResource();
+ if( resource == null || !resource.exists() ){
+ return;
+ }
+
+ IWorkbenchPage page = CUIPlugin.getActivePage();
+ ICElement element = CSearchUtil.getCElement( marker );
+
+ if( SearchUI.reuseEditor() ){
+ showWithReuse( marker, resource, element, page );
+ } else {
+ showWithoutReuse( marker, element, page );
+ }
+ }
+
+ private void showWithoutReuse( IMarker marker, ICElement element, IWorkbenchPage page ){
+ IEditorPart editor = null;
+ try{
+ Object objectToOpen = ( element != null ) ? (Object) element : (Object) marker.getResource();
+ editor = EditorUtility.openInEditor( objectToOpen, false );
+ } catch ( CoreException e ) {
+ //boo
+ }
+ if( editor != null ){
+ editor.gotoMarker( marker );
+ }
+ }
+
+ private void showWithReuse( IMarker marker, IResource resource, ICElement element, IWorkbenchPage page ) {
+ if( !(resource instanceof IFile) ){
+ return;
+ }
+
+ IEditorPart editor = EditorUtility.isOpenInEditor( element );
+ if( editor != null ){
+ page.bringToTop( editor );
+ } else {
+
+ }
+ }
+}
Index: src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java
===================================================================
RCS file: src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java
diff -N src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java 27 Jun 2003 20:41:19 -0000
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Corp. - Rational Software - initial implementation
+ ******************************************************************************/
+/*
+ * Created on Jun 18, 2003
+ */
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.search.ui.IGroupByKeyComputer;
+
+/**
+ * @author aniefer
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class GroupByKeyComputer implements IGroupByKeyComputer {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.search.ui.IGroupByKeyComputer#computeGroupByKey(org.eclipse.core.resources.IMarker)
+ */
+
+ public Object computeGroupByKey(IMarker marker) {
+ if( marker == null ){
+ return null;
+ }
+
+ // ICElement element = getCElement( marker );
+ // if( element != null && element.exists() ){
+ // return _lastHandle;
+ // }
+
+ return null;
+ }
+ /*
+ private String getJavaElementHandleId(IMarker marker) {
+ try {
+ return (String)marker.getAttribute(ICSearchUIConstants.ATT_JE_HANDLE_ID);
+ } catch (CoreException ex) {
+ ExceptionHandler.handle(ex, CSearchMessages.getString("Search.Error.markerAttributeAccess.title"), CSearchMessages.getString("Search.Error.markerAttributeAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$
+ return null;
+ }
+ }
+
+ private ICElement getCElement( IMarker marker ){
+ String handle = getCElementHandleId( marker );
+ if( handle == null ){
+ _lastHandle = null;
+ _lastElement = null;
+ return null;
+ }
+ if( !handle.equals( _lastHandle ) ){
+ _lastElement = SearchUtil
+ }
+ return _lastElement;
+ }*/
+
+ private String _lastHandle = null;
+ private ICElement _lastElement = null;
+
+}
Index: src/org/eclipse/cdt/internal/ui/search/ParentNameSorter.java
===================================================================
RCS file: src/org/eclipse/cdt/internal/ui/search/ParentNameSorter.java
diff -N src/org/eclipse/cdt/internal/ui/search/ParentNameSorter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/internal/ui/search/ParentNameSorter.java 27 Jun 2003 20:41:19 -0000
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Corp. - Rational Software - initial implementation
+ ******************************************************************************/
+/*
+ * Created on Jun 24, 2003
+ */
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.search.ui.ISearchResultView;
+import org.eclipse.search.ui.ISearchResultViewEntry;
+import org.eclipse.search.ui.SearchUI;
+
+/**
+ * @author aniefer
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class ParentNameSorter extends ViewerSorter {
+
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ String name1= null;
+ String name2= null;
+
+ if (e1 instanceof ISearchResultViewEntry)
+ name1= _labelProvider.getText(e1);
+
+ if (e2 instanceof ISearchResultViewEntry)
+ name2= _labelProvider.getText(e2);
+
+ if (name1 == null)
+ name1= ""; //$NON-NLS-1$
+
+ if (name2 == null)
+ name2= ""; //$NON-NLS-1$
+
+ return getCollator().compare(name1, name2);
+ }
+
+ /*
+ * Overrides method from ViewerSorter
+ */
+ public boolean isSorterProperty(Object element, String property) {
+ return true;
+ }
+
+ /*
+ * Overrides method from ViewerSorter
+ */
+ public void sort(Viewer viewer, Object[] elements) {
+ // Set label provider to show "path - resource"
+ ISearchResultView view = SearchUI.getSearchResultView();
+ if (view == null)
+ return;
+
+ _labelProvider = view.getLabelProvider();
+
+ if( _labelProvider instanceof CSearchResultLabelProvider )
+ ((CSearchResultLabelProvider)_labelProvider).setOrder( CSearchResultLabelProvider.SHOW_CONTAINER_ELEMENT );
+
+ super.sort( viewer, elements );
+ }
+
+ private ILabelProvider _labelProvider;
+}
Index: src/org/eclipse/cdt/internal/ui/search/PathNameSorter.java
===================================================================
RCS file: src/org/eclipse/cdt/internal/ui/search/PathNameSorter.java
diff -N src/org/eclipse/cdt/internal/ui/search/PathNameSorter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/internal/ui/search/PathNameSorter.java 27 Jun 2003 20:41:19 -0000
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Corp. - Rational Software - initial implementation
+ ******************************************************************************/
+/*
+ * Created on Jun 24, 2003
+ */
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.search.ui.ISearchResultView;
+import org.eclipse.search.ui.ISearchResultViewEntry;
+import org.eclipse.search.ui.SearchUI;
+
+/**
+ * @author aniefer
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class PathNameSorter extends ViewerSorter {
+
+ /*
+ * Overrides method from ViewerSorter
+ */
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ String name1 = null;
+ String name2 = null;
+ ISearchResultViewEntry entry1 = null;
+ ISearchResultViewEntry entry2 = null;
+
+ if( e1 instanceof ISearchResultViewEntry ) {
+ entry1 = (ISearchResultViewEntry)e1;
+ name1 = _labelProvider.getText( e1 );
+ }
+ if( e2 instanceof ISearchResultViewEntry ) {
+ entry2 = (ISearchResultViewEntry)e2;
+ name2 = _labelProvider.getText( e2 );
+ }
+
+ if( name1 == null )
+ name1 = ""; //$NON-NLS-1$
+
+ if( name2 == null )
+ name2 = ""; //$NON-NLS-1$
+
+ IResource resource = null;
+ if( entry1 != null)
+ resource = entry1.getResource();
+
+ if( resource != null && entry2 != null && resource == entry2.getResource() ) {
+
+ if( resource instanceof IProject || resource.getFileExtension().equalsIgnoreCase("jar") || resource.getFileExtension().equalsIgnoreCase("zip") ) //$NON-NLS-2$ //$NON-NLS-1$
+ // binary archives
+ return getCollator().compare(name1, name2);
+
+ // Sort by marker start position if resource is equal.
+ int startPos1 = -1;
+ int startPos2 = -1;
+ IMarker marker1 = entry1.getSelectedMarker();
+ IMarker marker2 = entry2.getSelectedMarker();
+
+ if (marker1 != null)
+ startPos1 = marker1.getAttribute( IMarker.CHAR_START, -1 );
+ if (marker2 != null)
+ startPos2 = marker2.getAttribute( IMarker.CHAR_START, -1 );
+
+ return startPos1 - startPos2;
+ }
+
+ return getCollator().compare(name1, name2);
+ }
+
+ /*
+ * Overrides method from ViewerSorter
+ */
+ public boolean isSorterProperty(Object element, String property) {
+ return true;
+ }
+
+ /*
+ * Overrides method from ViewerSorter
+ */
+ public void sort( Viewer viewer, Object[] elements ) {
+ // Set label provider to show "path - resource"
+ ISearchResultView view = SearchUI.getSearchResultView();
+ if( view == null )
+ return;
+
+ _labelProvider = view.getLabelProvider();
+ if( _labelProvider instanceof CSearchResultLabelProvider )
+ ((CSearchResultLabelProvider)_labelProvider).setOrder( CSearchResultLabelProvider.SHOW_PATH );
+ super.sort( viewer, elements );
+ }
+
+ private ILabelProvider _labelProvider;
+}
Index: search/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/ChangeLog,v
retrieving revision 1.1
diff -u -r1.1 ChangeLog
--- search/ChangeLog 27 Jun 2003 14:31:27 -0000 1.1
+++ search/ChangeLog 27 Jun 2003 20:40:47 -0000
@@ -1,3 +1,17 @@
+2003-06-27 Andrew Niefer
+Modified:
+ search/org.eclipse.cdt.core.search.matching/MatchLocator.java
+ - enter/exitInclusion
+ - enterClassSpecifier
+ search/org.eclipse.cdt.core.search.matching/CSearchPattern.java
+ - createClassPattern
+ - matchesName
+ search/org.eclipse.cdt.core.search.matching/ClassDeclarationPattern.java
+ - matchLevel
+ search/org.eclipse.cdt.core.search/ICSearchPattern.java
+ search/org.eclipse.cdt.core.search/ICSearchResultCollector.java
+ search/org.eclipse.cdt.core.search/SearchEngine.java
+
2003-06-25 Bogdan Gheorghe
Modified:
Index: search/org/eclipse/cdt/core/search/ICSearchPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchPattern.java,v
retrieving revision 1.1
diff -u -r1.1 ICSearchPattern.java
--- search/org/eclipse/cdt/core/search/ICSearchPattern.java 16 Jun 2003 17:35:46 -0000 1.1
+++ search/org/eclipse/cdt/core/search/ICSearchPattern.java 27 Jun 2003 20:40:47 -0000
@@ -13,6 +13,8 @@
*/
package org.eclipse.cdt.core.search;
+import org.eclipse.cdt.core.parser.ast.IASTOffsetableElement;
+
/**
* @author aniefer
*
@@ -21,4 +23,15 @@
*/
public interface ICSearchPattern {
+ public static final int IMPOSSIBLE_MATCH = 0;
+ public static final int POSSIBLE_MATCH = 1;
+ public static final int ACCURATE_MATCH = 2;
+ public static final int INACCURATE_MATCH = 3;
+
+ /**
+ * @param node
+ * @return
+ */
+ int matchLevel( IASTOffsetableElement node );
+
}
Index: search/org/eclipse/cdt/core/search/ICSearchResultCollector.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchResultCollector.java,v
retrieving revision 1.1
diff -u -r1.1 ICSearchResultCollector.java
--- search/org/eclipse/cdt/core/search/ICSearchResultCollector.java 16 Jun 2003 17:35:46 -0000 1.1
+++ search/org/eclipse/cdt/core/search/ICSearchResultCollector.java 27 Jun 2003 20:40:47 -0000
@@ -13,6 +13,7 @@
*/
package org.eclipse.cdt.core.search;
+import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -59,9 +60,10 @@
IResource resource,
int start,
int end,
- /*IJavaElement*/ Object enclosingElement,
+ ICElement enclosingElement,
int accuracy)
throws CoreException;
+
/**
* Called when the search has ended.
*/
@@ -72,4 +74,5 @@
* @return a progress monitor or null if no progress monitor is provided
*/
public IProgressMonitor getProgressMonitor();
+
}
Index: search/org/eclipse/cdt/core/search/SearchEngine.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/SearchEngine.java,v
retrieving revision 1.1
diff -u -r1.1 SearchEngine.java
--- search/org/eclipse/cdt/core/search/SearchEngine.java 16 Jun 2003 17:35:46 -0000 1.1
+++ search/org/eclipse/cdt/core/search/SearchEngine.java 27 Jun 2003 20:40:47 -0000
@@ -14,12 +14,16 @@
package org.eclipse.cdt.core.search;
import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.core.index.IndexManager;
+import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.cdt.internal.core.model.CModelManager;
+import org.eclipse.cdt.internal.core.search.PatternSearchJob;
import org.eclipse.cdt.internal.core.search.Util;
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
+import org.eclipse.cdt.internal.core.search.matching.MatchLocator;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubProgressMonitor;
/**
* @author aniefer
@@ -94,9 +98,23 @@
}
CModelManager modelManager = CModelManager.getDefault();
- IndexManager indexManager = null; //modelManager.getIndexManager();
+ IndexManager indexManager = modelManager.getIndexManager();
+ SubProgressMonitor subMonitor = (progressMonitor == null ) ? null : new SubProgressMonitor( progressMonitor, 5 );
+ indexManager.performConcurrentJob(
+ new PatternSearchJob(),
+ ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
+ subMonitor );
+
+ subMonitor = (progressMonitor == null ) ? null : new SubProgressMonitor( progressMonitor, 95 );
+
+ MatchLocator matchLocator = new MatchLocator( pattern, collector, scope, subMonitor );
+
+ if( progressMonitor != null && progressMonitor.isCanceled() )
+ throw new OperationCanceledException();
+
+ //matchLocator.locateMatches( pathCollector.getPaths(), workspace, workingCopies );
} finally {
collector.done();
}
Index: search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java,v
retrieving revision 1.2
diff -u -r1.2 CSearchPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java 27 Jun 2003 14:31:27 -0000 1.2
+++ search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java 27 Jun 2003 20:40:47 -0000
@@ -13,8 +13,18 @@
*/
package org.eclipse.cdt.internal.core.search.matching;
+import java.io.StringReader;
+import java.util.LinkedList;
+
+import org.eclipse.cdt.core.parser.EndOfFile;
+import org.eclipse.cdt.core.parser.IScanner;
+import org.eclipse.cdt.core.parser.IToken;
+import org.eclipse.cdt.core.parser.ParserFactory;
+import org.eclipse.cdt.core.parser.ParserMode;
+import org.eclipse.cdt.core.parser.ScannerException;
import org.eclipse.cdt.core.search.ICSearchConstants;
import org.eclipse.cdt.core.search.ICSearchPattern;
+import org.eclipse.cdt.internal.core.search.CharOperation;
/**
* @author aniefer
@@ -22,8 +32,12 @@
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
-public abstract class CSearchPattern
- implements ICSearchConstants, ICSearchPattern {
+public abstract class CSearchPattern implements ICSearchConstants, ICSearchPattern {
+
+ public static final int IMPOSSIBLE_MATCH = 0;
+ public static final int POSSIBLE_MATCH = 1;
+ public static final int ACCURATE_MATCH = 2;
+ public static final int INACCURATE_MATCH = 3;
/**
* @param matchMode
@@ -50,7 +64,7 @@
CSearchPattern pattern = null;
switch( searchFor ){
case ICSearchConstants.TYPE:
- pattern = createTypePattern( patternString, limitTo, matchMode, caseSensitive );
+ pattern = createClassPattern( patternString, limitTo, matchMode, caseSensitive );
break;
//case ICSearchConstants.METHOD:
// pattern = createMethodPattern( patternString, limitTo, matchMode, caseSensitive );
@@ -109,9 +123,33 @@
* @param caseSensitive
* @return
*/
- private static CSearchPattern createTypePattern(String patternString, int limitTo, int matchMode, boolean caseSensitive) {
- // TODO Auto-generated method stub
- return null;
+ private static CSearchPattern createClassPattern(String patternString, int limitTo, int matchMode, boolean caseSensitive) {
+ IScanner scanner = ParserFactory.createScanner( new StringReader( patternString ), "TEXT", null, null, ParserMode.QUICK_PARSE );
+
+ LinkedList list = new LinkedList();
+ IToken token = null;
+ String name = new String("");
+
+ try {
+ while( true ){
+ token = scanner.nextToken();
+
+ switch( token.getType() ){
+ case IToken.tCOLONCOLON :
+ list.addLast( name.toCharArray() );
+ name = new String("");
+ break;
+ default:
+ name += token.getImage();
+ break;
+ }
+ }
+ } catch (EndOfFile e) {
+ } catch (ScannerException e) {
+ }
+
+ char [][] qualifications = new char[1][];
+ return new ClassDeclarationPattern( name.toCharArray(), (char[][])list.toArray( qualifications ), null, matchMode, caseSensitive );
}
protected boolean matchesName( char[] pattern, char[] name ){
@@ -122,14 +160,15 @@
if( name != null ){
switch( _matchMode ){
case EXACT_MATCH:
- //return CharOperation.equals( pattern, name, _caseSensitive );
+ return CharOperation.equals( pattern, name, _caseSensitive );
case PREFIX_MATCH:
- //return CharOperation.prefixEquals( pattern, name, _caseSensitive );
+ return CharOperation.prefixEquals( pattern, name, _caseSensitive );
case PATTERN_MATCH:
if( !_caseSensitive ){
- //pattern = CharOperation.toLowerCase( pattern );
+ pattern = CharOperation.toLowerCase( pattern );
}
- //return CharOperation.match( pattern, name, _caseSensitive );
+
+ return CharOperation.match( pattern, name, _caseSensitive );
}
}
return false;
Index: search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java,v
retrieving revision 1.1
diff -u -r1.1 ClassDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java 16 Jun 2003 17:35:46 -0000 1.1
+++ search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java 27 Jun 2003 20:40:47 -0000
@@ -13,6 +13,11 @@
*/
package org.eclipse.cdt.internal.core.search.matching;
+import org.eclipse.cdt.core.parser.ast.ClassKind;
+import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
+import org.eclipse.cdt.core.parser.ast.IASTOffsetableElement;
+import org.eclipse.cdt.internal.core.search.CharOperation;
+
/**
* @author aniefer
*
@@ -25,5 +30,54 @@
super( matchMode, caseSensitive );
}
+ public ClassDeclarationPattern( char[] name, char[][] containers, ClassKind kind, int mode, boolean caseSensitive ){
+ super( mode, caseSensitive );
+ simpleName = caseSensitive ? name : CharOperation.toLowerCase( name );
+ if( caseSensitive || containers == null ){
+ containingTypes = containers;
+ } else {
+ int len = containers.length;
+ this.containingTypes = new char[ len ][];
+ for( int i = 0; i < len; i++ ){
+ this.containingTypes[i] = CharOperation.toLowerCase( containers[i] );
+ }
+ }
+ classKind = kind;
+ }
+
+ public int matchLevel( IASTOffsetableElement node ){
+ if( !( node instanceof IASTClassSpecifier ) )
+ return IMPOSSIBLE_MATCH;
+
+ IASTClassSpecifier clsSpec = (IASTClassSpecifier) node;
+
+ //check name, if simpleName == null, its treated the same as "*"
+ if( simpleName != null && !matchesName( simpleName, clsSpec.getName().toCharArray() ) ){
+ return IMPOSSIBLE_MATCH;
+ }
+
+ //check containing scopes
+ String [] qualifications = clsSpec.getFullyQualifiedName();
+ int size = containingTypes.length;
+ if( qualifications.length < size )
+ return IMPOSSIBLE_MATCH;
+
+ for( int i = 0; i < containingTypes.length; i++ ){
+ if( !matchesName( containingTypes[i], qualifications[i].toCharArray() ) ){
+ return IMPOSSIBLE_MATCH;
+ }
+ }
+
+ //check type
+ if( classKind != clsSpec.getClassKind() ){
+ return IMPOSSIBLE_MATCH;
+ }
+
+ return ACCURATE_MATCH;
+ }
+
+ private char[] simpleName;
+ private char[][] containingTypes;
+ private ClassKind classKind;
}
Index: search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java,v
retrieving revision 1.2
diff -u -r1.2 MatchLocator.java
--- search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java 24 Jun 2003 20:18:11 -0000 1.2
+++ search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java 27 Jun 2003 20:40:47 -0000
@@ -13,9 +13,23 @@
*/
package org.eclipse.cdt.internal.core.search.matching;
+import java.util.LinkedList;
+
import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
import org.eclipse.cdt.core.parser.ast.*;
+import org.eclipse.cdt.core.search.ICSearchPattern;
+import org.eclipse.cdt.core.search.ICSearchResultCollector;
+import org.eclipse.cdt.core.search.ICSearchScope;
+import org.eclipse.cdt.internal.core.model.IWorkingCopy;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+
/**
* @author aniefer
@@ -25,309 +39,97 @@
*/
public class MatchLocator implements ISourceElementRequestor {
+
/**
*
*/
- public MatchLocator() {
+ public MatchLocator( ICSearchPattern pattern, ICSearchResultCollector collector, ICSearchScope scope, IProgressMonitor monitor) {
super();
- // TODO Auto-generated constructor stub
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptProblem(org.eclipse.cdt.core.parser.IProblem)
- */
- public void acceptProblem(IProblem problem) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMacro(org.eclipse.cdt.core.parser.ast.IASTMacro)
- */
- public void acceptMacro(IASTMacro macro) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptVariable(org.eclipse.cdt.core.parser.ast.IASTVariable)
- */
- public void acceptVariable(IASTVariable variable) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFunctionDeclaration(org.eclipse.cdt.core.parser.ast.IASTFunction)
- */
- public void acceptFunctionDeclaration(IASTFunction function) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptUsingDirective(org.eclipse.cdt.core.parser.ast.IASTUsingDirective)
- */
- public void acceptUsingDirective(IASTUsingDirective usageDirective) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptUsingDeclaration(org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration)
- */
- public void acceptUsingDeclaration(IASTUsingDeclaration usageDeclaration) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptASMDefinition(org.eclipse.cdt.core.parser.ast.IASTASMDefinition)
- */
- public void acceptASMDefinition(IASTASMDefinition asmDefinition) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTypedef(org.eclipse.cdt.core.parser.ast.IASTTypedef)
- */
- public void acceptTypedef(IASTTypedef typedef) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterEnumSpecifier(org.eclipse.cdt.core.parser.ast.IASTEnumSpecifier)
- */
- //public void enterEnumSpecifier(IASTEnumSpecifier enumSpec) {
- // TODO Auto-generated method stub
-
- //}
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumerator(org.eclipse.cdt.core.parser.ast.IASTEnumerator)
- */
- public void acceptEnumerator(IASTEnumerator enumerator) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitEnumSpecifier(org.eclipse.cdt.core.parser.ast.IASTEnumSpecifier)
- */
- //public void exitEnumSpecifier(IASTEnumSpecifier enumSpec) {
- // TODO Auto-generated method stub
-
- //}
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterFunctionBody(org.eclipse.cdt.core.parser.ast.IASTFunction)
- */
- public void enterFunctionBody(IASTFunction function) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitFunctionBody(org.eclipse.cdt.core.parser.ast.IASTFunction)
- */
- public void exitFunctionBody(IASTFunction function) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterCompilationUnit(org.eclipse.cdt.core.parser.ast.IASTCompilationUnit)
- */
- public void enterCompilationUnit(IASTCompilationUnit compilationUnit) {
- // TODO Auto-generated method stub
-
- }
+ searchPattern = pattern;
+ resultCollector = collector;
+ searchScope = scope;
+ progressMonitor = monitor;
+ }
+
+ public void acceptProblem(IProblem problem) { }
+ public void acceptMacro(IASTMacro macro) { }
+ public void acceptVariable(IASTVariable variable) { }
+ public void acceptFunctionDeclaration(IASTFunction function) { }
+ public void acceptUsingDirective(IASTUsingDirective usageDirective) { }
+ public void acceptUsingDeclaration(IASTUsingDeclaration usageDeclaration) { }
+ public void acceptASMDefinition(IASTASMDefinition asmDefinition) { }
+ public void acceptTypedef(IASTTypedef typedef) { }
+ public void acceptEnumerator(IASTEnumerator enumerator) { }
+ public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration){ }
+ public void acceptClassReference(IASTClassSpecifier classSpecifier, int referenceOffset) { }
+ public void acceptElaboratedTypeSpecifier(IASTElaboratedTypeSpecifier elaboratedTypeSpec){ }
+ public void acceptMethodDeclaration(IASTMethod method) { }
+ public void acceptField(IASTField field) { }
+ public void acceptConstructor(IASTConstructor constructor) { }
+ public void enterFunctionBody(IASTFunction function) { }
+ public void enterCompilationUnit(IASTCompilationUnit compilationUnit) { }
+ public void enterNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) { }
+ public void enterLinkageSpecification(IASTLinkageSpecification linkageSpec) { }
+ public void enterTemplateDeclaration(IASTTemplateDeclaration declaration) { }
+ public void enterTemplateSpecialization(IASTTemplateSpecialization specialization) { }
+ public void enterTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) { }
+ public void enterMethodBody(IASTMethod method) { }
+ public void exitFunctionBody(IASTFunction function) { }
+ public void exitMethodBody(IASTMethod method) { }
+ public void exitTemplateDeclaration(IASTTemplateDeclaration declaration) { }
+ public void exitTemplateSpecialization(IASTTemplateSpecialization specialization) { }
+ public void exitTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) { }
+ public void exitLinkageSpecification(IASTLinkageSpecification linkageSpec) { }
+ public void exitClassSpecifier(IASTClassSpecifier classSpecification) { }
+ public void exitNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) { }
+ public void exitCompilationUnit(IASTCompilationUnit compilationUnit) { }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterInclusion(org.eclipse.cdt.core.parser.ast.IASTInclusion)
- */
public void enterInclusion(IASTInclusion inclusion) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterNamespaceDefinition(org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition)
- */
- public void enterNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier)
- */
- public void enterClassSpecifier(IASTClassSpecifier classSpecification) {
- // TODO Auto-generated method stub
+ String includePath = inclusion.getFullFileName();
+ IPath path = new Path( includePath );
+ IResource resource = workspaceRoot.findMember( path, true );
+ if( resource != null ){
+ resourceStack.addFirst( currentResource );
+ currentResource = resource;
+ }
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterLinkageSpecification(org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification)
- */
- public void enterLinkageSpecification(IASTLinkageSpecification linkageSpec) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateDeclaration(org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
- */
- public void enterTemplateDeclaration(IASTTemplateDeclaration declaration) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateSpecialization(org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization)
- */
- public void enterTemplateSpecialization(IASTTemplateSpecialization specialization) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateExplicitInstantiation(org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation)
- */
- public void enterTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMethodDeclaration(org.eclipse.cdt.core.parser.ast.IASTMethod)
- */
- public void acceptMethodDeclaration(IASTMethod method) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterMethodBody(org.eclipse.cdt.core.parser.ast.IASTMethod)
- */
- public void enterMethodBody(IASTMethod method) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitMethodBody(org.eclipse.cdt.core.parser.ast.IASTMethod)
- */
- public void exitMethodBody(IASTMethod method) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptField(org.eclipse.cdt.core.parser.ast.IASTField)
- */
- public void acceptField(IASTField field) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptConstructor(org.eclipse.cdt.core.parser.ast.IASTConstructor)
- */
- public void acceptConstructor(IASTConstructor constructor) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateDeclaration(org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
- */
- public void exitTemplateDeclaration(IASTTemplateDeclaration declaration) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateSpecialization(org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization)
- */
- public void exitTemplateSpecialization(IASTTemplateSpecialization specialization) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateExplicitInstantiation(org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation)
- */
- public void exitTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitLinkageSpecification(org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification)
- */
- public void exitLinkageSpecification(IASTLinkageSpecification linkageSpec) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier)
- */
- public void exitClassSpecifier(IASTClassSpecifier classSpecification) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitNamespaceDefinition(org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition)
- */
- public void exitNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitInclusion(org.eclipse.cdt.core.parser.ast.IASTInclusion)
- */
public void exitInclusion(IASTInclusion inclusion) {
- // TODO Auto-generated method stub
-
+ currentResource = (IResource) resourceStack.removeFirst();
}
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitCompilationUnit(org.eclipse.cdt.core.parser.ast.IASTCompilationUnit)
- */
- public void exitCompilationUnit(IASTCompilationUnit compilationUnit) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumerationSpecifier(org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier)
- */
- public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration) {
- // TODO Auto-generated method stub
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptClassReference(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier, int)
- */
- public void acceptClassReference(IASTClassSpecifier classSpecifier, int referenceOffset) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptElaboratedTypeSpecifier(org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier)
- */
- public void acceptElaboratedTypeSpecifier(IASTElaboratedTypeSpecifier elaboratedTypeSpec)
- {
- // TODO Auto-generated method stub
-
- }
-
+ public void enterClassSpecifier(IASTClassSpecifier classSpecification) {
+ if( searchPattern instanceof ClassDeclarationPattern ){
+ int level = searchPattern.matchLevel( classSpecification );
+ if( level != ICSearchPattern.IMPOSSIBLE_MATCH ){
+ report( classSpecification, level );
+ }
+ }
+ }
+
+ public void locateMatches( String [] paths, IWorkspace workspace, IWorkingCopy[] workingCopies ){
+ workspaceRoot = workspace.getRoot();
+ }
+
+ protected void report( IASTOffsetableElement node, int accuracyLevel ){
+ try {
+ resultCollector.accept( currentResource,
+ node.getElementStartingOffset(),
+ node.getElementEndingOffset(),
+ null,
+ accuracyLevel );
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ private ICSearchPattern searchPattern;
+ private ICSearchResultCollector resultCollector;
+ private IProgressMonitor progressMonitor;
+ private IResource currentResource;
+ private ICSearchScope searchScope;
+ private LinkedList resourceStack;
+ private IWorkspaceRoot workspaceRoot;
}