A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / preferences / TemplateEditorSourceViewerConfiguration.java
index 7b94aa7..f16ecab 100644 (file)
@@ -37,8 +37,8 @@ import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.RGB;
 import org.eclipse.ui.texteditor.ITextEditor;
 
-
-public class TemplateEditorSourceViewerConfiguration extends PHPSourceViewerConfiguration {
+public class TemplateEditorSourceViewerConfiguration extends
+               PHPSourceViewerConfiguration {
 
        private static class TemplateVariableTextHover implements ITextHover {
 
@@ -48,23 +48,28 @@ public class TemplateEditorSourceViewerConfiguration extends PHPSourceViewerConf
                 * @param type
                 */
                public TemplateVariableTextHover(TemplateVariableProcessor processor) {
-                       fProcessor= processor;
+                       fProcessor = processor;
                }
 
-               /* (non-Javadoc)
-                * @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
+               /*
+                * (non-Javadoc)
+                * 
+                * @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer,
+                *      org.eclipse.jface.text.IRegion)
                 */
                public String getHoverInfo(ITextViewer textViewer, IRegion subject) {
                        try {
-                               IDocument doc= textViewer.getDocument();
-                               int offset= subject.getOffset();
-                               if (offset >= 2 && "${".equals(doc.get(offset-2, 2))) { //$NON-NLS-1$
-                                       String varName= doc.get(offset, subject.getLength());
-                                       TemplateContextType contextType= fProcessor.getContextType();
+                               IDocument doc = textViewer.getDocument();
+                               int offset = subject.getOffset();
+                               if (offset >= 2 && "${".equals(doc.get(offset - 2, 2))) { //$NON-NLS-1$
+                                       String varName = doc.get(offset, subject.getLength());
+                                       TemplateContextType contextType = fProcessor
+                                                       .getContextType();
                                        if (contextType != null) {
-                                               Iterator iter= contextType.resolvers();
+                                               Iterator iter = contextType.resolvers();
                                                while (iter.hasNext()) {
-                                                       TemplateVariableResolver var= (TemplateVariableResolver) iter.next();
+                                                       TemplateVariableResolver var = (TemplateVariableResolver) iter
+                                                                       .next();
                                                        if (varName.equals(var.getType())) {
                                                                return var.getDescription();
                                                        }
@@ -76,12 +81,16 @@ public class TemplateEditorSourceViewerConfiguration extends PHPSourceViewerConf
                        return null;
                }
 
-               /* (non-Javadoc)
-                * @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer, int)
+               /*
+                * (non-Javadoc)
+                * 
+                * @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer,
+                *      int)
                 */
                public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
                        if (textViewer != null) {
-                               return JavaWordFinder.findWord(textViewer.getDocument(), offset);
+                               return JavaWordFinder
+                                               .findWord(textViewer.getDocument(), offset);
                        }
                        return null;
                }
@@ -90,9 +99,11 @@ public class TemplateEditorSourceViewerConfiguration extends PHPSourceViewerConf
 
        private final TemplateVariableProcessor fProcessor;
 
-       public TemplateEditorSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore store, ITextEditor editor, TemplateVariableProcessor processor) {
+       public TemplateEditorSourceViewerConfiguration(IColorManager colorManager,
+                       IPreferenceStore store, ITextEditor editor,
+                       TemplateVariableProcessor processor) {
                super(colorManager, store, editor, IPHPPartitions.PHP_PARTITIONING);
-               fProcessor= processor;
+               fProcessor = processor;
        }
 
        /*
@@ -100,34 +111,51 @@ public class TemplateEditorSourceViewerConfiguration extends PHPSourceViewerConf
         */
        public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
 
-               IPreferenceStore store= PHPeclipsePlugin.getDefault().getPreferenceStore();
-               JavaTextTools textTools= PHPeclipsePlugin.getDefault().getJavaTextTools();
-               IColorManager manager= textTools.getColorManager();
-
-
-               ContentAssistant assistant= new ContentAssistant();
-               assistant.setContentAssistProcessor(fProcessor, IDocument.DEFAULT_CONTENT_TYPE);
-                       // Register the same processor for strings and single line comments to get code completion at the start of those partitions.
-               assistant.setContentAssistProcessor(fProcessor, IPHPPartitions.PHP_STRING_DQ);
-               assistant.setContentAssistProcessor(fProcessor, IPHPPartitions.PHP_STRING_SQ);
-               assistant.setContentAssistProcessor(fProcessor, IPHPPartitions.PHP_STRING_HEREDOC);
-               assistant.setContentAssistProcessor(fProcessor, IPHPPartitions.PHP_SINGLELINE_COMMENT);
-               assistant.setContentAssistProcessor(fProcessor, IPHPPartitions.PHP_MULTILINE_COMMENT);
-               assistant.setContentAssistProcessor(fProcessor, IPHPPartitions.PHP_PHPDOC_COMMENT);
-
-               assistant.enableAutoInsert(store.getBoolean(PreferenceConstants.CODEASSIST_AUTOINSERT));
-               assistant.enableAutoActivation(store.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION));
-               assistant.setAutoActivationDelay(store.getInt(PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
-               assistant.setProposalPopupOrientation(ContentAssistant.PROPOSAL_OVERLAY);
-               assistant.setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_ABOVE);
-               assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
-
-               Color background= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, manager);
+               IPreferenceStore store = PHPeclipsePlugin.getDefault()
+                               .getPreferenceStore();
+               JavaTextTools textTools = PHPeclipsePlugin.getDefault()
+                               .getJavaTextTools();
+               IColorManager manager = textTools.getColorManager();
+
+               ContentAssistant assistant = new ContentAssistant();
+               assistant.setContentAssistProcessor(fProcessor,
+                               IDocument.DEFAULT_CONTENT_TYPE);
+               // Register the same processor for strings and single line comments to
+               // get code completion at the start of those partitions.
+               assistant.setContentAssistProcessor(fProcessor,
+                               IPHPPartitions.PHP_STRING_DQ);
+               assistant.setContentAssistProcessor(fProcessor,
+                               IPHPPartitions.PHP_STRING_SQ);
+               assistant.setContentAssistProcessor(fProcessor,
+                               IPHPPartitions.PHP_STRING_HEREDOC);
+               assistant.setContentAssistProcessor(fProcessor,
+                               IPHPPartitions.PHP_SINGLELINE_COMMENT);
+               assistant.setContentAssistProcessor(fProcessor,
+                               IPHPPartitions.PHP_MULTILINE_COMMENT);
+               assistant.setContentAssistProcessor(fProcessor,
+                               IPHPPartitions.PHP_PHPDOC_COMMENT);
+
+               assistant.enableAutoInsert(store
+                               .getBoolean(PreferenceConstants.CODEASSIST_AUTOINSERT));
+               assistant.enableAutoActivation(store
+                               .getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION));
+               assistant.setAutoActivationDelay(store
+                               .getInt(PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
+               assistant
+                               .setProposalPopupOrientation(ContentAssistant.PROPOSAL_OVERLAY);
+               assistant
+                               .setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_ABOVE);
+               assistant
+                               .setInformationControlCreator(getInformationControlCreator(sourceViewer));
+
+               Color background = getColor(store,
+                               PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, manager);
                assistant.setContextInformationPopupBackground(background);
                assistant.setContextSelectorBackground(background);
                assistant.setProposalSelectorBackground(background);
 
-               Color foreground= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, manager);
+               Color foreground = getColor(store,
+                               PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, manager);
                assistant.setContextInformationPopupForeground(foreground);
                assistant.setContextSelectorForeground(foreground);
                assistant.setProposalSelectorForeground(foreground);
@@ -135,8 +163,9 @@ public class TemplateEditorSourceViewerConfiguration extends PHPSourceViewerConf
                return assistant;
        }
 
-       private Color getColor(IPreferenceStore store, String key, IColorManager manager) {
-               RGB rgb= PreferenceConverter.getColor(store, key);
+       private Color getColor(IPreferenceStore store, String key,
+                       IColorManager manager) {
+               RGB rgb = PreferenceConverter.getColor(store, key);
                return manager.getColor(rgb);
        }
 
@@ -144,7 +173,8 @@ public class TemplateEditorSourceViewerConfiguration extends PHPSourceViewerConf
         * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String, int)
         * @since 2.1
         */
-       public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
+       public ITextHover getTextHover(ISourceViewer sourceViewer,
+                       String contentType, int stateMask) {
                return new TemplateVariableTextHover(fProcessor);
        }