added StringAutoIndentStrategy for single quoted strings
authorjsurfer <jsurfer>
Sun, 12 Sep 2004 06:52:56 +0000 (06:52 +0000)
committerjsurfer <jsurfer>
Sun, 12 Sep 2004 06:52:56 +0000 (06:52 +0000)
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/ColorSettingPreviewCode.txt
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/JavaEditorPreferencePage.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/PreferencesMessages.properties
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/JavaStringAutoIndentStrategyDQ.java [copied from net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/JavaStringAutoIndentStrategy.java with 96% similarity]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/JavaStringAutoIndentStrategySQ.java [moved from net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/JavaStringAutoIndentStrategy.java with 91% similarity]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/PreferenceConstants.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/text/PHPSourceViewerConfiguration.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java

index d7615dd..c89390a 100644 (file)
@@ -1,13 +1,19 @@
-<?php
+<?php 
 /**
  * This is about <code>ClassName</code>.
- * {@link com.yourCompany.aPackage.SuperClass}
+ * 
  * @author author
  */
 class ClassName extends SuperClass {
        /* This comment may span multiple lines. */
-       $integer= 0;
+       private $integer = 0;
        // This comment may span only this line
-       $string= "zero";
+       private $string = "zero";
+
+       public function info() {
+               # call a predefined php function
+               phpinfo();
+               return "test";
+       }
 }
 ?>
\ No newline at end of file
index 89a22b3..69d820c 100644 (file)
@@ -238,7 +238,9 @@ public class JavaEditorPreferencePage extends PreferencePage implements IWorkben
 
   //  private Button fAddJavaDocTagsButton;
 
-  private Button fEscapeStringsButton;
+  private Button fEscapeStringsButtonDQ;
+  
+  private Button fEscapeStringsButtonSQ;
 
   //   private Button fGuessMethodArgumentsButton;
   private SourceViewer fPreviewViewer;
@@ -455,9 +457,13 @@ public class JavaEditorPreferencePage extends PreferencePage implements IWorkben
     //    overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
     //        OverlayPreferenceStore.BOOLEAN,
     //        PreferenceConstants.EDITOR_CLOSE_JAVADOCS));
-    overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS));
+    overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
     overlayKeys
-        .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ESCAPE_STRINGS));
+        .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ));
+    overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
+    overlayKeys
+        .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ));
+    
     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
         PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS));
     overlayKeys
@@ -1053,15 +1059,21 @@ public class JavaEditorPreferencePage extends PreferencePage implements IWorkben
     group.setLayout(layout);
     group.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.description")); //$NON-NLS-1$
 
-    label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapStrings");
-    //$NON-NLS-1$
-    Button button = addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS, 1);
+    label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapStringsDQ");//$NON-NLS-1$
+    Button button = addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS_DQ, 1);
 
-    label = PreferencesMessages.getString("JavaEditorPreferencePage.escapeStrings");
-    //$NON-NLS-1$
-    fEscapeStringsButton = addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS, 1);
-    createDependency(button, fEscapeStringsButton);
+    label = PreferencesMessages.getString("JavaEditorPreferencePage.escapeStringsDQ");//$NON-NLS-1$
+    fEscapeStringsButtonDQ = addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ, 1);
+    createDependency(button, fEscapeStringsButtonDQ);
 
+    label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapStringsSQ");//$NON-NLS-1$
+    addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS_SQ, 1);
+
+    label = PreferencesMessages.getString("JavaEditorPreferencePage.escapeStringsSQ");
+    //$NON-NLS-1$
+    fEscapeStringsButtonSQ = addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ, 1);
+    createDependency(button, fEscapeStringsButtonSQ);
+    
     label = PreferencesMessages.getString("JavaEditorPreferencePage.smartPaste");
     //$NON-NLS-1$
     addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
@@ -1426,7 +1438,8 @@ public class JavaEditorPreferencePage extends PreferencePage implements IWorkben
     //    boolean closeJavaDocs = fOverlayStore
     //        .getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
     //    fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
-    fEscapeStringsButton.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS));
+    fEscapeStringsButtonDQ.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
+    fEscapeStringsButtonSQ.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
     //         boolean fillMethodArguments=
     // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
     //         fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
index 4997e09..ccb6825 100644 (file)
@@ -178,8 +178,10 @@ JavaEditorPreferencePage.closeStringsSQ= Close &single quoted strings
 JavaEditorPreferencePage.closeBrackets= Close &brackets and parenthesis
 JavaEditorPreferencePage.closeBraces= Cl&ose braces
 JavaEditorPreferencePage.closeJavaDocs= Close PHP&docs and comments
