misc
authoraxelcl <axelcl>
Sun, 28 Nov 2004 12:02:54 +0000 (12:02 +0000)
committeraxelcl <axelcl>
Sun, 28 Nov 2004 12:02:54 +0000 (12:02 +0000)
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/JavaContext.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCompletionProcessor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpsyntax.xml

index 09b5fb0..e2315a7 100644 (file)
@@ -19,7 +19,6 @@ import net.sourceforge.phpdt.internal.corext.util.Strings;
 import net.sourceforge.phpdt.internal.ui.preferences.CodeFormatterPreferencePage;
 import net.sourceforge.phpdt.internal.ui.text.template.contentassist.MultiVariable;
 import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler;
-import net.sourceforge.phpdt.ui.PreferenceConstants;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 
 import org.eclipse.core.runtime.CoreException;
@@ -161,7 +160,7 @@ public class JavaContext extends CompilationUnitContext {
         while ((start != 0) && Character.isUnicodeIdentifierPart(document.getChar(start - 1)))
           start--;
 
-        if ((start != 0) && Character.isUnicodeIdentifierStart(document.getChar(start - 1)))
+        if ((start != 0) && (Character.isUnicodeIdentifierStart(document.getChar(start - 1))||(document.getChar(start - 1)=='$') ))
           start--;
 
         return start;
@@ -173,7 +172,8 @@ public class JavaContext extends CompilationUnitContext {
 
         while (start != 0 && Character.isUnicodeIdentifierPart(document.getChar(start - 1)))
           start--;
-
+        if ((start != 0) && (Character.isUnicodeIdentifierStart(document.getChar(start - 1))||(document.getChar(start - 1)=='$') ))
+          start--;
         while (start != end && Character.isWhitespace(document.getChar(start)))
           start++;
 
@@ -217,8 +217,9 @@ public class JavaContext extends CompilationUnitContext {
    */
   public String getKey() {
 
-    if (getCompletionLength() == 0)
-      return super.getKey();
+//    if (getCompletionLength() == 0) {
+//      return super.getKey();
+//    }
 
     try {
       IDocument document = getDocument();
index 72d3508..ac785cf 100644 (file)
@@ -5,9 +5,6 @@
  which accompanies this distribution, and is available at
  http://www.eclipse.org/legal/cpl-v10.html
 
- Contributors:
- IBM Corporation - Initial implementation
- Klaus Hartlage - www.eclipseproject.de
  **********************************************************************/
 package net.sourceforge.phpeclipse;
 
@@ -304,6 +301,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
     plugin = this;
     setJVM();
     externalTools = new ExternalToolsPlugin();
+    
     //    try {
     //      resourceBundle =
     // ResourceBundle.getBundle("net.sourceforge.PHPeclipsePluginResources");
@@ -690,8 +688,9 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
     //    store.setDefault(PHP_LOCALHOST_PREF, "http://localhost");
     //    store.setDefault(PHP_DOCUMENTROOT_PREF, getWorkspace().getRoot()
     //        .getLocation().toString());
+    
 
-    //    store.setDefault(SHOW_EXTERNAL_PREVIEW_PREF, "true");
+//    store.setDefault(SHOW_EXTERNAL_PREVIEW_PREF, "true");
 //    store.setDefault(USE_EXTERNAL_BROWSER_PREF, "false");
     store.setDefault(SHOW_OUTPUT_IN_CONSOLE, "true");
     store.setDefault(PHP_OBFUSCATOR_DEFAULT, "c:\\temp");
@@ -716,6 +715,32 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
     //  if ((jvm == WINDOWS_9x) || (jvm == WINDOWS_NT)) {
     // 
     if (windowsSystem.equals(Platform.WS_WIN32)) {
+//      String workspaceLocation = getWorkspace().getRoot().getLocation().toString();
+//      String baseLocation = null;
+//      int index = workspaceLocation.lastIndexOf('/');
+//      if (index>0) {
+//        index = workspaceLocation.lastIndexOf('/', index-1);
+//        if (index>0) {
+//          baseLocation = workspaceLocation.substring(0,index);
+//        }
+//      }
+//      if (baseLocation!=null) {
+//        String xampp_start = baseLocation + "/xampp_start.exe";
+//        String xampp_stop = baseLocation + "/xampp_stop.exe";
+//        File testFile = new File(xampp_start);
+//        if (testFile.exists()) {
+//          System.out.println(xampp_start);
+//          System.out.println(xampp_stop);
+//        } else {
+//          xampp_start = "c:\\xampp\\xampp_start.exe";
+//          xampp_stop = "c:\\xampp\\xampp_stop.exe";
+//          testFile = new File(xampp_start);
+//          if (testFile.exists()) {
+//            System.out.println(xampp_start);
+//            System.out.println(xampp_stop);
+//          }
+//        }
+//      }
       store.setDefault(PHP_RUN_PREF, "c:\\apache\\php\\php.exe");
       store.setDefault(EXTERNAL_PARSER_PREF, "c:\\apache\\php\\php -l -f {0}");
       store.setDefault(MYSQL_RUN_PREF, "c:\\apache\\mysql\\bin\\mysqld-nt.exe");
@@ -1127,7 +1152,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
    */
   public void start(BundleContext context) throws Exception {
     super.start(context);
-
+    
     //         JavaCore.start(this, context);
     final JavaModelManager manager = JavaModelManager.getJavaModelManager();
     try {
index 2a165c5..939bd77 100644 (file)
@@ -7,7 +7,6 @@
 
  Contributors:
  IBM Corporation - Initial implementation
- Klaus Hartlage - www.eclipseproject.de
  **********************************************************************/
 package net.sourceforge.phpeclipse.phpeditor.php;
 
@@ -604,93 +603,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
       }
       IPHPCompletionProposal[] sqlResults = new IPHPCompletionProposal[0];
       if (project != null) {
-        // Get The Database bookmark from the Quantum SQL plugin:
-        BookmarkCollection sqlBookMarks = BookmarkCollection.getInstance();
-        if (sqlBookMarks != null) {
-          String bookmarkString = Util.getMiscProjectsPreferenceValue(project,
-              IPreferenceConstants.PHP_BOOKMARK_DEFAULT);
-          if (bookmarkString != null && !bookmarkString.equals("")) {
-            Bookmark bookmark = sqlBookMarks.find(bookmarkString);
-            ArrayList sqlList = new ArrayList();
-            if (bookmark != null && !bookmark.isConnected()) {
-              new ConnectionUtil().connect(bookmark, null);
-            }
-            if (bookmark != null && bookmark.isConnected()) {
-              try {
-                Connection connection = bookmark.getConnection();
-                DatabaseMetaData metaData = connection.getMetaData();
-
-                if (metaData != null) {
-                  int start = context.getStart();
-                  int end = context.getEnd();
-                  String foundSQLTableName = sqlTable.getTableName();
-                  String tableName;
-                  String columnName;
-                  String prefixWithoutDollar = prefix;
-                  boolean isDollarPrefix = false;
-                  if (prefix.length() > 0 && prefix.charAt(0) == '$') {
-                    prefixWithoutDollar = prefix.substring(1);
-                    isDollarPrefix = true;
-                  }
-                  IRegion region = new Region(start, end - start);
-                  ResultSet set;
-                  if (!isDollarPrefix) {
-                    set = metaData.getTables(null, null, prefixWithoutDollar
-                        + "%", null);
-                    while (set.next()) {
-                      //                  String tempSchema = set.getString("TABLE_SCHEM");
-                      //                  tempSchema = (tempSchema == null) ? "" :
-                      // tempSchema.trim();
-                      tableName = set.getString("TABLE_NAME");
-                      tableName = (tableName == null) ? "" : tableName.trim();
-                      if (tableName != null && tableName.length() > 0) {
-                        sqlList.add(new SQLProposal(tableName, context, region,
-                            viewer, PHPUiImages.get(PHPUiImages.IMG_TABLE)));
-                      }
-                    }
-                    set.close();
-                  }
-                  set = metaData.getColumns(null, null, "%",
-                      prefixWithoutDollar + "%");
-                  SQLProposal sqlProposal;
-                  while (set.next()) {
-                    columnName = set.getString("COLUMN_NAME");
-                    columnName = (columnName == null) ? "" : columnName.trim();
-                    tableName = set.getString("TABLE_NAME");
-                    tableName = (tableName == null) ? "" : tableName.trim();
-                    if (tableName != null && tableName.length() > 0
-                        && columnName != null && columnName.length() > 0) {
-                      if (isDollarPrefix) {
-                        sqlProposal = new SQLProposal(tableName, "$"
-                            + columnName, context, region, viewer, PHPUiImages
-                            .get(PHPUiImages.IMG_COLUMN));
-                      } else {
-                        sqlProposal = new SQLProposal(tableName, columnName,
-                            context, region, viewer, PHPUiImages
-                                .get(PHPUiImages.IMG_COLUMN));
-                      }
-                      if (tableName.equals(foundSQLTableName)) {
-                        sqlProposal.setRelevance(90);
-                      } else if (tableName.indexOf(foundSQLTableName) >= 0) {
-                        sqlProposal.setRelevance(75);
-                      }
-                      sqlList.add(sqlProposal);
-                    }
-                  }
-                  set.close();
-                  sqlResults = new IPHPCompletionProposal[sqlList.size()];
-                  for (int i = 0; i < sqlList.size(); i++) {
-                    sqlResults[i] = (SQLProposal) sqlList.get(i);
-                  }
-                }
-              } catch (NotConnectedException e) {
-                // ignore this - not mission critical
-              } catch (SQLException e) {
-                e.printStackTrace();
-              }
-            }
-          }
-        }
+        sqlResults = getSQLProposals(viewer, project, context, prefix, sqlTable, sqlResults);
       }
       // concatenate the result arrays
       IPHPCompletionProposal[] total;
@@ -719,6 +632,106 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
     return new IPHPCompletionProposal[0];
   }
 
+  /**
+   * @param viewer
+   * @param project
+   * @param context
+   * @param prefix
+   * @param sqlTable
+   * @param sqlResults
+   * @return
+   */
+  private IPHPCompletionProposal[] getSQLProposals(ITextViewer viewer, IProject project, JavaContext context, String prefix, TableName sqlTable, IPHPCompletionProposal[] sqlResults) {
+    // Get The Database bookmark from the Quantum SQL plugin:
+    BookmarkCollection sqlBookMarks = BookmarkCollection.getInstance();
+    if (sqlBookMarks != null) {
+      String bookmarkString = Util.getMiscProjectsPreferenceValue(project,
+          IPreferenceConstants.PHP_BOOKMARK_DEFAULT);
+      if (bookmarkString != null && !bookmarkString.equals("")) {
+        Bookmark bookmark = sqlBookMarks.find(bookmarkString);
+        ArrayList sqlList = new ArrayList();
+        if (bookmark != null && !bookmark.isConnected()) {
+          new ConnectionUtil().connect(bookmark, null);
+        }
+        if (bookmark != null && bookmark.isConnected()) {
+          try {
+            Connection connection = bookmark.getConnection();
+            DatabaseMetaData metaData = connection.getMetaData();
+
+            if (metaData != null) {
+              int start = context.getStart();
+              int end = context.getEnd();
+              String foundSQLTableName = sqlTable.getTableName();
+              String tableName;
+              String columnName;
+              String prefixWithoutDollar = prefix;
+              boolean isDollarPrefix = false;
+              if (prefix.length() > 0 && prefix.charAt(0) == '$') {
+                prefixWithoutDollar = prefix.substring(1);
+                isDollarPrefix = true;
+              }
+              IRegion region = new Region(start, end - start);
+              ResultSet set;
+              if (!isDollarPrefix) {
+                set = metaData.getTables(null, null, prefixWithoutDollar
+                    + "%", null);
+                while (set.next()) {
+                  //                  String tempSchema = set.getString("TABLE_SCHEM");
+                  //                  tempSchema = (tempSchema == null) ? "" :
+                  // tempSchema.trim();
+                  tableName = set.getString("TABLE_NAME");
+                  tableName = (tableName == null) ? "" : tableName.trim();
+                  if (tableName != null && tableName.length() > 0) {
+                    sqlList.add(new SQLProposal(tableName, context, region,
+                        viewer, PHPUiImages.get(PHPUiImages.IMG_TABLE)));
+                  }
+                }
+                set.close();
+              }
+              set = metaData.getColumns(null, null, "%",
+                  prefixWithoutDollar + "%");
+              SQLProposal sqlProposal;
+              while (set.next()) {
+                columnName = set.getString("COLUMN_NAME");
+                columnName = (columnName == null) ? "" : columnName.trim();
+                tableName = set.getString("TABLE_NAME");
+                tableName = (tableName == null) ? "" : tableName.trim();
+                if (tableName != null && tableName.length() > 0
+                    && columnName != null && columnName.length() > 0) {
+                  if (isDollarPrefix) {
+                    sqlProposal = new SQLProposal(tableName, "$"
+                        + columnName, context, region, viewer, PHPUiImages
+                        .get(PHPUiImages.IMG_COLUMN));
+                  } else {
+                    sqlProposal = new SQLProposal(tableName, columnName,
+                        context, region, viewer, PHPUiImages
+                            .get(PHPUiImages.IMG_COLUMN));
+                  }
+                  if (tableName.equals(foundSQLTableName)) {
+                    sqlProposal.setRelevance(90);
+                  } else if (tableName.indexOf(foundSQLTableName) >= 0) {
+                    sqlProposal.setRelevance(75);
+                  }
+                  sqlList.add(sqlProposal);
+                }
+              }
+              set.close();
+              sqlResults = new IPHPCompletionProposal[sqlList.size()];
+              for (int i = 0; i < sqlList.size(); i++) {
+                sqlResults[i] = (SQLProposal) sqlList.get(i);
+              }
+            }
+          } catch (NotConnectedException e) {
+            // ignore this - not mission critical
+          } catch (SQLException e) {
+            e.printStackTrace();
+          }
+        }
+      }
+    }
+    return sqlResults;
+  }
+
   private int guessContextInformationPosition(ITextViewer viewer, int offset) {
     int contextPosition = offset;
     IDocument document = viewer.getDocument();
index 56b9078..b3161ee 100644 (file)
         <phpsyntax keyword="null" tokenval="1044"></phpsyntax>
         <phpsyntax keyword="false" tokenval="1045"></phpsyntax>
         <phpsyntax keyword="true" tokenval="1046"></phpsyntax>
-        
+        <phpsyntax keyword="NULL" tokenval="1044"></phpsyntax>
+        <phpsyntax keyword="FALSE" tokenval="1045"></phpsyntax>
+        <phpsyntax keyword="TRUE" tokenval="1046"></phpsyntax>
         <phpsyntax keyword="abstract" tokenval="1050"></phpsyntax>
            <phpsyntax keyword="catch" tokenval="1051"></phpsyntax>
            <phpsyntax keyword="finally" tokenval="1052"></phpsyntax>
        <phpsyntax keyword="use" tokenval="1066"></phpsyntax>
        <phpsyntax keyword="isset" tokenval="1066"></phpsyntax>
        <phpsyntax keyword="final" tokenval="1067"></phpsyntax>
+       <phpsyntax keyword="__FUNCTION__" tokenval="1090"></phpsyntax>
+       <phpsyntax keyword="__CLASS__" tokenval="1091"></phpsyntax>
+       <phpsyntax keyword="__METHOD__" tokenval="1092"></phpsyntax>
+       <phpsyntax keyword="__FILE__" tokenval="1093"></phpsyntax>
+       <phpsyntax keyword="__LINE__" tokenval="1094"></phpsyntax>
+       <phpsyntax keyword="__FUNCTION__" tokenval="1095"></phpsyntax>
+       <phpsyntax keyword="php_user_filter" tokenval="1096"></phpsyntax>
+       <phpsyntax keyword="cfunction" tokenval="1097"></phpsyntax>
+       <phpsyntax keyword="old_function" tokenval="1098"></phpsyntax>
+       <phpsyntax keyword="exception" tokenval="1099"></phpsyntax>
+       <phpsyntax keyword="die" tokenval="1100"></phpsyntax>
 =========================================================        
 *Below this are the various PHP-specific variable types *
 =========================================================