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

Merged 1.2 fixes into HEAD. Includes:

- managed make fix for infinite make recursion
- search fix for large projects
- fixes to source project so that it actually contains source
This commit is contained in:
Doug Schaefer 2003-10-27 18:26:54 +00:00
parent df996a4a6f
commit de44b4c4a2
9 changed files with 143 additions and 11 deletions

View file

@ -1,3 +1,29 @@
2003-10-03 Sean Evoy
Fix for critical bug 44134.
The problem lies in how the makefile is generated when a build target
references other projects. The makefile creates a command to change to
the build directory of the referenced project and call $(MAKE) there, i.e.
cd <dep_project_build_dir>; $(MAKE) clean all
The problem arises when the directory change fails. As of RC0, the command
after the semi-colon is evaluated. Unfortunately, it evaluates to a recursive
make call in the build directory of the build target and 'make' will keep
invoking more 'make's until Eclipse runs out of memory. With a manual build,
the user can still cancel the build. When autobuild is turned on, they cannot.
The only way to shut down Eclipse under that scenario is to kill it, and when
it restarts, autobuild is still enabled and the problem repeats.
The solution is to NOT perform the 'make' command if the 'cd' fails, i.e.
cd <dep_project_build_dir> && $(MAKE) clean all
When the dependencies are generated this way, the 'cd' will fail as will the
build. The final tweak is to ignore the 'cd' failure and allow the rest of
the build to continue, i.e.
-cd <dep_project_build_dir> && $(MAKE) clean all
* src/org/eclipse/cdt/managedbuilder/internal/core/MakefileGenerator.java
2003-10-01 Sean Evoy
Final fix for bugs 44020.
The problem lay with the way that new projects were being created when the

View file

@ -68,7 +68,7 @@ public class MakefileGenerator {
protected static final String MODFILE_NAME = "subdir.mk"; //$NON-NLS-1$
protected static final String LINEBREAK = "\\";
protected static final String NEWLINE = System.getProperty("line.separator");
protected static final String SEMI_COLON = ";";
protected static final String LOGICAL_AND = "&&";
protected static final String SEPARATOR = "/";
protected static final String TAB = "\t";
protected static final String WHITESPACE = " ";
@ -562,7 +562,7 @@ public class MakefileGenerator {
}
managedProjectOutputs.add(buildDir + SEPARATOR + depPrefix + depTarget);
}
buffer.append(TAB + "cd" + WHITESPACE + buildDir + SEMI_COLON + WHITESPACE + "$(MAKE) " + depTargets + NEWLINE);
buffer.append(TAB + "-cd" + WHITESPACE + buildDir + WHITESPACE + LOGICAL_AND + WHITESPACE + "$(MAKE) " + depTargets + NEWLINE);
}
}
buffer.append(NEWLINE);

View file

@ -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

View file

@ -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.PatternSearchJob;
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 @@ public class SearchEngine implements ICSearchConstants{
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 @@ public class SearchEngine implements ICSearchConstants{
pathCollector,
indexManager
),
ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
subMonitor );
subMonitor = (progressMonitor == null ) ? null : new SubProgressMonitor( progressMonitor, 95 );

View file

@ -233,4 +233,19 @@ public class CSearchScope implements ICSearchScope {
}
}
}
/**
* @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());
}
}
}

View file

@ -63,6 +63,13 @@
* src/org/eclipse/cdt/internal/ui/CEditor.java
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

View file

@ -251,6 +251,7 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
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 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
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 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
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);

View file

@ -12,6 +12,7 @@ import java.util.LinkedList;
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.ICSearchConstants;
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.FunctionPrototypeSummary;
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 @@ public class CCompletionProcessor implements IContentAssistProcessor {
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 ));

View file

@ -46,7 +46,9 @@ public class ContentAssistPreference {
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 @@ public class ContentAssistPreference {
enabled= store.getBoolean(AUTOINSERT);
assistant.enableAutoInsert(enabled);
enabled= store.getBoolean(PROJECT_SCOPE_SEARCH);
configureCProcessor(assistant, store);
}
@ -177,7 +181,7 @@ public class ContentAssistPreference {
} else if (AUTOINSERT.equals(p)) {
boolean enabled= store.getBoolean(AUTOINSERT);
assistant.enableAutoInsert(enabled);
}
}
changeCProcessor(assistant, store, p);
}