X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCompletionProcessor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCompletionProcessor.java index 69f3124..d0d7f92 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCompletionProcessor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCompletionProcessor.java @@ -282,12 +282,23 @@ public class PHPCompletionProcessor implements IContentAssistProcessor { scanner.setPHPMode(true); int beforeLastToken = ITerminalSymbols.TokenNameEOF; int lastToken = ITerminalSymbols.TokenNameEOF; + char[] ident; try { token = scanner.getNextToken(); lastToken = token; while (token != ITerminalSymbols.TokenNameERROR && token != ITerminalSymbols.TokenNameEOF) { beforeLastToken = lastToken; + if (lastToken==ITerminalSymbols.TokenNameVariable) { + ident = scanner.getCurrentTokenSource(); + if (ident[0]=='$' && + ident[0]=='t' && + ident[0]=='h' && + ident[0]=='i' && + ident[0]=='s') { + beforeLastToken = ITerminalSymbols.TokenNamethis_PHP_COMPLETION; + } + } lastToken = token; // System.out.println(scanner.toStringAction(lastToken)); token = scanner.getNextToken(); @@ -534,61 +545,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor { // } } } - - final ICompilationUnit unit = fManager.getWorkingCopy(fEditor - .getEditorInput()); - - // get buffer contents - final IBuffer buffer; - CompilationUnitDeclaration unitDecl=null; - try { - buffer = unit.getBuffer(); - - if (project != null && buffer != null) { - - // final char[] contents = buffer == null ? null : - // buffer.getCharacters(); - // - // // generate structure and compute syntax problems if needed - // CompilationUnitStructureRequestor requestor = new - // CompilationUnitStructureRequestor(this, unitInfo, newElements); - // JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo = - // getPerWorkingCopyInfo(); - // IJavaProject project = getJavaProject(); - // boolean computeProblems = - // JavaProject.hasJavaNature(project.getProject()) && perWorkingCopyInfo - // != null && perWorkingCopyInfo.isActive(); - IProblemFactory problemFactory = new DefaultProblemFactory(); - // Map options = project.getOptions(true); - SourceElementParser parser = new SourceElementParser(null, - problemFactory, new CompilerOptions(null)); - //, true/*report local declarations*/); - unitDecl = parser.parseCompletionUnit( - new net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit() { - public char[] getContents() { - return buffer.getCharacters(); - } - - public char[] getMainTypeName() { - return null; - } - - public char[][] getPackageName() { - return null; - } - - public char[] getFileName() { - return null; - } - }, true /* full parse to find local elements */); - - } -// System.out.println(unit.toString()); - } catch (Exception e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - + ContextType phpContextType = ContextTypeRegistry.getInstance() .getContextType("php"); //$NON-NLS-1$ ((CompilationUnitContextType) phpContextType).setContextParameters( @@ -599,7 +556,8 @@ public class PHPCompletionProcessor implements IContentAssistProcessor { int lastSignificantToken = getLastToken(viewer, offset, context, sqlTable); boolean useClassMembers = (lastSignificantToken == ITerminalSymbols.TokenNameMINUS_GREATER) || (lastSignificantToken == ITerminalSymbols.TokenNameVariable) - || (lastSignificantToken == ITerminalSymbols.TokenNamenew); + || (lastSignificantToken == ITerminalSymbols.TokenNamenew) + || (lastSignificantToken == ITerminalSymbols.TokenNamethis_PHP_COMPLETION); boolean emptyPrefix = prefix == null || prefix.equals(""); if (fTemplateEngine != null) { IPHPCompletionProposal[] templateResults = new IPHPCompletionProposal[0];