added textArea as a temporary report area. will be replaced by a tree at some point...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PHPSourceViewerConfiguration.java
index c870909..0353b6d 100644 (file)
  **********************************************************************/
 package net.sourceforge.phpeclipse.phpeditor;
 import java.util.Vector;
+
+import net.sourceforge.phpdt.core.JavaCore;
 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.JavaElementProvider;
 import net.sourceforge.phpdt.internal.ui.text.JavaOutlineInformationControl;
 import net.sourceforge.phpdt.internal.ui.text.JavaReconciler;
 import net.sourceforge.phpdt.internal.ui.text.java.JavaFormattingStrategy;
 import net.sourceforge.phpdt.internal.ui.text.java.JavaReconcilingStrategy;
+import net.sourceforge.phpdt.internal.ui.text.java.JavaStringAutoIndentStrategy;
 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.phpdoc.PHPDocCompletionProcessor;
 import net.sourceforge.phpdt.ui.PreferenceConstants;
 import net.sourceforge.phpdt.ui.text.JavaTextTools;
-import net.sourceforge.phpeclipse.PHPCore;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.phpeditor.html.HTMLFormattingStrategy;
 import net.sourceforge.phpeclipse.phpeditor.php.HTMLCompletionProcessor;
-import net.sourceforge.phpeclipse.phpeditor.php.IPHPPartitionScannerConstants;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPAutoIndentStrategy;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPCompletionProcessor;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPDoubleClickSelector;
 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
-import org.eclipse.core.resources.IFile;
+
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.text.DefaultAutoIndentStrategy;
@@ -68,8 +70,6 @@ import org.eclipse.jface.text.source.ISourceViewer;
 import org.eclipse.jface.text.source.SourceViewerConfiguration;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
 /**
  * Configuration for an <code>SourceViewer</code> which shows PHP code.
  */
@@ -202,7 +202,10 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
         */
        public IAutoIndentStrategy getAutoIndentStrategy(
                        ISourceViewer sourceViewer, String contentType) {
-               return (IPHPPartitionScannerConstants.PHP.equals(contentType)
+               if (IPHPPartitions.PHP_STRING_DQ.equals(contentType))
+                       return new JavaStringAutoIndentStrategy(getConfiguredDocumentPartitioning(sourceViewer));
+
+               return (IPHPPartitions.PHP_PARTITIONING.equals(contentType)
                                ? new PHPAutoIndentStrategy()
                                : new DefaultAutoIndentStrategy());
        }
@@ -289,19 +292,20 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
                                return new JavaEditorTextHoverProxy(hoverDescs[i], getEditor());
                        i++;
                }
-               if (fEditor != null) {
-                       IEditorInput editorInput = fEditor.getEditorInput();
-                       if (editorInput instanceof IFileEditorInput) {
-                               try {
-                                       IFile f = ((IFileEditorInput) editorInput).getFile();
-                                       return new PHPTextHover(f.getProject());
-                               } catch (NullPointerException e) {
-                                       // this exception occurs, if getTextHover is called by
-                                       // preference pages !
-                               }
-                       }
-               }
-               return new PHPTextHover(null);
+               return null;
+//             if (fEditor != null) {
+//                     IEditorInput editorInput = fEditor.getEditorInput();
+//                     if (editorInput instanceof IFileEditorInput) {
+//                             try {
+//                                     IFile f = ((IFileEditorInput) editorInput).getFile();
+//                                     return new PHPTextHover(f.getProject());
+//                             } catch (NullPointerException e) {
+//                                     // this exception occurs, if getTextHover is called by
+//                                     // preference pages !
+//                             }
+//                     }
+//             }
+//             return new PHPTextHover(null);
        }
        /*
         * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String)
@@ -331,16 +335,16 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
         * (non-Javadoc) Method declared on SourceViewerConfiguration
         */
        public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
