Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 16722 Details for
Bug 81403
Completion improvement.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Rewritten solution
org.eclipse.cdt.ui.completition.adb.patch (text/plain), 7.55 KB, created by
Tomaszewski Przemek
on 2004-12-17 05:13:26 EST
(
hide
)
Description:
Rewritten solution
Filename:
MIME Type:
Creator:
Tomaszewski Przemek
Created:
2004-12-17 05:13:26 EST
Size:
7.55 KB
patch
obsolete
>Index: src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor.java >=================================================================== >RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor.java,v >retrieving revision 1.26 >diff -u -r1.26 CCompletionProcessor.java >--- src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor.java 13 Dec 2004 21:16:29 -0000 1.26 >+++ src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor.java 17 Dec 2004 09:37:29 -0000 >@@ -10,6 +10,7 @@ > import java.util.Iterator; > import java.util.LinkedList; > import java.util.List; >+import java.util.regex.Pattern; > > import org.eclipse.cdt.core.model.ICElement; > import org.eclipse.cdt.core.model.ITranslationUnit; >@@ -32,13 +33,15 @@ > import org.eclipse.cdt.ui.CUIPlugin; > import org.eclipse.cdt.ui.IFunctionSummary; > import org.eclipse.cdt.ui.IWorkingCopyManager; >-import org.eclipse.cdt.ui.text.ICHelpInvocationContext; > import org.eclipse.cdt.ui.text.ICCompletionProposal; >+import org.eclipse.cdt.ui.text.ICHelpInvocationContext; > import org.eclipse.core.resources.IProject; > import org.eclipse.jface.preference.IPreferenceStore; > import org.eclipse.jface.text.BadLocationException; > import org.eclipse.jface.text.IDocument; > import org.eclipse.jface.text.ITextViewer; >+import org.eclipse.jface.text.ITypedRegion; >+import org.eclipse.jface.text.TypedRegion; > import org.eclipse.jface.text.contentassist.ContextInformation; > import org.eclipse.jface.text.contentassist.ICompletionProposal; > import org.eclipse.jface.text.contentassist.IContentAssistProcessor; >@@ -54,12 +57,13 @@ > */ > public class CCompletionProcessor implements IContentAssistProcessor { > >+ > private static class ContextInformationWrapper implements IContextInformation, IContextInformationExtension { > > private final IContextInformation fContextInformation; > private int fPosition; > >- public ContextInformationWrapper(IContextInformation contextInformation) { >+ public ContextInformationWrapper(IContextInformation contextInformation) { > fContextInformation= contextInformation; > } > >@@ -122,7 +126,6 @@ > > public CCompletionProcessor(IEditorPart editor) { > fEditor = (CEditor) editor; >- > // Needed for search > searchResultCollector = new BasicSearchResultCollector (); > resultCollector = new ResultCollector(); >@@ -327,12 +330,109 @@ > if (fCurrentCompletionNode != null) { > addProposalsFromSearch(fCurrentCompletionNode, completions); > addProposalsFromCompletionContributors(fCurrentCompletionNode, completions); >- addProposalsFromTemplates(viewer, fCurrentCompletionNode, completions); >- return order( (ICCompletionProposal[]) completions.toArray(new ICCompletionProposal[0])); >+ addProposalsFromTemplates(viewer, fCurrentCompletionNode, completions); >+ ICCompletionProposal fastProposal = null; >+ if (completions.size() > 1) { >+ fastProposal = checkForFastCompletion(completions); >+ } >+ if (fastProposal == null) { >+ return order((ICCompletionProposal[]) completions.toArray(new ICCompletionProposal[0])); >+ } >+ return new ICCompletionProposal[] { fastProposal }; > } > return null; > } >- >+ >+ /** >+ * Determines if character matches separator in fast completion postfix end. >+ * >+ * @param ch >+ * Character to check. >+ * @return <code>true</code> if matches. >+ */ >+ private static boolean isProposalEnd(char ch) { >+ return ch == '(' || Character.isWhitespace(ch); >+ } >+ >+ /** >+ * Retrieves matching proposals. These which matches proposals. >+ * @param proposals Proposals to check. >+ * @param prefixChars Prefix to match. >+ * @return List of proposals which match to prefix. >+ */ >+ private static List getMatchingProposals(List proposals, char[] prefixChars) >+ { >+ final List matchingCompletions = new LinkedList(); >+ final int size = proposals.size(); >+ >+ // Retrieves only matching proposals. >+ for (int i = 0; i < size; i++) { >+ final ICCompletionProposal proposal = (ICCompletionProposal) proposals.get(i); >+ final char[] proposalChars = proposal.getDisplayString().toCharArray(); >+ boolean skip = false; >+ for (int j = 0; j < prefixChars.length; j++) { >+ if (prefixChars[j] != proposalChars[j]) { >+ skip = true; >+ break; >+ } >+ } >+ if (!skip) { >+ matchingCompletions.add(proposal); >+ } >+ } >+ return matchingCompletions; >+ } >+ /** >+ * Checks if completions have their common part at the begining. >+ * If yes, it creates proposal with usage of this part. >+ * It is case sensitive. >+ >+ * @param completions Completions for check. >+ * @return Found completion or <code>null</code> >+ */ >+ private ICCompletionProposal checkForFastCompletion(List completions) >+ { >+ final char[] prefixChars = fCurrentCompletionNode.getCompletionPrefix().toCharArray(); >+ final List matching = getMatchingProposals(completions, prefixChars); >+ >+ // If no matching, all proposals should be shown. >+ final int size = matching.size(); >+ if (size == 0) { >+ return null; >+ } >+ >+ final StringBuffer resultProposal = new StringBuffer(); >+ final char[] current = ((ICCompletionProposal) matching.get(0)).getDisplayString().toCharArray(); >+ for (int currentCharIdx = prefixChars.length; currentCharIdx < current.length; currentCharIdx++) { >+ boolean end = false; >+ final char ch = current[currentCharIdx]; >+ if (isProposalEnd(ch)) >+ { >+ break; >+ } >+ for (int i = 0; i < size; i++) { >+ final char[] proposalChars = ((ICCompletionProposal) matching.get(i)).getDisplayString().toCharArray(); >+ if (currentCharIdx < proposalChars.length) { >+ if (proposalChars[currentCharIdx] != ch) { >+ end = true; >+ break; >+ } >+ } >+ else { >+ end = true; >+ break; >+ } >+ } >+ if (end) { >+ break; >+ } >+ resultProposal.append(ch); >+ } >+ return resultProposal.length() == 0 >+ ? null >+ : new CCompletionProposal(resultProposal.toString(), fCurrentOffset, resultProposal.length(), null, null, 0); >+ } >+ > private void addProposalsFromTemplates(ITextViewer viewer, IASTCompletionNode completionNode, List completions){ > if (completionNode == null) > return; >@@ -343,9 +443,9 @@ > IASTCompletionNode.CompletionKind kind = completionNode.getCompletionKind(); > > >-// if ((kind == IASTCompletionNode.CompletionKind.VARIABLE_TYPE) || >-// (kind == IASTCompletionNode.CompletionKind.CLASS_REFERENCE) >-// || (kind == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)) { >+// if ((kind == IASTCompletionNode.CompletionKind.VARIABLE_TYPE) || >+// (kind == IASTCompletionNode.CompletionKind.CLASS_REFERENCE) >+// || (kind == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)) { > addProposalsFromTemplateEngine(viewer, fTemplateEngine, completions); > // } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
bjorn.freeman-benson
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 81403
:
16695
| 16722 |
17195
|
17233