Avoid NPE for "Mark Occurrences"
[phpeclipse.git] / net.sourceforge.phpeclipse.launching / src / net / sourceforge / phpdt / internal / launching / PHPRuntime.java
index f454e62..0613535 100644 (file)
@@ -49,11 +49,11 @@ public class PHPRuntime {
                return selectedInterpreter;
        }
 
-       public PHPInterpreter getInterpreter(String name) {
+       public PHPInterpreter getInterpreter(String installLocation) {
                Iterator interpreters = getInstalledInterpreters().iterator();
                while(interpreters.hasNext()) {
                        PHPInterpreter each = (PHPInterpreter) interpreters.next();
-                       if (each.getName().equals(name))
+                       if (each.getInstallLocation().toString().equals(installLocation))
                                return each;
                }
                
@@ -129,7 +129,7 @@ public class PHPRuntime {
                                writer.write("<interpreter name=\"");
                                
                                PHPInterpreter entry = (PHPInterpreter) interpretersIterator.next();
-                               writer.write(entry.getName());
+//                             writer.write(entry.getName());
                                writer.write("\" path=\"");
                                writer.write(entry.getInstallLocation().toString());
                                writer.write("\"");
@@ -154,9 +154,14 @@ public class PHPRuntime {
                        public void endPrefixMapping(String prefix) throws SAXException {}
                        public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
                                if ("interpreter".equals(qName)) {
-                                       String interpreterName = atts.getValue("name");
-                                       IPath installLocation = new Path(atts.getValue("path"));
-                                       PHPInterpreter interpreter = new PHPInterpreter(interpreterName, installLocation);
+                                       String interpreterName = atts.getValue("name");
+                                       java.io.File installLocation;
+                                       if (interpreterName!=null) {
+                                         installLocation = new File(atts.getValue("path")+File.separatorChar+interpreterName);
+                                       } else {
+                                         installLocation = new File(atts.getValue("path"));
+                                       }
+                                       PHPInterpreter interpreter = new PHPInterpreter(installLocation);
                                        installedInterpreters.add(interpreter);
                                        if (atts.getValue("selected") != null)
                                                selectedInterpreter = interpreter;