Revision: 4892
          http://sourceforge.net/p/vexi/code/4892
Author:   mkpg2
Date:     2016-10-28 01:45:47 +0000 (Fri, 28 Oct 2016)
Log Message:
-----------
Refactor/share path building.

Modified Paths:
--------------
    trunk/tools/org.vexi.vexidev/src/org/vexi/vexidev/VexiProject.java

Added Paths:
-----------
    
trunk/org.vexi-vexidev.conf/src/main/java/org/vexi/vexidev/conf/IProjectPath.java
    
trunk/org.vexi-vexidev.conf/src/main/java/org/vexi/vexidev/conf/PathBuilder.java

Added: 
trunk/org.vexi-vexidev.conf/src/main/java/org/vexi/vexidev/conf/IProjectPath.java
===================================================================
--- 
trunk/org.vexi-vexidev.conf/src/main/java/org/vexi/vexidev/conf/IProjectPath.java
                           (rev 0)
+++ 
trunk/org.vexi-vexidev.conf/src/main/java/org/vexi/vexidev/conf/IProjectPath.java
   2016-10-28 01:45:47 UTC (rev 4892)
@@ -0,0 +1,8 @@
+package org.vexi.vexidev.conf;
+
+public interface IProjectPath {
+       public String getName();
+       public Xml.ProjectPath getPath();
+       public IProjectPath getDependency(Xml.PathEntry dep);
+       
+}


Property changes on: 
trunk/org.vexi-vexidev.conf/src/main/java/org/vexi/vexidev/conf/IProjectPath.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: 
trunk/org.vexi-vexidev.conf/src/main/java/org/vexi/vexidev/conf/PathBuilder.java
===================================================================
--- 
trunk/org.vexi-vexidev.conf/src/main/java/org/vexi/vexidev/conf/PathBuilder.java
                            (rev 0)
+++ 
trunk/org.vexi-vexidev.conf/src/main/java/org/vexi/vexidev/conf/PathBuilder.java
    2016-10-28 01:45:47 UTC (rev 4892)
@@ -0,0 +1,46 @@
+package org.vexi.vexidev.conf;
+
+import java.util.ArrayList;
+
+public class PathBuilder {
+
+       static private void addToPath(Xml.Path r, IProjectPath proj, 
Xml.ScopePath scopePath){
+               for(Xml.PathEntry dep0: scopePath.dependencies){
+                       if(dep0.type==EntryType.project){
+                               IProjectPath dep = proj.getDependency(dep0);
+                               addToPath(r,dep,dep.getPath().main);
+                       }else{
+                               r.entries.add(dep0);
+                       }
+               }
+               
+               for(Xml.SourceDir source: scopePath.sources){
+                       Xml.PathEntry e = new Xml.PathEntry();
+                       e.type=EntryType.workspace_directory;
+//                     IPath p = new Path("/"+project.getName());
+//                     p = p.append(source.path);
+                       e.path="/"+proj.getName()+"/"+source.path; 
+                       r.entries.add(e);
+               }
+       }
+       
+    // Recurse on all referenced projects adding sourcepath of each one
+       static synchronized public Xml.Path getFullPath(IProjectPath proj, 
Scope scope) {
+               Xml.Path r = new Xml.Path();
+               r.entries = new ArrayList();
+               
+               Xml.ProjectPath ppath = proj.getPath();
+               if(scope.includesMain()){
+                       addToPath(r,proj,ppath.main);
+               }
+               if(scope.includesTest()){
+                       addToPath(r,proj,ppath.test);
+                       r.addLibrary("VUNIT");
+               }
+               if(scope.includesPoke()){
+                       addToPath(r,proj,ppath.poke);
+               }
+               return r; 
+       }
+
+}


Property changes on: 
trunk/org.vexi-vexidev.conf/src/main/java/org/vexi/vexidev/conf/PathBuilder.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/tools/org.vexi.vexidev/src/org/vexi/vexidev/VexiProject.java
===================================================================
--- trunk/tools/org.vexi.vexidev/src/org/vexi/vexidev/VexiProject.java  
2016-10-21 21:21:39 UTC (rev 4891)
+++ trunk/tools/org.vexi.vexidev/src/org/vexi/vexidev/VexiProject.java  
2016-10-28 01:45:47 UTC (rev 4892)
@@ -21,13 +21,15 @@
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.PlatformObject;
-import org.vexi.vexidev.conf.EntryType;
+import org.vexi.vexidev.conf.IProjectPath;
+import org.vexi.vexidev.conf.PathBuilder;
 import org.vexi.vexidev.conf.Scope;
 import org.vexi.vexidev.conf.Xml;
+import org.vexi.vexidev.conf.Xml.PathEntry;
 import org.vexi.vexidev.conf.Xml.ProjectPath;
 import org.vexi.vexidev.util.ConfUtil;
 
-public class VexiProject extends PlatformObject implements IConstants{
+public class VexiProject extends PlatformObject implements IConstants, 
org.vexi.vexidev.conf.IProjectPath{
        
        final public IProject project;
        
@@ -35,6 +37,15 @@
                this.project = project;
        }
        
+       public String getName() {
+               return project.getName();
+       }
+       
+       public IProjectPath getDependency(PathEntry dep) {
+               IProject project = (IProject)ConfUtil.asResource(dep);
+               return (VexiProject)project.getAdapter(VexiProject.class);
+       }
+       
        public Xml.ProjectPath load() throws Exception{
                IFile file = project.getFile(".vexipath");
                if(file.exists()){
@@ -123,47 +134,10 @@
                }
                return r;
        }
-
-
-       private void addToPath(Xml.Path r, Xml.ScopePath scopePath){
-               for(Xml.PathEntry dep: scopePath.dependencies){
-                       if(dep.type==EntryType.project){
-                               IProject project = 
(IProject)ConfUtil.asResource(dep);
-                               VexiProject vproject = 
(VexiProject)project.getAdapter(VexiProject.class);
-                               vproject.addToPath(r,vproject.getPath().main);
-                       }else{
-                               r.entries.add(dep);
-                       }
-               }
-               
-               for(Xml.SourceDir source: scopePath.sources){
-                       Xml.PathEntry e = new Xml.PathEntry();
-                       e.type=EntryType.workspace_directory;
-//                     IPath p = new Path("/"+project.getName());
-//                     p = p.append(source.path);
-                       e.path="/"+project.getName()+"/"+source.path; 
-                       r.entries.add(e);
-               }
-       }
        
     // Recurse on all referenced projects adding sourcepath of each one
        synchronized public Xml.Path getFullPath(Scope scope) {
-               Xml.Path r = new Xml.Path();
-               r.entries = new ArrayList();
-
-               
-               Xml.ProjectPath ppath = getPath();
-               if(scope.includesMain()){
-                       addToPath(r,ppath.main);
-               }
-               if(scope.includesTest()){
-                       addToPath(r,ppath.test);
-                       r.addLibrary("VUNIT");
-               }
-               if(scope.includesPoke()){
-                       addToPath(r,ppath.poke);
-               }
-               return r; 
+               return PathBuilder.getFullPath(this, scope);             
        }
 
        void reportError(String msg) throws CoreException {

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to