Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] CProject.findElement() fix.

2002-11-01 Alain Magloire

        * model/../internal/core/mode/CProject.java (findElement):
        Check if the path is Absolute or relative before creating the
        element.


Index: org/eclipse/cdt/internal/core/model/CProject.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java,v
retrieving revision 1.1
diff -u -r1.1 CProject.java
--- org/eclipse/cdt/internal/core/model/CProject.java   26 Jun 2002 20:37:14 -0000      1.1
+++ org/eclipse/cdt/internal/core/model/CProject.java   1 Nov 2002 20:10:35 -0000
@@ -45,9 +45,20 @@
        }
 
        public ICElement findElement(IPath path) throws CModelException {
-               ICElement celem =  CModelManager.getDefault().create(path);
-               if (celem == null)
-                       new CModelStatus(ICModelStatusConstants.INVALID_PATH, path);
+               ICElement celem = null;
+               if (path.isAbsolute()) {
+                       celem =  CModelManager.getDefault().create(path);
+               } else {
+                       IProject project = getProject();
+                       if (project !=  null) {
+                               IPath p = project.getFullPath().append(path);
+                               celem = CModelManager.getDefault().create(p);
+                       }
+               }
+               if (celem == null) {
+                       CModelStatus status = new CModelStatus(ICModelStatusConstants.INVALID_PATH, path);
+                       throw new CModelException(status);
+               }
                return celem;
        }




Back to the top