-JavaEditorPreferencePage.wrapStrings= Wra&p PHP strings
-JavaEditorPreferencePage.escapeStrings= &Escape text when pasting into a string literal
+JavaEditorPreferencePage.wrapStringsDQ= Wra&p double quoted PHP strings
+JavaEditorPreferencePage.escapeStringsDQ= &Escape text when pasting into a double quoted PHP string
+JavaEditorPreferencePage.wrapStringsSQ= Wra&p single quoted PHP strings
+JavaEditorPreferencePage.escapeStringsSQ= &Escape text when pasting into a single quoted PHP string
 JavaEditorPreferencePage.addJavaDocTags= Add PHPdoc &tags
 JavaEditorPreferencePage.smartPaste= Pasting fo&r correct indentation
 
@@ -29,7 +29,7 @@ import org.eclipse.ui.texteditor.ITextEditorExtension3;
 /**
  * Auto indent strategy for java strings
  */
-public class JavaStringAutoIndentStrategy extends DefaultAutoIndentStrategy {
+public class JavaStringAutoIndentStrategyDQ extends DefaultAutoIndentStrategy {
        
        private String fPartitioning;
        
@@ -116,7 +116,7 @@ public class JavaStringAutoIndentStrategy extends DefaultAutoIndentStrategy {
         * 
         * @param partitioning the document partitioning
         */
-       public JavaStringAutoIndentStrategy(String partitioning) {
+       public JavaStringAutoIndentStrategyDQ(String partitioning) {
                super();
                fPartitioning= partitioning;
        }
@@ -171,7 +171,7 @@ public class JavaStringAutoIndentStrategy extends DefaultAutoIndentStrategy {
                IPreferenceStore preferenceStore= PHPeclipsePlugin.getDefault().getPreferenceStore();
                if (isLineDelimiter(document, command.text))
                        command.text= "\" ." + command.text + indentation + "\"";  //$NON-NLS-1$//$NON-NLS-2$
-               else if (command.text.length() > 1 && preferenceStore.getBoolean(PreferenceConstants.EDITOR_ESCAPE_STRINGS))
+               else if (command.text.length() > 1 && preferenceStore.getBoolean(PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ))
                        command.text= getModifiedText(command.text, indentation, delimiter);            
        }
        
@@ -197,7 +197,7 @@ public class JavaStringAutoIndentStrategy extends DefaultAutoIndentStrategy {
 
                        IPreferenceStore preferenceStore= PHPeclipsePlugin.getDefault().getPreferenceStore();
                                
-                       if (preferenceStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS) && isSmartMode())
+                       if (preferenceStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_DQ) && isSmartMode())
                                javaStringIndentAfterNewLine(document, command);
                                
                } catch (BadLocationException e) {
@@ -29,7 +29,7 @@ import org.eclipse.ui.texteditor.ITextEditorExtension3;
 /**
  * Auto indent strategy for java strings
  */
-public class JavaStringAutoIndentStrategy extends DefaultAutoIndentStrategy {
+public class JavaStringAutoIndentStrategySQ extends DefaultAutoIndentStrategy {
        
        private String fPartitioning;
        
@@ -53,23 +53,23 @@ public class JavaStringAutoIndentStrategy extends DefaultAutoIndentStrategy {
                                        token = tokenizer.nextToken();
                                        if (token.equals("\n")) { //$NON-NLS-1$
                                                buffer.append("\\n"); //$NON-NLS-1$
-                                               buffer.append("\" . " + delimiter); //$NON-NLS-1$
+                                               buffer.append("\' . " + delimiter); //$NON-NLS-1$
                                                buffer.append(indentation);
-                                               buffer.append("\""); //$NON-NLS-1$
+                                               buffer.append("\'"); //$NON-NLS-1$
                                                continue;
                                        } else {
-                                               buffer.append("\" . " + delimiter); //$NON-NLS-1$
+                                               buffer.append("\' . " + delimiter); //$NON-NLS-1$
                                                buffer.append(indentation);
-                                               buffer.append("\""); //$NON-NLS-1$
+                                               buffer.append("\'"); //$NON-NLS-1$
                                        }
                                } else {
                                        continue;
                                }
                        } else if (token.equals("\n")) { //$NON-NLS-1$
                                buffer.append("\\n"); //$NON-NLS-1$
-                               buffer.append("\" . " + delimiter); //$NON-NLS-1$
+                               buffer.append("\' . " + delimiter); //$NON-NLS-1$
                                buffer.append(indentation);
-                               buffer.append("\""); //$NON-NLS-1$
+                               buffer.append("\'"); //$NON-NLS-1$
                                continue;
                        }       
        
@@ -116,7 +116,7 @@ public class JavaStringAutoIndentStrategy extends DefaultAutoIndentStrategy {
         * 
         * @param partitioning the document partitioning
         */
-       public JavaStringAutoIndentStrategy(String partitioning) {
+       public JavaStringAutoIndentStrategySQ(String partitioning) {
                super();
                fPartitioning= partitioning;
        }
@@ -157,7 +157,7 @@ public class JavaStringAutoIndentStrategy extends DefaultAutoIndentStrategy {
                        return;
                }
                
-               if (command.offset == offset + length && document.getChar(offset + length - 1) == '\"')
+               if (command.offset == offset + length && document.getChar(offset + length - 1) == '\'')
                        return;
 
                String indentation= getLineIndentation(document, command.offset);
@@ -170,8 +170,8 @@ public class JavaStringAutoIndentStrategy extends DefaultAutoIndentStrategy {
                
                IPreferenceStore preferenceStore= PHPeclipsePlugin.getDefault().getPreferenceStore();
                if (isLineDelimiter(document, command.text))
-                       command.text= "\" ." + command.text + indentation + "\"";  //$NON-NLS-1$//$NON-NLS-2$
-               else if (command.text.length() > 1 && preferenceStore.getBoolean(PreferenceConstants.EDITOR_ESCAPE_STRINGS))
+                       command.text= "\' ." + command.text + indentation + "\'";  //$NON-NLS-1$//$NON-NLS-2$
+               else if (command.text.length() > 1 && preferenceStore.getBoolean(PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ))
                        command.text= getModifiedText(command.text, indentation, delimiter);            
        }
        
@@ -197,7 +197,7 @@ public class JavaStringAutoIndentStrategy extends DefaultAutoIndentStrategy {
 
                        IPreferenceStore preferenceStore= PHPeclipsePlugin.getDefault().getPreferenceStore();
                                
-                       if (preferenceStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS) && isSmartMode())
+                       if (preferenceStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_SQ) && isSmartMode())
                                javaStringIndentAfterNewLine(document, command);
                                
                } catch (BadLocationException e) {
index a4d6700..ec2fb75 100644 (file)
@@ -769,7 +769,7 @@ public class PreferenceConstants {
         * </p>
         * @since 2.1
         */
-       public final static String EDITOR_WRAP_STRINGS= "wrapStrings"; //$NON-NLS-1$
+       public final static String EDITOR_WRAP_STRINGS_DQ= "wrapStringsDQ"; //$NON-NLS-1$
 
        /**
         * A named preference that controls whether the 'escape strings' feature is
@@ -779,7 +779,27 @@ public class PreferenceConstants {
         * </p>
         * @since 3.0
         */
-       public final static String EDITOR_ESCAPE_STRINGS= "escapeStrings"; //$NON-NLS-1$
+       public final static String EDITOR_ESCAPE_STRINGS_DQ= "escapeStringsDQ"; //$NON-NLS-1$
+       /**
+        * A named preference that controls whether the 'wrap strings' feature is
+        * enabled.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        * @since 2.1
+        */
+       public final static String EDITOR_WRAP_STRINGS_SQ= "wrapStringsDQ"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether the 'escape strings' feature is
+        * enabled.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        * @since 3.0
+        */
+       public final static String EDITOR_ESCAPE_STRINGS_SQ= "escapeStringsSQ"; //$NON-NLS-1$
+       
        /**
         * A named preference that controls if content assist inserts the common
         * prefix of all proposals before presenting choices.
@@ -2395,8 +2415,10 @@ public final static String EDITOR_TEXT_FONT= "net.sourceforge.phpdt.ui.editors.t
     store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP, true);
     store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACES, true);
     store.setDefault(PreferenceConstants.EDITOR_CLOSE_JAVADOCS, true);
-    store.setDefault(PreferenceConstants.EDITOR_WRAP_STRINGS, true);
-    store.setDefault(PreferenceConstants.EDITOR_ESCAPE_STRINGS, false);
+    store.setDefault(PreferenceConstants.EDITOR_WRAP_STRINGS_DQ, true);
+    store.setDefault(PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ, false);
+    store.setDefault(PreferenceConstants.EDITOR_WRAP_STRINGS_SQ, true);
+    store.setDefault(PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ, false);
     store.setDefault(PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, true);
     store.setDefault(PreferenceConstants.EDITOR_FORMAT_JAVADOCS, true);
        store.setDefault(PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, false);
index 735dcec..d1e9583 100644 (file)
@@ -19,7 +19,6 @@ import net.sourceforge.phpdt.internal.ui.text.ContentAssistPreference;
 import net.sourceforge.phpdt.internal.ui.text.HTMLTextPresenter;
 import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
 import net.sourceforge.phpdt.internal.ui.text.JavaAnnotationHover;
-import net.sourceforge.phpdt.internal.ui.text.JavaColorManager;
 import net.sourceforge.phpdt.internal.ui.text.JavaCompositeReconcilingStrategy;
 import net.sourceforge.phpdt.internal.ui.text.JavaElementProvider;
 import net.sourceforge.phpdt.internal.ui.text.JavaOutlineInformationControl;
@@ -27,7 +26,8 @@ import net.sourceforge.phpdt.internal.ui.text.JavaPresentationReconciler;
 import net.sourceforge.phpdt.internal.ui.text.JavaReconciler;
 import net.sourceforge.phpdt.internal.ui.text.PreferencesAdapter;
 import net.sourceforge.phpdt.internal.ui.text.java.JavaFormattingStrategy;
-import net.sourceforge.phpdt.internal.ui.text.java.JavaStringAutoIndentStrategy;
+import net.sourceforge.phpdt.internal.ui.text.java.JavaStringAutoIndentStrategyDQ;
+import net.sourceforge.phpdt.internal.ui.text.java.JavaStringAutoIndentStrategySQ;
 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor;
 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy;
 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaInformationProvider;
@@ -36,7 +36,6 @@ import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCompletionProcessor;
 import net.sourceforge.phpdt.ui.PreferenceConstants;
 import net.sourceforge.phpeclipse.IPreferenceConstants;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-import net.sourceforge.phpeclipse.phpeditor.PHPEditor;
 import net.sourceforge.phpeclipse.phpeditor.html.HTMLFormattingStrategy;
 import net.sourceforge.phpeclipse.phpeditor.php.HTMLCompletionProcessor;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPAutoIndentStrategy;
@@ -45,9 +44,6 @@ import net.sourceforge.phpeclipse.phpeditor.php.PHPCompletionProcessor;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPDocumentPartitioner;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPDoubleClickSelector;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPPartitionScanner;
-import net.sourceforge.phpeclipse.phpeditor.php.SmartyCodeScanner;
-import net.sourceforge.phpeclipse.phpeditor.php.SmartyDocCodeScanner;
-import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
 import net.sourceforge.phpeclipse.xml.ui.XMLPlugin;
 import net.sourceforge.phpeclipse.xml.ui.internal.text.XMLConfiguration;
 import net.sourceforge.phpeclipse.xml.ui.internal.text.XMLPartitionScanner;
@@ -413,8 +409,10 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
    * (non-Javadoc) Method declared on SourceViewerConfiguration
    */
   public IAutoIndentStrategy getAutoIndentStrategy(ISourceViewer sourceViewer, String contentType) {
-    if (IPHPPartitions.PHP_STRING_DQ.equals(contentType) || IPHPPartitions.PHP_STRING_SQ.equals(contentType))
-      return new JavaStringAutoIndentStrategy(getConfiguredDocumentPartitioning(sourceViewer));
+    if (IPHPPartitions.PHP_STRING_DQ.equals(contentType))
+      return new JavaStringAutoIndentStrategyDQ(getConfiguredDocumentPartitioning(sourceViewer));
+    if (IPHPPartitions.PHP_STRING_SQ.equals(contentType))
+      return new JavaStringAutoIndentStrategySQ(getConfiguredDocumentPartitioning(sourceViewer));
 
     return (PHPDocumentPartitioner.PHP_TEMPLATE_DATA.equals(contentType)
         || PHPDocumentPartitioner.PHP_SCRIPT_CODE.equals(contentType) || IDocument.DEFAULT_CONTENT_TYPE.equals(contentType)
index 5aa3cca..ae9f4ca 100644 (file)
@@ -1305,7 +1305,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
   private final static String CLOSE_STRINGS_SQ_PHP = PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP;
 
   /** Preference key for automatically wrapping Java strings */
-  private final static String WRAP_STRINGS = PreferenceConstants.EDITOR_WRAP_STRINGS;
+//  private final static String WRAP_STRINGS = PreferenceConstants.EDITOR_WRAP_STRINGS_DQ;
 
   /** Preference key for automatically closing brackets and parenthesis */
   private final static String CLOSE_BRACKETS_PHP = PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP;