1 /**********************************************************************
2 Copyright (c) 2000, 2002 IBM Corp. and others.
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Common Public License v1.0
5 which accompanies this distribution, and is available at
6 http://www.eclipse.org/legal/cpl-v10.html
9 IBM Corporation - Initial implementation
10 Klaus Hartlage - www.eclipseproject.de
11 **********************************************************************/
12 package net.sourceforge.phpeclipse.phpeditor.php;
14 import java.sql.Connection;
15 import java.sql.DatabaseMetaData;
16 import java.sql.ResultSet;
17 import java.sql.SQLException;
18 import java.util.ArrayList;
19 import java.util.Arrays;
20 import java.util.List;
21 import java.util.SortedMap;
23 import net.sourceforge.phpdt.core.ICompilationUnit;
24 import net.sourceforge.phpdt.core.ToolFactory;
25 import net.sourceforge.phpdt.core.compiler.ITerminalSymbols;
26 import net.sourceforge.phpdt.core.compiler.InvalidInputException;
27 import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
28 import net.sourceforge.phpdt.internal.corext.template.php.JavaContext;
29 import net.sourceforge.phpdt.internal.corext.template.php.JavaContextType;
30 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
31 import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal;
32 import net.sourceforge.phpdt.internal.ui.text.java.PHPCompletionProposalComparator;
33 import net.sourceforge.phpdt.internal.ui.text.template.BuiltInEngine;
34 import net.sourceforge.phpdt.internal.ui.text.template.DeclarationEngine;
35 import net.sourceforge.phpdt.internal.ui.text.template.IdentifierEngine;
36 import net.sourceforge.phpdt.internal.ui.text.template.SQLProposal;
37 import net.sourceforge.phpdt.internal.ui.text.template.contentassist.TemplateEngine;
38 import net.sourceforge.phpdt.ui.IWorkingCopyManager;
39 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
40 import net.sourceforge.phpeclipse.builder.IdentifierIndexManager;
41 import net.sourceforge.phpeclipse.phpeditor.PHPEditor;
42 import net.sourceforge.phpeclipse.phpeditor.PHPSyntaxRdr;
43 import net.sourceforge.phpeclipse.ui.IPreferenceConstants;
44 import net.sourceforge.phpeclipse.ui.overlaypages.Util;
46 import org.eclipse.core.resources.IFile;
47 import org.eclipse.core.resources.IProject;
48 import org.eclipse.jface.text.BadLocationException;
49 import org.eclipse.jface.text.IDocument;
50 import org.eclipse.jface.text.IRegion;
51 import org.eclipse.jface.text.ITextViewer;
52 import org.eclipse.jface.text.Region;
53 import org.eclipse.jface.text.TextPresentation;
54 import org.eclipse.jface.text.contentassist.ICompletionProposal;
55 import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
56 import org.eclipse.jface.text.contentassist.IContextInformation;
57 import org.eclipse.jface.text.contentassist.IContextInformationExtension;
58 import org.eclipse.jface.text.contentassist.IContextInformationPresenter;
59 import org.eclipse.jface.text.contentassist.IContextInformationValidator;
60 import org.eclipse.jface.text.templates.TemplateContextType;
61 import org.eclipse.swt.graphics.Image;
62 import org.eclipse.swt.graphics.Point;
63 import org.eclipse.ui.IEditorPart;
64 import org.eclipse.ui.IFileEditorInput;
66 import com.quantum.model.Bookmark;
67 import com.quantum.model.BookmarkCollection;
68 import com.quantum.model.NotConnectedException;
69 import com.quantum.util.connection.ConnectionUtil;
72 * Example PHP completion processor.
74 public class PHPCompletionProcessor implements IContentAssistProcessor {
76 * Simple content assist tip closer. The tip is valid in a range of 5
77 * characters around its popup location.
79 protected static class Validator implements IContextInformationValidator,
80 IContextInformationPresenter {
81 protected int fInstallOffset;
84 * @see IContextInformationValidator#isContextInformationValid(int)
86 public boolean isContextInformationValid(int offset) {
87 return Math.abs(fInstallOffset - offset) < 5;
91 * @see IContextInformationValidator#install(IContextInformation,
94 public void install(IContextInformation info, ITextViewer viewer, int offset) {
95 fInstallOffset = offset;
99 * @see org.eclipse.jface.text.contentassist.IContextInformationPresenter#updatePresentation(int,
102 public boolean updatePresentation(int documentPosition,
103 TextPresentation presentation) {
108 private static class ContextInformationWrapper implements
109 IContextInformation, IContextInformationExtension {
110 private final IContextInformation fContextInformation;
112 private int fPosition;
114 public ContextInformationWrapper(IContextInformation contextInformation) {
115 fContextInformation = contextInformation;
119 * @see IContextInformation#getContextDisplayString()
121 public String getContextDisplayString() {
122 return fContextInformation.getContextDisplayString();
126 * @see IContextInformation#getImage()
128 public Image getImage() {
129 return fContextInformation.getImage();
133 * @see IContextInformation#getInformationDisplayString()
135 public String getInformationDisplayString() {
136 return fContextInformation.getInformationDisplayString();
140 * @see IContextInformationExtension#getContextInformationPosition()
142 public int getContextInformationPosition() {
146 public void setContextInformationPosition(int position) {
147 fPosition = position;
151 private class TableName {
159 * @return Returns the tableName.
161 public String getTableName() {
162 if (fTableName == null) {
163 return "<!--no-table-->";
170 * The tableName to set.
172 public void setTableName(String tableName) {
173 fTableName = tableName;
177 private char[] fProposalAutoActivationSet;
179 protected IContextInformationValidator fValidator = new Validator();
181 private TemplateEngine fTemplateEngine;
183 private PHPCompletionProposalComparator fComparator;
185 private int fNumberOfComputedResults = 0;
187 private IEditorPart fEditor;
189 protected IWorkingCopyManager fManager;
191 public PHPCompletionProcessor(IEditorPart editor) {
193 fManager = PHPeclipsePlugin.getDefault().getWorkingCopyManager();
194 TemplateContextType contextType = PHPeclipsePlugin.getDefault().getTemplateContextRegistry().getContextType(
195 "php"); //$NON-NLS-1$
196 if (contextType != null)
197 fTemplateEngine = new TemplateEngine(contextType);
198 fComparator = new PHPCompletionProposalComparator();
202 * Tells this processor to order the proposals alphabetically.
205 * <code>true</code> if proposals should be ordered.
207 public void orderProposalsAlphabetically(boolean order) {
208 fComparator.setOrderAlphabetically(order);
212 * Sets this processor's set of characters triggering the activation of the
213 * completion proposal computation.
215 * @param activationSet
218 public void setCompletionProposalAutoActivationCharacters(char[] activationSet) {
219 fProposalAutoActivationSet = activationSet;
223 * (non-Javadoc) Method declared on IContentAssistProcessor
225 public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer,
226 int documentOffset) {
227 int contextInformationPosition = guessContextInformationPosition(viewer,
229 return internalComputeCompletionProposals(viewer, documentOffset,
230 contextInformationPosition);
233 private int getLastToken(ITextViewer viewer, int completionPosition,
234 JavaContext context, TableName tableName) {
235 IDocument document = viewer.getDocument();
236 int start = context.getStart();
237 int end = context.getEnd();
239 int lastSignificantToken = ITerminalSymbols.TokenNameEOF;
241 // begin search 2 lines behind of this
246 ch = document.getChar(j);
252 ch = document.getChar(j);
259 // scan the line for the dereferencing operator '->'
260 startText = document.get(j, start - j);
262 System.out.println(startText);
264 int token = ITerminalSymbols.TokenNameEOF;
265 // token = getLastSQLToken(startText);
266 tableName.setTableName(getLastSQLTableName(startText));
267 Scanner scanner = ToolFactory.createScanner(false, false, false);
268 scanner.setSource(startText.toCharArray());
269 scanner.setPHPMode(true);
270 int beforeLastToken = ITerminalSymbols.TokenNameEOF;
271 int lastToken = ITerminalSymbols.TokenNameEOF;
274 token = scanner.getNextToken();
276 while (token != ITerminalSymbols.TokenNameERROR
277 && token != ITerminalSymbols.TokenNameEOF) {
278 beforeLastToken = lastToken;
279 if (lastToken==ITerminalSymbols.TokenNameVariable) {
280 ident = scanner.getCurrentTokenSource();
281 if (ident.length==5 &&
287 beforeLastToken = ITerminalSymbols.TokenNamethis_PHP_COMPLETION;
291 // System.out.println(scanner.toStringAction(lastToken));
292 token = scanner.getNextToken();
294 } catch (InvalidInputException e1) {
297 case ITerminalSymbols.TokenNameMINUS_GREATER:
298 // dereferencing operator '->' found
299 lastSignificantToken = ITerminalSymbols.TokenNameMINUS_GREATER;
300 if (beforeLastToken == ITerminalSymbols.TokenNameVariable) {
301 lastSignificantToken = ITerminalSymbols.TokenNameVariable;
304 case ITerminalSymbols.TokenNamenew:
305 lastSignificantToken = ITerminalSymbols.TokenNamenew;
309 } catch (BadLocationException e) {
311 return lastSignificantToken;
314 String getSQLTableName(String sqlText, int start) {
315 int tableNameStart = -1;
316 int currentCharacterPosition = start + 1;
320 ch = sqlText.charAt(currentCharacterPosition++);
321 if (tableNameStart == -1 && Character.isJavaIdentifierStart(ch)) {
322 tableNameStart = currentCharacterPosition - 1;
324 if (!Character.isJavaIdentifierPart(ch)) {
325 return sqlText.substring(tableNameStart,
326 currentCharacterPosition - 1);
330 } catch (IndexOutOfBoundsException e) {
331 if (tableNameStart >= 0) {
332 return sqlText.substring(tableNameStart, currentCharacterPosition - 1);
338 private String getLastSQLTableName(String startText) {
340 // scan for sql identifiers
342 int currentSQLPosition = startText.length();
345 boolean whiteSpace = true;
348 ch = startText.charAt(--currentSQLPosition);
349 if (ch >= 'A' && ch <= 'Z') {
351 identEnd = currentSQLPosition + 1;
353 } else if (ch >= 'a' && ch <= 'z') {
355 identEnd = currentSQLPosition + 1;
357 } else if (identEnd >= 0) {
358 ident = startText.substring(currentSQLPosition + 1, identEnd);
359 // select -- from -- where --
360 // update -- set -- where --
361 // insert into -- ( -- ) values ( -- )
362 if (ident.length() >= 4 && ident.length() <= 6) {
363 ident = ident.toLowerCase();
364 switch (ident.length()) {
366 // if (ident.equals("set")) {
367 // // System.out.println("set");
368 // token = ITerminalSymbols.TokenNameSQLset;
373 if (ident.equals("from")) {
374 // System.out.println("from");
375 token = ITerminalSymbols.TokenNameSQLfrom;
376 return getSQLTableName(startText, identEnd);
377 } else if (ident.equals("into")) {
378 // System.out.println("into");
379 token = ITerminalSymbols.TokenNameSQLinto;
380 return getSQLTableName(startText, identEnd);
384 // if (ident.equals("where")) {
385 // // System.out.println("where");
386 // token = ITerminalSymbols.TokenNameSQLwhere;
391 // if (ident.equals("select")) {
392 // // System.out.println("select");
393 // token = ITerminalSymbols.TokenNameSQLselect;
395 // } else if (ident.equals("insert")) {
396 // // System.out.println("insert");
397 // token = ITerminalSymbols.TokenNameSQLinsert;
400 if (ident.equals("update")) {
401 // System.out.println("update");
402 token = ITerminalSymbols.TokenNameSQLupdate;
403 return getSQLTableName(startText, identEnd);
405 // else if (ident.equals("values")) {
406 // // System.out.println("values");
407 // token = ITerminalSymbols.TokenNameSQLvalues;
415 } else if (Character.isWhitespace(ch)) {
420 } catch (IndexOutOfBoundsException e) {
422 return "<!--no-table-->";
426 * Detect the last significant SQL token in the text before the completion
430 private int getLastSQLToken(String startText) {
432 // scan for sql identifiers
434 int currentSQLPosition = startText.length();
437 boolean whiteSpace = true;
440 ch = startText.charAt(--currentSQLPosition);
441 if (ch >= 'A' && ch <= 'Z') {
443 identEnd = currentSQLPosition + 1;
445 } else if (ch >= 'a' && ch <= 'z') {
447 identEnd = currentSQLPosition + 1;
449 } else if (identEnd >= 0) {
450 ident = startText.substring(currentSQLPosition + 1, identEnd);
451 // select -- from -- where --
452 // update -- set -- where --
453 // insert into -- ( -- ) values ( -- )
454 if (ident.length() >= 3 && ident.length() <= 6) {
455 ident = ident.toLowerCase();
456 switch (ident.length()) {
458 if (ident.equals("set")) {
459 // System.out.println("set");
460 token = ITerminalSymbols.TokenNameSQLset;
465 if (ident.equals("from")) {
466 // System.out.println("from");
467 token = ITerminalSymbols.TokenNameSQLfrom;
470 } else if (ident.equals("into")) {
471 // System.out.println("into");
472 token = ITerminalSymbols.TokenNameSQLinto;
477 if (ident.equals("where")) {
478 // System.out.println("where");
479 token = ITerminalSymbols.TokenNameSQLwhere;
484 if (ident.equals("select")) {
485 // System.out.println("select");
486 token = ITerminalSymbols.TokenNameSQLselect;
488 } else if (ident.equals("insert")) {
489 // System.out.println("insert");
490 token = ITerminalSymbols.TokenNameSQLinsert;
492 } else if (ident.equals("update")) {
493 // System.out.println("update");
494 token = ITerminalSymbols.TokenNameSQLupdate;
496 } else if (ident.equals("values")) {
497 // System.out.println("values");
498 token = ITerminalSymbols.TokenNameSQLvalues;
506 } else if (Character.isWhitespace(ch)) {
511 } catch (IndexOutOfBoundsException e) {
513 return ITerminalSymbols.TokenNameEOF;
516 private ICompletionProposal[] internalComputeCompletionProposals(
517 ITextViewer viewer, int offset, int contextOffset) {
518 ICompilationUnit unit= fManager.getWorkingCopy(fEditor.getEditorInput());
519 IDocument document = viewer.getDocument();
520 Object[] identifiers = null;
522 IProject project = null;
524 PHPEditor editor = null;
525 if (fEditor != null && (fEditor instanceof PHPEditor)) {
526 editor = (PHPEditor) fEditor;
527 file = ((IFileEditorInput) editor.getEditorInput()).getFile();
528 project = file.getProject();
532 Point selection= viewer.getSelectedRange();
534 // remember selected text
535 String selectedText= null;
536 if (selection.y != 0) {
538 selectedText= document.get(selection.x, selection.y);
539 } catch (BadLocationException e) {}
542 JavaContextType phpContextType = (JavaContextType)PHPeclipsePlugin.getDefault().getTemplateContextRegistry().getContextType(
543 "php"); //$NON-NLS-1$
544 // ((CompilationUnitContextType) phpContextType).setContextParameters(
545 // document, offset, 0);
546 JavaContext context = (JavaContext) phpContextType.createContext(document, offset,selection.y,unit);
547 context.setVariable("selection", selectedText); //$NON-NLS-1$
548 String prefix = context.getKey();
549 TableName sqlTable = new TableName();
550 int lastSignificantToken = getLastToken(viewer, offset, context, sqlTable);
551 boolean useClassMembers = (lastSignificantToken == ITerminalSymbols.TokenNameMINUS_GREATER)
552 || (lastSignificantToken == ITerminalSymbols.TokenNameVariable)
553 || (lastSignificantToken == ITerminalSymbols.TokenNamenew)
554 || (lastSignificantToken == ITerminalSymbols.TokenNamethis_PHP_COMPLETION);
555 boolean emptyPrefix = prefix == null || prefix.equals("");
556 if (fTemplateEngine != null) {
557 IPHPCompletionProposal[] templateResults = new IPHPCompletionProposal[0];
558 ICompletionProposal[] results;
560 fTemplateEngine.reset();
561 fTemplateEngine.complete(viewer, offset, unit);
562 templateResults = fTemplateEngine.getResults();
564 IPHPCompletionProposal[] identifierResults = new IPHPCompletionProposal[0];
565 if ((!useClassMembers) && identifiers != null) {
566 IdentifierEngine identifierEngine;
567 JavaContextType contextType = (JavaContextType)PHPeclipsePlugin.getDefault().getTemplateContextRegistry().getContextType(
568 "php"); //$NON-NLS-1$
569 if (contextType != null) {
570 identifierEngine = new IdentifierEngine(contextType);
571 identifierEngine.complete(viewer, offset, identifiers,unit);
572 identifierResults = identifierEngine.getResults();
575 // declarations stored in file project.index on project level
576 IPHPCompletionProposal[] declarationResults = new IPHPCompletionProposal[0];
577 if (project != null) {
578 DeclarationEngine declarationEngine;
579 JavaContextType contextType = (JavaContextType)PHPeclipsePlugin.getDefault().getTemplateContextRegistry().getContextType(
580 "php"); //$NON-NLS-1$
581 if (contextType != null) {
582 IdentifierIndexManager indexManager = PHPeclipsePlugin.getDefault()
583 .getIndexManager(project);
584 SortedMap sortedMap = indexManager.getIdentifierMap();
585 declarationEngine = new DeclarationEngine(project, contextType,
586 lastSignificantToken, file);
587 declarationEngine.complete(viewer, offset, sortedMap,unit);
588 declarationResults = declarationEngine.getResults();
591 // built in function names from phpsyntax.xml
592 ArrayList syntaxbuffer = PHPSyntaxRdr.getSyntaxData();
593 IPHPCompletionProposal[] builtinResults = new IPHPCompletionProposal[0];
594 if ((!useClassMembers) && syntaxbuffer != null) {
595 BuiltInEngine builtinEngine;
597 JavaContextType contextType = (JavaContextType)PHPeclipsePlugin.getDefault().getTemplateContextRegistry().getContextType(
598 "php"); //$NON-NLS-1$
599 if (contextType != null) {
600 builtinEngine = new BuiltInEngine(contextType);
601 builtinEngine.complete(viewer, offset, syntaxbuffer, unit);
602 builtinResults = builtinEngine.getResults();
605 IPHPCompletionProposal[] sqlResults = new IPHPCompletionProposal[0];
606 if (project != null) {
607 // Get The Database bookmark from the Quantum SQL plugin:
608 BookmarkCollection sqlBookMarks = BookmarkCollection.getInstance();
609 if (sqlBookMarks != null) {
610 String bookmarkString = Util.getMiscProjectsPreferenceValue(project,
611 IPreferenceConstants.PHP_BOOKMARK_DEFAULT);
612 if (bookmarkString != null && !bookmarkString.equals("")) {
613 Bookmark bookmark = sqlBookMarks.find(bookmarkString);
614 ArrayList sqlList = new ArrayList();
615 if (bookmark != null && !bookmark.isConnected()) {
616 new ConnectionUtil().connect(bookmark, null);
618 if (bookmark != null && bookmark.isConnected()) {
620 Connection connection = bookmark.getConnection();
621 DatabaseMetaData metaData = connection.getMetaData();
623 if (metaData != null) {
624 int start = context.getStart();
625 int end = context.getEnd();
626 String foundSQLTableName = sqlTable.getTableName();
629 String prefixWithoutDollar = prefix;
630 boolean isDollarPrefix = false;
631 if (prefix.length() > 0 && prefix.charAt(0) == '$') {
632 prefixWithoutDollar = prefix.substring(1);
633 isDollarPrefix = true;
635 IRegion region = new Region(start, end - start);
637 if (!isDollarPrefix) {
638 set = metaData.getTables(null, null, prefixWithoutDollar
641 // String tempSchema = set.getString("TABLE_SCHEM");
642 // tempSchema = (tempSchema == null) ? "" :
643 // tempSchema.trim();
644 tableName = set.getString("TABLE_NAME");
645 tableName = (tableName == null) ? "" : tableName.trim();
646 if (tableName != null && tableName.length() > 0) {
647 sqlList.add(new SQLProposal(tableName, context, region,
648 viewer, PHPUiImages.get(PHPUiImages.IMG_TABLE)));
653 set = metaData.getColumns(null, null, "%",
654 prefixWithoutDollar + "%");
655 SQLProposal sqlProposal;
657 columnName = set.getString("COLUMN_NAME");
658 columnName = (columnName == null) ? "" : columnName.trim();
659 tableName = set.getString("TABLE_NAME");
660 tableName = (tableName == null) ? "" : tableName.trim();
661 if (tableName != null && tableName.length() > 0
662 && columnName != null && columnName.length() > 0) {
663 if (isDollarPrefix) {
664 sqlProposal = new SQLProposal(tableName, "$"
665 + columnName, context, region, viewer, PHPUiImages
666 .get(PHPUiImages.IMG_COLUMN));
668 sqlProposal = new SQLProposal(tableName, columnName,
669 context, region, viewer, PHPUiImages
670 .get(PHPUiImages.IMG_COLUMN));
672 if (tableName.equals(foundSQLTableName)) {
673 sqlProposal.setRelevance(90);
674 } else if (tableName.indexOf(foundSQLTableName) >= 0) {
675 sqlProposal.setRelevance(75);
677 sqlList.add(sqlProposal);
681 sqlResults = new IPHPCompletionProposal[sqlList.size()];
682 for (int i = 0; i < sqlList.size(); i++) {
683 sqlResults[i] = (SQLProposal) sqlList.get(i);
686 } catch (NotConnectedException e) {
687 // ignore this - not mission critical
688 } catch (SQLException e) {
695 // concatenate the result arrays
696 IPHPCompletionProposal[] total;
697 total = new IPHPCompletionProposal[templateResults.length
698 + identifierResults.length + builtinResults.length
699 + declarationResults.length + sqlResults.length];
700 System.arraycopy(templateResults, 0, total, 0, templateResults.length);
701 System.arraycopy(identifierResults, 0, total, templateResults.length,
702 identifierResults.length);
703 System.arraycopy(builtinResults, 0, total, templateResults.length
704 + identifierResults.length, builtinResults.length);
705 System.arraycopy(declarationResults, 0, total, templateResults.length
706 + identifierResults.length + builtinResults.length,
707 declarationResults.length);
708 System.arraycopy(sqlResults, 0, total, templateResults.length
709 + identifierResults.length + builtinResults.length
710 + declarationResults.length, sqlResults.length);
712 fNumberOfComputedResults = (results == null ? 0 : results.length);
714 * Order here and not in result collector to make sure that the order
715 * applies to all proposals and not just those of the compilation unit.
717 return order(results);
719 return new IPHPCompletionProposal[0];
722 private int guessContextInformationPosition(ITextViewer viewer, int offset) {
723 int contextPosition = offset;
724 IDocument document = viewer.getDocument();
727 // PHPCodeReader reader= new PHPCodeReader();
728 // reader.configureBackwardReader(document, offset, true, true);
730 // int nestingLevel= 0;
732 // int curr= reader.read();
733 // while (curr != PHPCodeReader.EOF) {
735 // if (')' == (char) curr)
738 // else if ('(' == (char) curr) {
741 // if (nestingLevel < 0) {
742 // int start= reader.getOffset();
743 // if (looksLikeMethod(reader))
748 // curr= reader.read();
750 // } catch (IOException e) {
752 return contextPosition;
756 * (non-Javadoc) Method declared on IContentAssistProcessor
758 // public IContextInformation[] computeContextInformation(ITextViewer viewer,
759 // int documentOffset) {
760 // IContextInformation[] result = new IContextInformation[5];
761 // for (int i = 0; i < result.length; i++)
763 // ContextInformation(MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.ContextInfo.display.pattern"),
764 // new Object[] { new Integer(i), new Integer(documentOffset)}),
766 // MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.ContextInfo.value.pattern"),
767 // new Object[] { new Integer(i), new Integer(documentOffset - 5), new
768 // Integer(documentOffset + 5)})); //$NON-NLS-1$
772 * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int)
774 public IContextInformation[] computeContextInformation(ITextViewer viewer,
776 int contextInformationPosition = guessContextInformationPosition(viewer,
778 List result = addContextInformations(viewer, contextInformationPosition);
779 return (IContextInformation[]) result
780 .toArray(new IContextInformation[result.size()]);
783 private List addContextInformations(ITextViewer viewer, int offset) {
784 ICompletionProposal[] proposals = internalComputeCompletionProposals(
786 List result = new ArrayList();
787 for (int i = 0; i < proposals.length; i++) {
788 IContextInformation contextInformation = proposals[i]
789 .getContextInformation();
790 if (contextInformation != null) {
791 ContextInformationWrapper wrapper = new ContextInformationWrapper(
793 wrapper.setContextInformationPosition(offset);
801 * Order the given proposals.
803 private ICompletionProposal[] order(ICompletionProposal[] proposals) {
804 Arrays.sort(proposals, fComparator);
809 * (non-Javadoc) Method declared on IContentAssistProcessor
811 public char[] getCompletionProposalAutoActivationCharacters() {
812 return fProposalAutoActivationSet;
813 // return null; // new char[] { '$' };
817 * (non-Javadoc) Method declared on IContentAssistProcessor
819 public char[] getContextInformationAutoActivationCharacters() {
820 return new char[] {};
824 * (non-Javadoc) Method declared on IContentAssistProcessor
826 public IContextInformationValidator getContextInformationValidator() {
831 * (non-Javadoc) Method declared on IContentAssistProcessor
833 public String getErrorMessage() {