Expressions like:
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / text / template / contentassist / TemplateEngine.java
index 2303b47..13b4a92 100644 (file)
@@ -1,10 +1,10 @@
 /*******************************************************************************
  * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials 
+ * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Common Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/cpl-v10.html
- * 
+ *
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *******************************************************************************/
@@ -71,7 +71,7 @@ public class TemplateEngine {
         */
        public void complete(ITextViewer viewer, int completionPosition, ICompilationUnit compilationUnit) {
            IDocument document= viewer.getDocument();
-           
+
                if (!(fContextType instanceof CompilationUnitContextType))
                        return;
 
@@ -85,14 +85,14 @@ public class TemplateEngine {
                        } catch (BadLocationException e) {}
                }
 
-               
+
                CompilationUnitContext context= ((CompilationUnitContextType) fContextType).createContext(document, completionPosition, selection.y, compilationUnit);
                context.setVariable("selection", selectedText); //$NON-NLS-1$
                int start= context.getStart();
                int end= context.getEnd();
                IRegion region= new Region(start, end - start);
 
-               Template[] templates= PHPeclipsePlugin.getDefault().getTemplateStore().getTemplates(); 
+               Template[] templates= PHPeclipsePlugin.getDefault().getTemplateStore().getTemplates();
 
                if (selection.y == 0) {
                        for (int i= 0; i != templates.length; i++)
@@ -105,11 +105,11 @@ public class TemplateEngine {
                                context.setForceEvaluation(true);
 
                        boolean multipleLinesSelected= areMultipleLinesSelected(viewer);
-                               
+
                        for (int i= 0; i != templates.length; i++) {
-                               Template template= templates[i];                                
+                               Template template= templates[i];
                                if (context.canEvaluate(template) &&
-                                       template.getContextTypeId().equals(context.getContextType().getId()) &&                         
+                                       template.getContextTypeId().equals(context.getContextType().getId()) &&
                                        (!multipleLinesSelected && template.getPattern().indexOf($_WORD_SELECTION) != -1 || (multipleLinesSelected && template.getPattern().indexOf($_LINE_SELECTION) != -1)))
                                {
                                        fProposals.add(new TemplateProposal(templates[i], context, region, PHPUiImages.get(PHPUiImages.IMG_OBJS_TEMPLATE)));
@@ -117,31 +117,31 @@ public class TemplateEngine {
                        }
                }
        }
-       
+
        /**
         * Returns <code>true</code> if one line is completely selected or if multiple lines are selected.
-        * Being completely selected means that all characters except the new line characters are 
+        * Being completely selected means that all characters except the new line characters are
         * selected.
-        * 
+        *
         * @return <code>true</code> if one or multiple lines are selected
         * @since 2.1
         */
        private boolean areMultipleLinesSelected(ITextViewer viewer) {
                if (viewer == null)
                        return false;
-               
+
                Point s= viewer.getSelectedRange();
                if (s.y == 0)
                        return false;
-                       
+
                try {
-                       
+
                        IDocument document= viewer.getDocument();
                        int startLine= document.getLineOfOffset(s.x);
                        int endLine= document.getLineOfOffset(s.x + s.y);
                        IRegion line= document.getLineInformation(startLine);
                        return startLine != endLine || (s.x == line.getOffset() && s.y == line.getLength());
-               
+
                } catch (BadLocationException x) {
                        return false;
                }