Mercurial > projects > dwt-addons
comparison dwtx/jface/text/templates/TemplateCompletionProcessor.d @ 134:51e6e63f930e
Regex fix for casts
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 24 Aug 2008 01:46:20 +0200 |
parents | c4fb132a086c |
children | 02cd5f1224d3 |
comparison
equal
deleted
inserted
replaced
133:7d818bd32d63 | 134:51e6e63f930e |
---|---|
61 */ | 61 */ |
62 public abstract class TemplateCompletionProcessor : IContentAssistProcessor { | 62 public abstract class TemplateCompletionProcessor : IContentAssistProcessor { |
63 | 63 |
64 private static final class ProposalComparator : Comparator { | 64 private static final class ProposalComparator : Comparator { |
65 public int compare(Object o1, Object o2) { | 65 public int compare(Object o1, Object o2) { |
66 return ((TemplateProposal) o2).getRelevance() - ((TemplateProposal) o1).getRelevance(); | 66 return (cast(TemplateProposal) o2).getRelevance() - (cast(TemplateProposal) o1).getRelevance(); |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 private static final Comparator fgProposalComparator= new ProposalComparator(); | 70 private static final Comparator fgProposalComparator= new ProposalComparator(); |
71 | 71 |
73 * @see dwtx.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(dwtx.jface.text.ITextViewer, | 73 * @see dwtx.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(dwtx.jface.text.ITextViewer, |
74 * int) | 74 * int) |
75 */ | 75 */ |
76 public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { | 76 public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { |
77 | 77 |
78 ITextSelection selection= (ITextSelection) viewer.getSelectionProvider().getSelection(); | 78 ITextSelection selection= cast(ITextSelection) viewer.getSelectionProvider().getSelection(); |
79 | 79 |
80 // adjust offset to end of normalized selection | 80 // adjust offset to end of normalized selection |
81 if (selection.getOffset() is offset) | 81 if (selection.getOffset() is offset) |
82 offset= selection.getOffset() + selection.getLength(); | 82 offset= selection.getOffset() + selection.getLength(); |
83 | 83 |
98 context.getContextType().validate(template.getPattern()); | 98 context.getContextType().validate(template.getPattern()); |
99 } catch (TemplateException e) { | 99 } catch (TemplateException e) { |
100 continue; | 100 continue; |
101 } | 101 } |
102 if (template.matches(prefix, context.getContextType().getId())) | 102 if (template.matches(prefix, context.getContextType().getId())) |
103 matches.add(createProposal(template, context, (IRegion) region, getRelevance(template, prefix))); | 103 matches.add(createProposal(template, context, cast(IRegion) region, getRelevance(template, prefix))); |
104 } | 104 } |
105 | 105 |
106 Collections.sort(matches, fgProposalComparator); | 106 Collections.sort(matches, fgProposalComparator); |
107 | 107 |
108 return (ICompletionProposal[]) matches.toArray(new ICompletionProposal[matches.size()]); | 108 return (ICompletionProposal[]) matches.toArray(new ICompletionProposal[matches.size()]); |
123 * <code>template</code> | 123 * <code>template</code> |
124 * @deprecated use the version specifying <code>IRegion</code> as third parameter | 124 * @deprecated use the version specifying <code>IRegion</code> as third parameter |
125 * @since 3.1 | 125 * @since 3.1 |
126 */ | 126 */ |
127 protected ICompletionProposal createProposal(Template template, TemplateContext context, Region region, int relevance) { | 127 protected ICompletionProposal createProposal(Template template, TemplateContext context, Region region, int relevance) { |
128 return createProposal(template, context, (IRegion) region, relevance); | 128 return createProposal(template, context, cast(IRegion) region, relevance); |
129 } | 129 } |
130 | 130 |
131 /** | 131 /** |
132 * Creates a new proposal. | 132 * Creates a new proposal. |
133 * <p> | 133 * <p> |