[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [cdt-patch] Patch proposal for Bug 43174
|
And here is just such a patch:
- Added a "Search entire project
for completion proposals" check box to Preferences->C/C++ Editor->Content
Assist
- The default is file search scope.
- AutomatedIntegration Suite run on
both Windows and Linux.
- Bogdan
Douglas Schaefer/Ottawa/IBM@IBMCA
Sent by: cdt-patch-admin@xxxxxxxxxxx
10/08/2003 01:31 PM
Please respond to
cdt-patch@xxxxxxxxxxx |
|
To
| cdt-patch@xxxxxxxxxxx
|
cc
|
|
Subject
| RE: [cdt-patch] Patch proposal
for Bug 43174 |
|
Actually, John C corrected me. Not only is it
the widget size but that
the Search Engine, for each match that it finds, opens the file with the
declaration for that match and parses it. I imagine we can find a
more
optimal solution for 2.0.
For now, I think the best answer is the preference to select File scope
versus Project scope. We'll have File scope as the default which
can be
overridden by products as necessary.
Doug Schaefer, Senior Software Developer
IBM Rational Software, Ottawa, Ontario, Canada
Thomas Fletcher <ThomasF@xxxxxxx>
Sent by: cdt-patch-admin@xxxxxxxxxxx
10/08/2003 01:12 PM
Please respond to
cdt-patch@xxxxxxxxxxx
To
"'cdt-patch@xxxxxxxxxxx'" <cdt-patch@xxxxxxxxxxx>
cc
Subject
RE: [cdt-patch] Patch proposal for Bug 43174
> -----Original Message-----
> From: Douglas Schaefer [mailto:dschaefe@xxxxxxxxxx]
> Sent: October 8, 2003 12:05 PM
> To: cdt-patch@xxxxxxxxxxx
> Subject: RE: [cdt-patch] Patch proposal for Bug 43174
>
>
> The root cause of the problem we saw was when the code
> completion returned
> a large result set. The performance problem wasn't in the
> search but in
> the creation of the drop down. The fix produced by Bogdan is
> unfortunately only a workaround for that to try and reduce
> the size of the
> set.
>
> BTW, we were getting code complete times of 3 minutes + with no
> opportunity to cancel which would look like a hang to the user.
Aha! Now I'm getting a better understanding. In that case, I
would suggest a preference instead which limits the number of
entries returned to the user. Since entries get ranked as they
are put into code completion, and typing "more" causes the list
to get narrowed down, then limitting the number of entries
presented (ie a random semi large number like 250?) seems more
than reasonable.
Limiting the scope of the returned values because the widgets
don't handle large data sets seems to be punishing some users
while not doing justice to the wicked work you guys have done
on the searching/indexing.
Thomas
> cdt-patch-admin@xxxxxxxxxxx wrote on 10/08/2003 11:45:42 AM:
>
> >
> >
> > > -----Original Message-----
> > > From: Alain Magloire [mailto:alain@xxxxxxx]
> > > Sent: October 8, 2003 10:55 AM
> > > To: cdt-patch@xxxxxxxxxxx
> > > Subject: Re: [cdt-patch] Patch proposal for Bug 43174
> > >
> > > +1, with some comments.
> > >
> > > (1)
> > > If the file search scope includes the inclusion ("#include
...")
> > > part of the search, got no problem.
> > > True for C it is not a requirement for visibility, in the
IDE
> > > case making an explicit declaration should be a requirement
for
> > > Code Assist to work properly.
> >
> > Fully agree with this. One of the major feature parity
issues
> > which customers (of the CDT and derived products) have is the
> > fact that we _do_ have code completion for projects.
> >
> > I can certainly explain to existing customers about the necessity
> > (ie performance improvement) of only providing information from
> > included header files (promote proper developer discipline, clean
> > code yadadada). I can _not_ realistically tell them that
the entire
> > feature is _just_gone_ and that they will have to live with it.
> >
> > > (2)
> > > I do understand that the first time, you do content assit
> > > you will have a hit, but do not we have cache indexed file
> > > to speed things up ?
> > >
> > > (3)
> > > The old indexer(CTags) parse the entire project once
> > > in a database, and all globals would be indexed so
> > > next time around even for a big project, it would not
> > > take more then a few seconds.
> >
> > I think that there is likely some extra work being done here
that
> > Alex Chapiro is discussing in another thread.
> >
> > Thanks,
> > Thomas
> >
> >
> > > > JohnC
> > > >
> > > > cdt-patch-admin@xxxxxxxxxxx wrote on 10/08/2003 05:54:36
AM:
> > > >
> > > > >
> > > > > What's the problem?
> > > > >
> > > > > In its current state, code assist takes a long
time to pop up
> > > > > completions and they aren't always correct.
> > > > >
> > > > > Why?
> > > > >
> > > > > Code assist currently uses a project scope
when performing a
> > > > > search. Thus all files in a project are searched
- which
> > > > > contributes to the long pop up time (especially
in large
> > > projects)
> > > > > and the inaccurate results (as a file rarely includes
all
> > > > > the other files in the same project).
> > > > >
> > > > > What's in this patch?
> > > > >
> > > > > This patch changes the search scope for code assist
from
> > > a project
> > > > > scope to a file scope. This improves both performance
and
> > > > > accuracy of the matches.
> > > > >
> > > > > Automation Suite run on both Windows + Linux.
> > > > >
> > > > > Thanks,
> > > > > Bogdan
> > > > > [attachment "cdt-core-patch.txt" deleted
by John
> > > Camelon/Ottawa/IBM]
> > > > > [attachment "cdt-ui-patch.txt" deleted
by John
> > > Camelon/Ottawa/IBM]
> > > > _______________________________________________
> > > > cdt-patch mailing list
> > > > cdt-patch@xxxxxxxxxxx
> > > > http://dev.eclipse.org/mailman/listinfo/cdt-patch
> > > >
> > > >
> > > > _______________________________________________
> > > > cdt-patch mailing list
> > > > cdt-patch@xxxxxxxxxxx
> > > > http://dev.eclipse.org/mailman/listinfo/cdt-patch
> > > >
> > >
> > >
> > > --
> > > au revoir, alain
> > > ----
> > > Aussi haut que l'on soit assis, on est toujours assis que
sur
> > > son cul !!!
> > >
> > > _______________________________________________
> > > cdt-patch mailing list
> > > cdt-patch@xxxxxxxxxxx
> > > http://dev.eclipse.org/mailman/listinfo/cdt-patch
> > >
> > _______________________________________________
> > cdt-patch mailing list
> > cdt-patch@xxxxxxxxxxx
> > http://dev.eclipse.org/mailman/listinfo/cdt-patch
>
> _______________________________________________
> cdt-patch mailing list
> cdt-patch@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/cdt-patch
>
_______________________________________________
cdt-patch mailing list
cdt-patch@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/cdt-patch
_______________________________________________
cdt-patch mailing list
cdt-patch@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/cdt-patch
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.203
diff -u -r1.203 ChangeLog
--- ChangeLog 1 Oct 2003 21:33:23 -0000 1.203
+++ ChangeLog 8 Oct 2003 20:07:50 -0000
@@ -1,3 +1,10 @@
+2003-10-08 Bogdan Gheorghe
+
+ - Modified CCompletionProcessor.java to create a file scope
+ instead of a project scope
+
+ * src/org/eclipse/cdt/internal/ui/txt/CCompletionProcessor.java
+
2003-10-01 Andrew Niefer
-bug44032 - deleting/moving files breaks search
* modified src/org/eclipse/cdt/ui/CSearchResultLabelProvider getText to return empty string instead of null
Index: src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java,v
retrieving revision 1.15
diff -u -r1.15 CEditorPreferencePage.java
--- src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java 29 Sep 2003 14:56:38 -0000 1.15
+++ src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java 8 Oct 2003 20:07:51 -0000
@@ -251,6 +251,7 @@
overlayKeys.add(
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.CASE_SENSITIVITY));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ADD_INCLUDE));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.PROJECT_SCOPE_SEARCH));
//new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_FOREGROUND),
//new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_BACKGROUND),
//new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_FOREGROUND),
@@ -346,6 +347,7 @@
store.setDefault(ContentAssistPreference.CASE_SENSITIVITY, false);
store.setDefault(ContentAssistPreference.ORDER_PROPOSALS, false);
store.setDefault(ContentAssistPreference.ADD_INCLUDE, true);
+ store.setDefault(ContentAssistPreference.PROJECT_SCOPE_SEARCH, false);
}
@@ -887,10 +889,13 @@
GridLayout layout = new GridLayout();
layout.numColumns = 2;
contentAssistComposite.setLayout(layout);
+
+ String label= "&Search entire project for completion proposals";
+ addCheckBox(contentAssistComposite, label, ContentAssistPreference.PROJECT_SCOPE_SEARCH, 0);
- String label = "Insert single &proposals automatically";
+ label = "Insert single &proposals automatically";
addCheckBox(contentAssistComposite, label, ContentAssistPreference.AUTOINSERT, 0);
-
+
//label= "Show only proposals visible in the invocation conte&xt";
//addCheckBox(contentAssistComposite, label, ContentAssistPreference.SHOW_VISIBLE_PROPOSALS, 0);
Index: src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java,v
retrieving revision 1.15
diff -u -r1.15 CCompletionProcessor.java
--- src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java 26 Sep 2003 15:25:45 -0000 1.15
+++ src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java 8 Oct 2003 20:07:51 -0000
@@ -12,6 +12,7 @@
import java.util.List;
import java.util.Map;
+import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IMember;
@@ -26,7 +27,9 @@
import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.core.search.SearchEngine;
import org.eclipse.cdt.internal.core.model.CElement;
+import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.cdt.internal.core.search.matching.OrPattern;
+import org.eclipse.cdt.internal.core.sourcedependency.DependencyQueryJob;
import org.eclipse.cdt.internal.corext.template.ContextType;
import org.eclipse.cdt.internal.corext.template.ContextTypeRegistry;
import org.eclipse.cdt.internal.ui.CCompletionContributorManager;
@@ -39,6 +42,9 @@
import org.eclipse.cdt.ui.IFunctionSummary;
import org.eclipse.cdt.ui.IWorkingCopyManager;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
@@ -486,12 +492,37 @@
String prefix = frag + "*";
// TODO: change that to resource scope later
- ICElement[] projectScopeElement = new ICElement[1];
- projectScopeElement[0] = (ICElement)currentScope.getCProject();
- ICSearchScope scope = SearchEngine.createCSearchScope(projectScopeElement, true);
+ if (currentScope == null)
+ return;
+
+ IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
+ boolean projectScope = store.getBoolean(ContentAssistPreference.PROJECT_SCOPE_SEARCH);
+ ICSearchScope scope = null;
+
+ if (projectScope){
+ ICElement[] projectScopeElement = new ICElement[1];
+ projectScopeElement[0] = (ICElement)currentScope.getCProject();
+ scope = SearchEngine.createCSearchScope(projectScopeElement, true);
+ }
+ else{
+ //Try to get the file
+ IResource actualFile = currentScope.getUnderlyingResource();
+ IProject project = currentScope.getCProject().getProject();
+ ArrayList dependencies = new ArrayList();
+ if (actualFile != null){
+ //Get file's dependencies
+ try {
+ IndexManager indexMan = CCorePlugin.getDefault().getCoreModel().getIndexManager();
+ indexMan.performConcurrentJob(new DependencyQueryJob(project, (IFile)actualFile, indexMan, dependencies), ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null);
+ } catch (Exception e) {
+ }
+ }
+ //Create CFileSearchScope
+ scope = SearchEngine.createCFileSearchScope((IFile) actualFile, dependencies);
+ }
+
OrPattern orPattern = new OrPattern();
// search for global variables, functions, classes, structs, unions, enums and macros
-
orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.VAR, ICSearchConstants.DECLARATIONS, false ));
orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.FUNCTION, ICSearchConstants.DECLARATIONS, false ));
orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.FUNCTION, ICSearchConstants.DEFINITIONS, false ));
Index: src/org/eclipse/cdt/internal/ui/text/ContentAssistPreference.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/ContentAssistPreference.java,v
retrieving revision 1.3
diff -u -r1.3 ContentAssistPreference.java
--- src/org/eclipse/cdt/internal/ui/text/ContentAssistPreference.java 26 Sep 2003 15:25:45 -0000 1.3
+++ src/org/eclipse/cdt/internal/ui/text/ContentAssistPreference.java 8 Oct 2003 20:07:51 -0000
@@ -46,7 +46,9 @@
public final static String CASE_SENSITIVITY= "content_assist_case_sensitivity";
/** Preference key for adding imports on code assist */
public final static String ADD_INCLUDE= "content_assist_add_import";
-
+ /** Preference key for completion search scope */
+ public final static String PROJECT_SCOPE_SEARCH= "content_assist_project_scope_search";
+
private static Color getColor(IPreferenceStore store, String key, IColorManager manager) {
RGB rgb= PreferenceConverter.getColor(store, key);
return manager.getColor(rgb);
@@ -118,6 +120,8 @@
enabled= store.getBoolean(AUTOINSERT);
assistant.enableAutoInsert(enabled);
+ enabled= store.getBoolean(PROJECT_SCOPE_SEARCH);
+
configureCProcessor(assistant, store);
}
@@ -177,7 +181,7 @@
} else if (AUTOINSERT.equals(p)) {
boolean enabled= store.getBoolean(AUTOINSERT);
assistant.enableAutoInsert(enabled);
- }
+ }
changeCProcessor(assistant, store, p);
}
Index: search/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/ChangeLog,v
retrieving revision 1.37
diff -u -r1.37 ChangeLog
--- search/ChangeLog 1 Oct 2003 21:33:17 -0000 1.37
+++ search/ChangeLog 8 Oct 2003 20:07:27 -0000
@@ -1,3 +1,7 @@
+2003-10-06 Bogdan Gheorghe
+ - added createCFileSearchScope() to SearchEngine.java to improve
+ code complete performance
+
2003-10-01 Andrew Niefer
- fix bug 44026 by checking scope before reporting match in MatchLocator.report
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.9
diff -u -r1.9 SearchEngine.java
--- search/org/eclipse/cdt/core/search/SearchEngine.java 22 Sep 2003 18:38:24 -0000 1.9
+++ search/org/eclipse/cdt/core/search/SearchEngine.java 8 Oct 2003 20:07:27 -0000
@@ -13,8 +13,11 @@
*/
package org.eclipse.cdt.core.search;
+import java.util.ArrayList;
import java.util.HashSet;
+import java.util.Iterator;
+import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.core.Util;
@@ -27,9 +30,12 @@
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
import org.eclipse.cdt.internal.core.search.matching.MatchLocator;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.SubProgressMonitor;
/**
@@ -95,6 +101,40 @@
return scope;
}
+ /**
+ * @param objects
+ * @return
+ */
+ public static ICSearchScope createCFileSearchScope(IFile sourceFile, ArrayList elements) {
+ CSearchScope scope = new CSearchScope();
+ HashSet visitedProjects = new HashSet(2);
+
+ if (sourceFile != null){
+ //Add the source file and project
+ scope.addFile(sourceFile.getFullPath(), sourceFile.getProject());
+ IPath rootPath = CCorePlugin.getWorkspace().getRoot().getLocation();
+ int segCount = CCorePlugin.getWorkspace().getRoot().getLocation().segmentCount();
+ if (elements!=null){
+ Iterator i = elements.iterator();
+ while (i.hasNext()){
+ IPath tempPath = new Path((String) i.next());
+ if (rootPath.isPrefixOf(tempPath)){
+ //path is in workspace
+ IFile tempFile = CCorePlugin.getWorkspace().getRoot().getFile(tempPath);
+ IPath finalPath = tempFile.getFullPath().removeFirstSegments(segCount);
+ tempFile = CCorePlugin.getWorkspace().getRoot().getFile(finalPath);
+ scope.addFile(tempFile.getFullPath(), tempFile.getProject());
+ }
+ else{
+ scope.addFile(tempPath,null);
+ }
+
+ }
+ }
+ }
+ return scope;
+ }
+
public static ICSearchPattern createSearchPattern( String stringPattern, SearchFor searchFor, LimitTo limitTo, boolean isCaseSensitive){
int mode;
@@ -147,7 +187,7 @@
pathCollector,
indexManager
),
- ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
+ ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
subMonitor );
subMonitor = (progressMonitor == null ) ? null : new SubProgressMonitor( progressMonitor, 95 );
Index: search/org/eclipse/cdt/internal/core/search/CSearchScope.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/CSearchScope.java,v
retrieving revision 1.4
diff -u -r1.4 CSearchScope.java
--- search/org/eclipse/cdt/internal/core/search/CSearchScope.java 29 Sep 2003 21:35:10 -0000 1.4
+++ search/org/eclipse/cdt/internal/core/search/CSearchScope.java 8 Oct 2003 20:07:27 -0000
@@ -233,4 +233,19 @@
}
}
}
+
+ /**
+ * @param finalPath
+ */
+ public void addFile(IPath filePath, IProject fileProject) {
+ //Add the file
+ this.add(filePath, true);
+ //Add the files' containing project - unless it's an external file
+ //in which case this is null
+ if (fileProject != null){
+ this.addEnclosingProject(fileProject.getFullPath());
+ }
+
+ }
+
}