-               return new String[]{IPHPPartitionScannerConstants.HTML,
-                               IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT,
-                               IPHPPartitionScannerConstants.PHP,
-                               IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT,
-                               IPHPPartitionScannerConstants.CSS,
-                               IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT,
-                               IPHPPartitionScannerConstants.JAVASCRIPT,
-                               IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT,
-                               IPHPPartitionScannerConstants.SMARTY,
-                               IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT,
+               return new String[]{IPHPPartitions.HTML,
+                               IPHPPartitions.HTML_MULTILINE_COMMENT,
+                               IPHPPartitions.PHP_PARTITIONING,
+                               IPHPPartitions.PHP_PHPDOC_COMMENT,
+                               IPHPPartitions.CSS,
+                               IPHPPartitions.CSS_MULTILINE_COMMENT,
+                               IPHPPartitions.JAVASCRIPT,
+                               IPHPPartitions.JS_MULTILINE_COMMENT,
+                               IPHPPartitions.SMARTY,
+                               IPHPPartitions.SMARTY_MULTILINE_COMMENT,
                                IDocument.DEFAULT_CONTENT_TYPE};
        }
        /*
@@ -350,28 +354,28 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
                ContentAssistant assistant = new ContentAssistant();
                IContentAssistProcessor processor = new HTMLCompletionProcessor();
                assistant.setContentAssistProcessor(processor,
-                               IPHPPartitionScannerConstants.HTML);
+                               IPHPPartitions.HTML);
                assistant.setContentAssistProcessor(processor,
-                               IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
+                               IPHPPartitions.HTML_MULTILINE_COMMENT);
                assistant.setContentAssistProcessor(processor,
                                IDocument.DEFAULT_CONTENT_TYPE);
                assistant.setContentAssistProcessor(processor,
-                               IPHPPartitionScannerConstants.CSS);
+                               IPHPPartitions.CSS);
                assistant.setContentAssistProcessor(processor,
-                               IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT);
+                               IPHPPartitions.CSS_MULTILINE_COMMENT);
                assistant.setContentAssistProcessor(processor,
-                               IPHPPartitionScannerConstants.JAVASCRIPT);
+                               IPHPPartitions.JAVASCRIPT);
                assistant.setContentAssistProcessor(processor,
-                               IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT);
+                               IPHPPartitions.JS_MULTILINE_COMMENT);
                // TODO define special smarty partition content assist
                assistant.setContentAssistProcessor(processor,
-                               IPHPPartitionScannerConstants.SMARTY);
+                               IPHPPartitions.SMARTY);
                assistant.setContentAssistProcessor(processor,
-                               IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
+                               IPHPPartitions.SMARTY_MULTILINE_COMMENT);
                assistant.setContentAssistProcessor(new PHPCompletionProcessor(),
-                               IPHPPartitionScannerConstants.PHP);
+                               IPHPPartitions.PHP_PARTITIONING);
                assistant.setContentAssistProcessor(new PHPDocCompletionProcessor(),
-                               IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
+                               IPHPPartitions.PHP_PHPDOC_COMMENT);
                //    assistant.enableAutoActivation(true);
                //    assistant.setAutoActivationDelay(500);
                //    assistant.setProposalPopupOrientation(ContentAssistant.PROPOSAL_OVERLAY);
@@ -422,7 +426,7 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
                // prefix[0] is either '\t' or ' ' x tabWidth, depending on useSpaces
                final IPreferenceStore preferences = PHPeclipsePlugin.getDefault()
                                .getPreferenceStore();
-               int tabWidth = preferences.getInt(PHPCore.FORMATTER_TAB_SIZE);
+               int tabWidth = preferences.getInt(JavaCore.FORMATTER_TAB_SIZE);
                boolean useSpaces = getPreferenceStore().getBoolean(SPACES_FOR_TABS);
                for (int i = 0; i <= tabWidth; i++) {
                        StringBuffer prefix = new StringBuffer();
@@ -456,47 +460,47 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
                reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
                reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
                dr = new DefaultDamagerRepairer(getHTMLScanner());
-               reconciler.setDamager(dr, IPHPPartitionScannerConstants.HTML);
-               reconciler.setRepairer(dr, IPHPPartitionScannerConstants.HTML);
+               reconciler.setDamager(dr, IPHPPartitions.HTML);
+               reconciler.setRepairer(dr, IPHPPartitions.HTML);
                dr = new DefaultDamagerRepairer(getHTMLScanner());
-               reconciler.setDamager(dr, IPHPPartitionScannerConstants.CSS);
-               reconciler.setRepairer(dr, IPHPPartitionScannerConstants.CSS);
+               reconciler.setDamager(dr, IPHPPartitions.CSS);
+               reconciler.setRepairer(dr, IPHPPartitions.CSS);
                dr = new DefaultDamagerRepairer(getHTMLScanner());
                reconciler.setDamager(dr,
-                               IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT);
+                               IPHPPartitions.CSS_MULTILINE_COMMENT);
                reconciler.setRepairer(dr,
-                               IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT);
+                               IPHPPartitions.CSS_MULTILINE_COMMENT);
                dr = new DefaultDamagerRepairer(getHTMLScanner());
-               reconciler.setDamager(dr, IPHPPartitionScannerConstants.JAVASCRIPT);
-               reconciler.setRepairer(dr, IPHPPartitionScannerConstants.JAVASCRIPT);
+               reconciler.setDamager(dr, IPHPPartitions.JAVASCRIPT);
+               reconciler.setRepairer(dr, IPHPPartitions.JAVASCRIPT);
                dr = new DefaultDamagerRepairer(getHTMLScanner());
                reconciler.setDamager(dr,
-                               IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT);
+                               IPHPPartitions.JS_MULTILINE_COMMENT);
                reconciler.setRepairer(dr,
-                               IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT);
+                               IPHPPartitions.JS_MULTILINE_COMMENT);
                dr = new DefaultDamagerRepairer(getSmartyScanner());
-               reconciler.setDamager(dr, IPHPPartitionScannerConstants.SMARTY);
-               reconciler.setRepairer(dr, IPHPPartitionScannerConstants.SMARTY);
+               reconciler.setDamager(dr, IPHPPartitions.SMARTY);
+               reconciler.setRepairer(dr, IPHPPartitions.SMARTY);
                dr = new DefaultDamagerRepairer(getSmartyDocScanner());
                reconciler.setDamager(dr,
-                               IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
+                               IPHPPartitions.SMARTY_MULTILINE_COMMENT);
                reconciler.setRepairer(dr,
-                               IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
+                               IPHPPartitions.SMARTY_MULTILINE_COMMENT);
                dr = new DefaultDamagerRepairer(new SingleTokenScanner(
                                new TextAttribute(fJavaTextTools.getColorManager().getColor(
                                                PHPColorProvider.MULTI_LINE_COMMENT))));
                reconciler.setDamager(dr,
-                               IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
+                               IPHPPartitions.HTML_MULTILINE_COMMENT);
                reconciler.setRepairer(dr,
-                               IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
+                               IPHPPartitions.HTML_MULTILINE_COMMENT);
                dr = new DefaultDamagerRepairer(getCodeScanner());
-               reconciler.setDamager(dr, IPHPPartitionScannerConstants.PHP);
-               reconciler.setRepairer(dr, IPHPPartitionScannerConstants.PHP);
+               reconciler.setDamager(dr, IPHPPartitions.PHP_PARTITIONING);
+               reconciler.setRepairer(dr, IPHPPartitions.PHP_PARTITIONING);
                dr = new DefaultDamagerRepairer(getPHPDocScanner());
                reconciler.setDamager(dr,
-                               IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
+                               IPHPPartitions.PHP_PHPDOC_COMMENT);
                reconciler.setRepairer(dr,
-                               IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
+                               IPHPPartitions.PHP_PHPDOC_COMMENT);
                return reconciler;
        }
        /*
@@ -620,15 +624,15 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
                presenter.setInformationProvider(provider,
                                IDocument.DEFAULT_CONTENT_TYPE);
                presenter.setInformationProvider(provider,
-                               IPHPPartitionScannerConstants.PHP);
+                               IPHPPartitions.PHP_PARTITIONING);
                presenter.setInformationProvider(provider,
-                               IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
+                               IPHPPartitions.PHP_PHPDOC_COMMENT);
                presenter.setInformationProvider(provider,
-                               IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
+                               IPHPPartitions.SMARTY_MULTILINE_COMMENT);
                presenter.setInformationProvider(provider,
-                               IPHPPartitionScannerConstants.HTML);
+                               IPHPPartitions.HTML);
                presenter.setInformationProvider(provider,
-                               IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
+                               IPHPPartitions.HTML_MULTILINE_COMMENT);
                presenter.setSizeConstraints(40, 20, true, false);
                return presenter;
        }