Expressions like:
authoraxelcl <axelcl>
Sun, 9 Oct 2005 10:18:39 +0000 (10:18 +0000)
committeraxelcl <axelcl>
Sun, 9 Oct 2005 10:18:39 +0000 (10:18 +0000)
  self::$instance = new Singleton();
shouldnt give an error

net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/compiler/ITerminalSymbols.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/TemplateEngine.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/TemplateProposal.java

index 7b3cbcd..df10d9f 100644 (file)
@@ -12,7 +12,7 @@ package net.sourceforge.phpdt.core.compiler;
 /**
  * Maps each terminal symbol in the php-grammar into a unique integer. This
  * integer is used to represent the terminal when computing a parsing action.
- * 
+ *
  * @see IScanner
  * @since 2.0
  */
@@ -99,18 +99,18 @@ public interface ITerminalSymbols {
   final static int TokenNamearrayCAST = 178;
   final static int TokenNameobjectCAST = 179;
   final static int TokenNameunsetCAST = 180;
-  
+
   // �
   final static int TokenNameEncapsedString0 = 190;
   // '
 //  final static int TokenNameEncapsedString1 = 191;
   // "
 //  final static int TokenNameEncapsedString2 = 192;
-  
+
   final static int TokenNameSTRING = 193;
-  
+
   final static int TokenNameLBRACE_DOLLAR = 194;
-  
+
   // start SQL token - the SQL tokens are only used in the
   // PHPCompletionprocessor:
   public final static int TokenNameSQLselect = 901;
@@ -196,7 +196,7 @@ public interface ITerminalSymbols {
   public final static int TokenNameCLASS_C = 1072;
   public final static int TokenNameMETHOD_C = 1073;
   public final static int TokenNameFUNC_C = 1074;
-  
+
   // special tokens not normally used in the parser
   public final static int TokenNamethis_PHP_COMPLETION = 2000;
 }
index c34ca1d..1f05db8 100644 (file)
@@ -2502,37 +2502,33 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI
                        // | rw_variable T_INC
                        // | rw_variable T_DEC
                        case TokenNameIdentifier:
-                               char[] ident = scanner.getCurrentTokenSource();
-                               Expression lhsIdentifier = identifier(true, true);
-                               if (lhsIdentifier != null) {
-                                       expression = lhsIdentifier;
-                               }
-                               if (token == TokenNameEQUAL || token == TokenNamePLUS_EQUAL
-                                               || token == TokenNameMINUS_EQUAL || token == TokenNameMULTIPLY_EQUAL || token == TokenNameDIVIDE_EQUAL
-                                               || token == TokenNameDOT_EQUAL || token == TokenNameREMAINDER_EQUAL || token == TokenNameAND_EQUAL
-                                               || token == TokenNameOR_EQUAL || token == TokenNameXOR_EQUAL || token == TokenNameRIGHT_SHIFT_EQUAL
-                                               || token == TokenNameLEFT_SHIFT_EQUAL) {
-                                       String error = "Assignment operator '"+scanner.toStringAction(token)+"' not allowed after identifier '"+new String(ident)+"' (use 'define(...)' to define constants).";
-                                       throwSyntaxError(error);
-                               }
-                               break;
                        case TokenNameVariable:
                        case TokenNameDOLLAR:
+                               Expression lhs = null;
                                boolean rememberedVar = false;
-                               Expression lhs = variable(true, true);
-                               if (lhs != null && lhs instanceof FieldReference && token != TokenNameEQUAL && token != TokenNamePLUS_EQUAL
-                                               && token != TokenNameMINUS_EQUAL && token != TokenNameMULTIPLY_EQUAL && token != TokenNameDIVIDE_EQUAL
-                                               && token != TokenNameDOT_EQUAL && token != TokenNameREMAINDER_EQUAL && token != TokenNameAND_EQUAL
-                                               && token != TokenNameOR_EQUAL && token != TokenNameXOR_EQUAL && token != TokenNameRIGHT_SHIFT_EQUAL
-                                               && token != TokenNameLEFT_SHIFT_EQUAL) {
-                                       FieldReference ref = (FieldReference) lhs;
-                                       if (!containsVariableSet(ref.token)) {
-                                               problemReporter.uninitializedLocalVariable(new String(ref.token), ref.sourceStart(), ref.sourceEnd(), referenceContext,
-                                                               compilationUnit.compilationResult);
-                                               addVariableSet(ref.token);
+                               if (token == TokenNameIdentifier) {
+                                       lhs = identifier(true, true);
+                                       if (lhs != null) {
+                                               expression = lhs;
+                                       }
+                               } else {
+                                       lhs = variable(true, true);
+                                       if (lhs != null) {
+                                               expression = lhs;
+                                       }
+                                       if (lhs != null && lhs instanceof FieldReference && token != TokenNameEQUAL && token != TokenNamePLUS_EQUAL
+                                                       && token != TokenNameMINUS_EQUAL && token != TokenNameMULTIPLY_EQUAL && token != TokenNameDIVIDE_EQUAL
+                                                       && token != TokenNameDOT_EQUAL && token != TokenNameREMAINDER_EQUAL && token != TokenNameAND_EQUAL
+                                                       && token != TokenNameOR_EQUAL && token != TokenNameXOR_EQUAL && token != TokenNameRIGHT_SHIFT_EQUAL
+                                                       && token != TokenNameLEFT_SHIFT_EQUAL) {
+                                               FieldReference ref = (FieldReference) lhs;
+                                               if (!containsVariableSet(ref.token)) {
+                                                       problemReporter.uninitializedLocalVariable(new String(ref.token), ref.sourceStart(), ref.sourceEnd(),
+                                                                       referenceContext, compilationUnit.compilationResult);
+                                                       addVariableSet(ref.token);
+                                               }
                                        }
                                }
-
                                switch (token) {
                                case TokenNameEQUAL:
                                        if (lhs != null && lhs instanceof FieldReference) {
@@ -3349,7 +3345,103 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI
                // base_variable_with_function_calls T_OBJECT_OPERATOR
                // object_property method_or_not variable_properties
                // | base_variable_with_function_calls
-               Expression ref = base_variable_with_function_calls(lefthandside, ignoreVar);
+
+               // Expression ref = function_call(lefthandside, ignoreVar);
+
+               // function_call:
+               // T_STRING '(' function_call_parameter_list ')'
+               // | class_constant '(' function_call_parameter_list ')'
+               // | static_member '(' function_call_parameter_list ')'
+               // | variable_without_objects '(' function_call_parameter_list ')'
+               char[] defineName = null;
+               char[] ident = null;
+               int startPos = 0;
+               int endPos = 0;
+               Expression ref = null;
+               if (Scanner.TRACE) {
+                       System.out.println("TRACE: function_call()");
+               }
+               if (token == TokenNameIdentifier) {
+                       ident = scanner.getCurrentIdentifierSource();
+                       defineName = ident;
+                       startPos = scanner.getCurrentTokenStartPosition();
+                       endPos = scanner.getCurrentTokenEndPosition();
+                       getNextToken();
+
+                       if (token == TokenNameEQUAL || token == TokenNamePLUS_EQUAL || token == TokenNameMINUS_EQUAL
+                                       || token == TokenNameMULTIPLY_EQUAL || token == TokenNameDIVIDE_EQUAL || token == TokenNameDOT_EQUAL
+                                       || token == TokenNameREMAINDER_EQUAL || token == TokenNameAND_EQUAL || token == TokenNameOR_EQUAL
+                                       || token == TokenNameXOR_EQUAL || token == TokenNameRIGHT_SHIFT_EQUAL || token == TokenNameLEFT_SHIFT_EQUAL) {
+                               String error = "Assignment operator '" + scanner.toStringAction(token) + "' not allowed after identifier '"
+                                               + new String(ident) + "' (use 'define(...)' to define constants).";
+                               reportSyntaxError(error);
+                       }
+
+                       switch (token) {
+                       case TokenNamePAAMAYIM_NEKUDOTAYIM:
+                               // static member:
+                               defineName = null;
+                               getNextToken();
+                               if (token == TokenNameIdentifier) {
+                                       // class _constant
+                                       getNextToken();
+                               } else {
+                                       // static member:
+                                       variable_without_objects(true, false);
+                               }
+                               break;
+                       }
+               } else {
+                       ref = variable_without_objects(lefthandside, ignoreVar);
+               }
+               if (token != TokenNameLPAREN) {
+                       if (defineName != null) {
+                               // does this identifier contain only uppercase characters?
+                               if (defineName.length == 3) {
+                                       if (defineName[0] == 'd' && defineName[1] == 'i' && defineName[2] == 'e') {
+                                               defineName = null;
+                                       }
+                               } else if (defineName.length == 4) {
+                                       if (defineName[0] == 't' && defineName[1] == 'r' && defineName[2] == 'u' && defineName[3] == 'e') {
+                                               defineName = null;
+                                       } else if (defineName[0] == 'n' && defineName[1] == 'u' && defineName[2] == 'l' && defineName[3] == 'l') {
+                                               defineName = null;
+                                       }
+                               } else if (defineName.length == 5) {
+                                       if (defineName[0] == 'f' && defineName[1] == 'a' && defineName[2] == 'l' && defineName[3] == 's' && defineName[4] == 'e') {
+                                               defineName = null;
+                                       }
+                               }
+                               if (defineName != null) {
+                                       for (int i = 0; i < defineName.length; i++) {
+                                               if (Character.isLowerCase(defineName[i])) {
+                                                       problemReporter.phpUppercaseIdentifierWarning(startPos, endPos, referenceContext, compilationUnit.compilationResult);
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
+                       // TODO is this ok ?
+                       return ref;
+                       // throwSyntaxError("'(' expected in function call.");
+               }
+               getNextToken();
+               if (token == TokenNameRPAREN) {
+                       getNextToken();
+                       return ref;
+               }
+               non_empty_function_call_parameter_list();
+               if (token != TokenNameRPAREN) {
+                       String functionName;
+                       if (ident == null) {
+                               functionName = new String(" ");
+                       } else {
+                               functionName = new String(ident);
+                       }
+                       throwSyntaxError("')' expected in function call (" + functionName + ").");
+               }
+               getNextToken();
+
                if (token == TokenNameMINUS_GREATER) {
                        ref = null;
                        getNextToken();
index ce16744..a19a44d 100644 (file)
@@ -27,8 +27,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
         * stream - currentPosition-1 gives the sourceEnd position into the stream
         */
        // 1.4 feature
-//     private boolean assertMode;
-
+       // private boolean assertMode;
        public boolean useAssertAsAnIndentifier = false;
 
        // flag indicating if processed source contains occurrences of keyword assert
@@ -199,6 +198,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                ObviousIdentCharNatures['"'] = C_SEPARATOR;
                ObviousIdentCharNatures['\''] = C_SEPARATOR;
        }
+
        static final char[] initCharArray = new char[] { '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000' };
 
        static final int TableSize = 30, InternalTableSize = 6;
@@ -285,10 +285,11 @@ public class Scanner implements IScanner, ITerminalSymbols {
         */
        public static boolean isPHPIdentOrVarStart(char ch) {
                if (ch < MAX_OBVIOUS) {
-                       return ObviousIdentCharNatures[ch]==C_LETTER || ObviousIdentCharNatures[ch]==C_DOLLAR;
+                       return ObviousIdentCharNatures[ch] == C_LETTER || ObviousIdentCharNatures[ch] == C_DOLLAR;
                }
                return false;
-               //return Character.isLetter(ch) || (ch == '$') || (ch == '_') || (0x7F <= ch && ch <= 0xFF);
+               // return Character.isLetter(ch) || (ch == '$') || (ch == '_') || (0x7F <=
+               // ch && ch <= 0xFF);
        }
 
        /**
@@ -299,10 +300,11 @@ public class Scanner implements IScanner, ITerminalSymbols {
         */
        public static boolean isPHPIdentifierStart(char ch) {
                if (ch < MAX_OBVIOUS) {
-                       return ObviousIdentCharNatures[ch]==C_LETTER;
+                       return ObviousIdentCharNatures[ch] == C_LETTER;
                }
                return false;
-//             return Character.isLetter(ch) || (ch == '_') || (0x7F <= ch && ch <= 0xFF);
+               // return Character.isLetter(ch) || (ch == '_') || (0x7F <= ch && ch <=
+               // 0xFF);
        }
 
        /**
@@ -311,15 +313,16 @@ public class Scanner implements IScanner, ITerminalSymbols {
         */
        public static boolean isPHPIdentifierPart(char ch) {
                if (ch < MAX_OBVIOUS) {
-                       return ObviousIdentCharNatures[ch]==C_LETTER || ObviousIdentCharNatures[ch]==C_DIGIT;
+                       return ObviousIdentCharNatures[ch] == C_LETTER || ObviousIdentCharNatures[ch] == C_DIGIT;
                }
                return false;
-//             return Character.isLetterOrDigit(ch) || (ch == '_') || (0x7F <= ch && ch <= 0xFF);
+               // return Character.isLetterOrDigit(ch) || (ch == '_') || (0x7F <= ch && ch
+               // <= 0xFF);
        }
 
        public static boolean isSQLIdentifierPart(char ch) {
                if (ch < MAX_OBVIOUS) {
-                       return ObviousIdentCharNatures[ch]==C_LETTER || ObviousIdentCharNatures[ch]==C_DIGIT;
+                       return ObviousIdentCharNatures[ch] == C_LETTER || ObviousIdentCharNatures[ch] == C_DIGIT;
                }
                return false;
        }
@@ -424,7 +427,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                        return false;
                }
                for (int i = 0; i < word.length; i++) {
-                       if (word[i]!=source[startPosition+i]){
+                       if (word[i] != source[startPosition + i]) {
                                return false;
                        }
                }
@@ -901,8 +904,9 @@ public class Scanner implements IScanner, ITerminalSymbols {
                        do {
                                currentCharacter = source[currentPosition++];
                        } while (currentCharacter == ' ' || currentCharacter == '\t');
-                       while (ObviousIdentCharNatures[currentCharacter]==C_LETTER) {
-                               //      while((currentCharacter >= 'a' && currentCharacter <= 'z') || (currentCharacter >= 'A' && currentCharacter <= 'Z')) {
+                       while (ObviousIdentCharNatures[currentCharacter] == C_LETTER) {
+                               // while((currentCharacter >= 'a' && currentCharacter <= 'z') ||
+                               // (currentCharacter >= 'A' && currentCharacter <= 'Z')) {
                                buf.append(currentCharacter);
                                currentCharacter = source[currentPosition++];
                        }
@@ -2441,7 +2445,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                        break;
                                }
                                default:
-                                       if (isPHPIdentOrVarStart(currentCharacter) ) {
+                                       if (isPHPIdentOrVarStart(currentCharacter)) {
                                                try {
                                                        scanIdentifierOrKeyword((currentCharacter == '$'));
                                                } catch (InvalidInputException ex) {
@@ -2449,8 +2453,8 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                ;
                                                break;
                                        }
-                               if ( ObviousIdentCharNatures[currentCharacter]==C_DIGIT) {
-//                                     if (Character.isDigit(currentCharacter)) {
+                                       if (ObviousIdentCharNatures[currentCharacter] == C_DIGIT) {
+                                               // if (Character.isDigit(currentCharacter)) {
                                                try {
                                                        scanNumber(false);
                                                } catch (InvalidInputException ex) {
@@ -3528,8 +3532,13 @@ public class Scanner implements IScanner, ITerminalSymbols {
                        } else
                                return TokenNameIdentifier;
                case 's':
-                       // static switch
+                       // self static switch
                        switch (length) {
+//                     case 4:
+//                             if ((data[++index] == 'e') && (data[++index] == 'l') && (data[++index] == 'f')) {
+//                                     return TokenNameself;
+//                             }
+//                             return TokenNameIdentifier;
                        case 6:
                                if (data[++index] == 't')
                                        if ((data[++index] == 'a') && (data[++index] == 't') && (data[++index] == 'i') && (data[++index] == 'c')) {
@@ -3957,6 +3966,8 @@ public class Scanner implements IScanner, ITerminalSymbols {
                        return "require_once"; //$NON-NLS-1$
                case TokenNamereturn:
                        return "return"; //$NON-NLS-1$
+//             case TokenNameself:
+//                     return "self"; //$NON-NLS-1$
                case TokenNamestatic:
                        return "static"; //$NON-NLS-1$
                case TokenNameswitch:
@@ -3985,10 +3996,10 @@ public class Scanner implements IScanner, ITerminalSymbols {
                        return "StringInterpolated(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
                case TokenNameEncapsedString0:
                        return "`"; //$NON-NLS-1$
-                       // case TokenNameEncapsedString1:
-                       // return "\'"; //$NON-NLS-1$
-                       // case TokenNameEncapsedString2:
-                       // return "\""; //$NON-NLS-1$
+               // case TokenNameEncapsedString1:
+               // return "\'"; //$NON-NLS-1$
+               // case TokenNameEncapsedString2:
+               // return "\""; //$NON-NLS-1$
                case TokenNameSTRING:
                        return "STRING_DQ(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
                case TokenNameHEREDOC:
@@ -4163,7 +4174,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
                this.tokenizeWhiteSpace = tokenizeWhiteSpace;
                this.tokenizeStrings = tokenizeStrings;
                this.checkNonExternalizedStringLiterals = checkNonExternalizedStringLiterals;
-//             this.assertMode = assertMode;
+               // this.assertMode = assertMode;
                // this.encapsedStringStack = null;
                this.taskTags = taskTags;
                this.taskPriorities = taskPriorities;
@@ -4337,8 +4348,8 @@ public class Scanner implements IScanner, ITerminalSymbols {
                                                        continue nextTag;
                                                if ((sc = src[i + t]) != (tc = tag[t])) { // case sensitive check
                                                        if (this.isTaskCaseSensitive || (Character.toLowerCase(sc) != Character.toLowerCase(tc))) { // case
-                                                                                                                                                                                                                                                                                                                                                                                                                                       // insensitive
-                                                                                                                                                                                                                                                                                                                                                                                                                                       // check
+                                                               // insensitive
+                                                               // check
                                                                continue nextTag;
                                                        }
                                                }
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;
                }
index f042e57..57e4b4a 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
  *******************************************************************************/
@@ -67,27 +67,27 @@ public class TemplateProposal implements IPHPCompletionProposal, ICompletionProp
 
        private IRegion fSelectedRegion; // initialized by apply()
        private String fDisplayString;
-               
+
        /**
         * Creates a template proposal with a template and its context.
-        * 
+        *
         * @param template  the template
         * @param context   the context in which the template was requested
         * @param region        the region this proposal applies to
         * @param image     the icon of the proposal
-        */     
+        */
        public TemplateProposal(Template template, TemplateContext context, IRegion region, Image image) {
                Assert.isNotNull(template);
                Assert.isNotNull(context);
                Assert.isNotNull(region);
-               
+
                fTemplate= template;
                fContext= context;
                fImage= image;
                fRegion= region;
-               
+
                fDisplayString= null;
-               
+
                if (context instanceof JavaContext) {
                        switch (((JavaContext) context).getCharacterBeforeStart()) {
                        // high relevance after whitespace
@@ -101,8 +101,8 @@ public class TemplateProposal implements IPHPCompletionProposal, ICompletionProp
                                fRelevance= 0;
                        }
                } else {
-                       fRelevance= 90;                 
-               }               
+                       fRelevance= 90;
+               }
        }
 
        /*
@@ -111,14 +111,14 @@ public class TemplateProposal implements IPHPCompletionProposal, ICompletionProp
        public final void apply(IDocument document) {
                // not called anymore
        }
-       
+
        /*
         * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer, char, int, int)
         */
        public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
 
                try {
-                       
+
                        fContext.setReadOnly(false);
                        TemplateBuffer templateBuffer;
                        try {
@@ -127,34 +127,34 @@ public class TemplateProposal implements IPHPCompletionProposal, ICompletionProp
                                fSelectedRegion= fRegion;
                                return;
                        }
-                       
+
                        int start= getReplaceOffset();
                        int end= getReplaceEndOffset();
                        end= Math.max(end, offset);
-                       
+
                        // insert template string
                        IDocument document= viewer.getDocument();
-                       String templateString= templateBuffer.getString();      
-                       document.replace(start, end - start, templateString);   
-                       
+                       String templateString= templateBuffer.getString();
+                       document.replace(start, end - start, templateString);
+
                        // translate positions
                        LinkedModeModel model= new LinkedModeModel();
                        TemplateVariable[] variables= templateBuffer.getVariables();
-                       
+
                        MultiVariableGuess guess= fContext instanceof CompilationUnitContext ? ((CompilationUnitContext) fContext).getMultiVariableGuess() : null;
-               
+
                        boolean hasPositions= false;
                        for (int i= 0; i != variables.length; i++) {
                                TemplateVariable variable= variables[i];
 
                                if (variable.isUnambiguous())
                                        continue;
-                               
+
                                LinkedPositionGroup group= new LinkedPositionGroup();
-                               
+
                                int[] offsets= variable.getOffsets();
                                int length= variable.getLength();
-                               
+
                                LinkedPosition first;
                                if (guess != null && variable instanceof MultiVariable) {
                                        first= new VariablePosition(document, offsets[0] + start, length, guess, (MultiVariable) variable);
@@ -168,54 +168,54 @@ public class TemplateProposal implements IPHPCompletionProposal, ICompletionProp
                                                document.addPosition(getCategory(), pos);
                                                proposals[j]= new PositionBasedCompletionProposal(values[j], pos, length);
                                        }
-                                       
+
                                        if (proposals.length > 1)
                                                first= new ProposalPosition(document, offsets[0] + start, length, proposals);
                                        else
                                                first= new LinkedPosition(document, offsets[0] + start, length);
                                }
-                               
+
                                for (int j= 0; j != offsets.length; j++)
                                        if (j == 0)
                                                group.addPosition(first);
                                        else
                                                group.addPosition(new LinkedPosition(document, offsets[j] + start, length));
-                               
+
                                model.addGroup(group);
                                hasPositions= true;
                        }
-                       
+
                        if (hasPositions) {
                                model.forceInstall();
                                PHPEditor editor= getJavaEditor();
                                if (editor != null) {
                                        model.addLinkingListener(new EditorHighlightingSynchronizer(editor));
                                }
-                               
+
                                LinkedModeUI ui= new EditorLinkedModeUI(model, viewer);
                                ui.setExitPosition(viewer, getCaretOffset(templateBuffer) + start, 0, Integer.MAX_VALUE);
                                ui.enter();
-                               
+
                                fSelectedRegion= ui.getSelectedRegion();
                        } else
                                fSelectedRegion= new Region(getCaretOffset(templateBuffer) + start, 0);
-                       
+
                } catch (BadLocationException e) {
                  PHPeclipsePlugin.log(e);
-                       openErrorDialog(viewer.getTextWidget().getShell(), e);              
+                       openErrorDialog(viewer.getTextWidget().getShell(), e);
                        fSelectedRegion= fRegion;
                } catch (BadPositionCategoryException e) {
                  PHPeclipsePlugin.log(e);
-                       openErrorDialog(viewer.getTextWidget().getShell(), e);              
+                       openErrorDialog(viewer.getTextWidget().getShell(), e);
                        fSelectedRegion= fRegion;
                }
 
-       }       
-       
+       }
+
        /**
-        * Returns the currently active java editor, or <code>null</code> if it 
+        * Returns the currently active java editor, or <code>null</code> if it
         * cannot be determined.
-        * 
+        *
         * @return  the currently active java editor, or <code>null</code>
         */
        private PHPEditor getJavaEditor() {
@@ -229,7 +229,7 @@ public class TemplateProposal implements IPHPCompletionProposal, ICompletionProp
        /**
         * Returns the offset of the range in the document that will be replaced by
         * applying this template.
-        * 
+        *
         * @return the offset of the range in the document that will be replaced by
         *         applying this template
         */
@@ -247,7 +247,7 @@ public class TemplateProposal implements IPHPCompletionProposal, ICompletionProp
        /**
         * Returns the end offset of the range in the document that will be replaced
         * by applying this template.
-        * 
+        *
         * @return the end offset of the range in the document that will be replaced
         *         by applying this template
         */
@@ -267,7 +267,7 @@ public class TemplateProposal implements IPHPCompletionProposal, ICompletionProp
                        document.addPositionCategory(getCategory());
                        final InclusivePositionUpdater updater= new InclusivePositionUpdater(getCategory());
                        document.addPositionUpdater(updater);
-                       
+
                        model.addLinkingListener(new ILinkedModeListener() {
 
                                /*
@@ -293,7 +293,7 @@ public class TemplateProposal implements IPHPCompletionProposal, ICompletionProp
        }
 
        private int getCaretOffset(TemplateBuffer buffer) {
-       
+
            TemplateVariable[] variables= buffer.getVariables();
                for (int i= 0; i != variables.length; i++) {
                        TemplateVariable variable= variables[i];
@@ -303,7 +303,7 @@ public class TemplateProposal implements IPHPCompletionProposal, ICompletionProp
 
                return buffer.getString().length();
        }
-       
+
        /*
         * @see ICompletionProposal#getSelection(IDocument)
         */
@@ -341,10 +341,10 @@ public class TemplateProposal implements IPHPCompletionProposal, ICompletionProp
                }
                return fDisplayString;
        }
-       
+
        public void setDisplayString(String displayString) {
                fDisplayString= displayString;
-       }       
+       }
 
        /*
         * @see ICompletionProposal#getImage()
@@ -378,7 +378,7 @@ public class TemplateProposal implements IPHPCompletionProposal, ICompletionProp
        public void setRelevance(int relevance) {
                fRelevance= relevance;
        }
-       
+
        public Template getTemplate() {
                return fTemplate;
        }