X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPUnitContext.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPUnitContext.java index 5d98915..3f27a31 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPUnitContext.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPUnitContext.java @@ -6,9 +6,11 @@ package net.sourceforge.phpdt.internal.corext.template.php; import net.sourceforge.phpdt.internal.corext.template.ContextType; import net.sourceforge.phpdt.internal.corext.template.DocumentTemplateContext; +import net.sourceforge.phpdt.internal.corext.template.ITemplateEditor; 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; @@ -24,7 +26,7 @@ public class PHPUnitContext extends DocumentTemplateContext { private static final String specialChars = "$"; /** The compilation unit, may be null. */ // private final ICompilationUnit fCompilationUnit; - + protected boolean fForceEvaluation; /** * Creates a compilation unit context. * @@ -36,10 +38,17 @@ public class PHPUnitContext extends DocumentTemplateContext { protected PHPUnitContext(ContextType type, IDocument document, int completionPosition) //,ICompilationUnit compilationUnit) { - super(type, document, completionPosition); + super(type, document, completionPosition, 0); // fCompilationUnit= compilationUnit; } - + + protected PHPUnitContext(ContextType type, IDocument document, int completionPosition, int completionLength) + //,ICompilationUnit compilationUnit) + { + super(type, document, completionPosition, completionLength); + // fCompilationUnit= compilationUnit; + } + /* * @see TemplateContext#canEvaluate(Template templates) */ @@ -57,7 +66,8 @@ public class PHPUnitContext extends DocumentTemplateContext { return // fEnabled && // fContextTypeName.equals(contextTypeName) && - (prefix.length() != 0) && identifier.toLowerCase().startsWith(prefix.toLowerCase()); +// (prefix.length() != 0) && + identifier.toLowerCase().startsWith(prefix.toLowerCase()); } /* @@ -81,8 +91,8 @@ public class PHPUnitContext extends DocumentTemplateContext { if (lineDelimiter == null) lineDelimiter = PLATFORM_LINE_DELIMITER; - // ITemplateEditor formatter= new JavaFormatter(lineDelimiter); - // formatter.edit(buffer, this); +// ITemplateEditor formatter= new PHPFormatter(lineDelimiter); +// formatter.edit(buffer, this); return buffer; } @@ -93,8 +103,12 @@ public class PHPUnitContext 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 +122,7 @@ public class PHPUnitContext extends DocumentTemplateContext { return start; } catch (BadLocationException e) { - return getCompletionPosition(); + return getCompletionOffset(); } } @@ -125,6 +139,7 @@ public class PHPUnitContext extends DocumentTemplateContext { return ' '; } } + /** * Returns the compilation unit if one is associated with this context, null otherwise. */ @@ -152,4 +167,11 @@ public class PHPUnitContext extends DocumentTemplateContext { // } // } + /** + * @param b + */ + public void setForceEvaluation(boolean b) { + fForceEvaluation = b; + } + }