Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Fix for PR45 609 Applied to CDT_1.2

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/ChangeLog,v
retrieving revision 1.159.2.2
diff -u -r1.159.2.2 ChangeLog
--- ChangeLog	27 Oct 2003 20:44:57 -0000	1.159.2.2
+++ ChangeLog	29 Oct 2003 16:38:11 -0000
@@ -1,3 +1,10 @@
+2003-10-29 Alain Magloire
+
+	When a resource is linked, IWorkspaceRoot.getFileForLocation();
+	Does not do the job righ, we have to use IWorkspaceRoot.findFilesForLocation().
+
+	* src/org/eclipse/cdt/core/ErrorParserManager.java
+
 2003-10-27 Bogdan Gheorghe
 
 	Modified DeltaProcessor.updateDependencies to offload dependency
Index: model/org/eclipse/cdt/internal/core/model/CModelManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java,v
retrieving revision 1.33
diff -u -r1.33 CModelManager.java
--- model/org/eclipse/cdt/internal/core/model/CModelManager.java	26 Sep 2003 17:53:31 -0000	1.33
+++ model/org/eclipse/cdt/internal/core/model/CModelManager.java	29 Oct 2003 16:38:11 -0000
@@ -46,12 +46,12 @@
 
 public class CModelManager implements IResourceChangeListener {
 
-    /**
-     * Unique handle onto the CModel
-     */
-    final CModel cModel = new CModel();
+	/**
+	 * Unique handle onto the CModel
+	 */
+	final CModel cModel = new CModel();
     
-    public static HashSet OptionNames = new HashSet(20);
+	public static HashSet OptionNames = new HashSet(20);
         
 	/**
 	 * Used to convert <code>IResourceDelta</code>s into <code>ICElementDelta</code>s.
@@ -356,7 +356,11 @@
 		if (project != null) {
 			ICElement celement = create(project);
 			if (celement != null) {
+				// Let the function remove the children
+				// but it has the side of effect of removing the CProject also
+				// so we have to recall create again.
 				releaseCElement(celement);
+				celement = create(project);
 				// Fired and ICElementDelta.PARSER_CHANGED
 				CElementDelta delta = new CElementDelta(getCModel());
 				delta.binaryParserChanged(celement);
@@ -554,8 +558,8 @@
 				case IResourceChangeEvent.PRE_DELETE :
 				try{
 					if (resource.getType() == IResource.PROJECT && 	
-					    ( ((IProject)resource).hasNature(CProjectNature.C_NATURE_ID) ||
-					      ((IProject)resource).hasNature(CCProjectNature.CC_NATURE_ID) )){
+						( ((IProject)resource).hasNature(CProjectNature.C_NATURE_ID) ||
+						  ((IProject)resource).hasNature(CCProjectNature.CC_NATURE_ID) )){
 						this.deleting((IProject) resource);}
 				}catch (CoreException e){
 				}
Index: src/org/eclipse/cdt/core/ErrorParserManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java,v
retrieving revision 1.17
diff -u -r1.17 ErrorParserManager.java
--- src/org/eclipse/cdt/core/ErrorParserManager.java	24 Sep 2003 14:48:19 -0000	1.17
+++ src/org/eclipse/cdt/core/ErrorParserManager.java	29 Oct 2003 16:38:11 -0000
@@ -20,6 +20,7 @@
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
@@ -208,6 +209,28 @@
 		return (IFile) fFilesInProject.get(path.lastSegment());
 	}
 
+	protected IFile findFileInWorkspace(IPath path) {
+		IFile file = null;
+		if (path.isAbsolute()) {
+			IWorkspaceRoot root = fProject.getWorkspace().getRoot();
+			file =  root.getFileForLocation(path);
+			// It may be a link resource so we must check it also.
+			if (file == null) {
+				IFile[] files = root.findFilesForLocation(path);
+				for (int i = 0; i < files.length; i++) {
+					if (files[i].getProject().equals(fProject)) {
+						file = files[i];
+						break;
+					}
+				}
+			}
+
+		} else {
+			file = fProject.getFile(path);
+		}
+		return file;
+	}
+
 	/**
 	 * Called by the error parsers.
 	 */
@@ -235,9 +258,9 @@
 
 		IFile file = null;
 		// The workspace may throw an IllegalArgumentException
-		// Catch it and the parser will fallback to scan the entire project.
+		// Catch it and the parser should fallback to scan the entire project.
 		try {
-			file = (path.isAbsolute()) ? fProject.getWorkspace().getRoot().getFileForLocation(path) : fProject.getFile(path);
+			file = findFileInWorkspace(path);
 		} catch (Exception e) {
 		}
 
@@ -248,11 +271,9 @@
 			try {
 				String canon = f.getCanonicalPath();
 				path = new Path(canon);
-				file = (path.isAbsolute()) ? fProject.getWorkspace().getRoot().getFileForLocation(path) : fProject.getFile(path);
+				file = findFileInWorkspace(path);
 			} catch (IOException e1) {
 			}
-		} else {
-			return file;
 		}
 		return (file != null && file.exists()) ? file : null;
 	}



Back to the top