X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/HTMLUnitContext.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/HTMLUnitContext.java index e459ce2..76343dd 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/HTMLUnitContext.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/HTMLUnitContext.java @@ -9,6 +9,7 @@ import net.sourceforge.phpdt.internal.corext.template.DocumentTemplateContext; import net.sourceforge.phpdt.internal.corext.template.Template; import net.sourceforge.phpdt.internal.corext.template.TemplateBuffer; import net.sourceforge.phpdt.internal.corext.template.TemplateTranslator; + import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; @@ -21,7 +22,7 @@ public class HTMLUnitContext extends DocumentTemplateContext { /** The platform default line delimiter. */ private static final String PLATFORM_LINE_DELIMITER = System.getProperty("line.separator"); //$NON-NLS-1$ - private static final String specialChars = "$&<"; + private static final String specialChars = "&<#"; /** The compilation unit, may be null. */ // private final ICompilationUnit fCompilationUnit; @@ -36,7 +37,7 @@ public class HTMLUnitContext extends DocumentTemplateContext { protected HTMLUnitContext(ContextType type, IDocument document, int completionPosition) //,ICompilationUnit compilationUnit) { - super(type, document, completionPosition); + super(type, document, completionPosition, 0); // fCompilationUnit= compilationUnit; } @@ -93,8 +94,12 @@ public class HTMLUnitContext extends DocumentTemplateContext { public int getStart() { IDocument document = getDocument(); try { - int start = getCompletionPosition(); + int start = getCompletionOffset(); + if ( ((start != 0) && specialChars.indexOf(document.getChar(start - 1)) != (-1) )) { + return --start; + } + while (((start != 0) && Character.isUnicodeIdentifierPart(document.getChar(start - 1))) || ((start != 0) && specialChars.indexOf(document.getChar(start - 1)) != (-1) )) { start--; @@ -108,7 +113,7 @@ public class HTMLUnitContext extends DocumentTemplateContext { return start; } catch (BadLocationException e) { - return getCompletionPosition(); + return getCompletionOffset(); } }