comparison dwtx/jface/text/templates/TemplateCompletionProcessor.d @ 162:1a5b8f8129df

...
author Frank Benoit <benoit@tionex.de>
date Mon, 08 Sep 2008 00:51:37 +0200
parents f70d9508c95c
children
comparison
equal deleted inserted replaced
161:f8d52b926852 162:1a5b8f8129df
65 public int compare(Object o1, Object o2) { 65 public int compare(Object o1, Object o2) {
66 return (cast(TemplateProposal) o2).getRelevance() - (cast(TemplateProposal) o1).getRelevance(); 66 return (cast(TemplateProposal) o2).getRelevance() - (cast(TemplateProposal) o1).getRelevance();
67 } 67 }
68 } 68 }
69 69
70 private static const Comparator fgProposalComparator= new ProposalComparator(); 70 private static Comparator fgProposalComparator_;
71 private static Comparator fgProposalComparator(){
72 if(fgProposalComparator_ is null ) {
73 synchronized( TemplateCompletionProcessor.classinfo ){
74 if(fgProposalComparator_ is null ) {
75 fgProposalComparator_ = new ProposalComparator();
76 }
77 }
78 }
79 return fgProposalComparator_;
80 }
71 81
72 /* 82 /*
73 * @see dwtx.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(dwtx.jface.text.ITextViewer, 83 * @see dwtx.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(dwtx.jface.text.ITextViewer,
74 * int) 84 * int)
75 */ 85 */
98 context.getContextType().validate(template_.getPattern()); 108 context.getContextType().validate(template_.getPattern());
99 } catch (TemplateException e) { 109 } catch (TemplateException e) {
100 continue; 110 continue;
101 } 111 }
102 if (template_.matches(prefix, context.getContextType().getId())) 112 if (template_.matches(prefix, context.getContextType().getId()))
103 matches.add(createProposal(template_, context, cast(IRegion) region, getRelevance(template_, prefix))); 113 matches.add( cast(Object) createProposal(template_, context, cast(IRegion) region, getRelevance(template_, prefix)));
104 } 114 }
105 115
106 Collections.sort(matches, fgProposalComparator); 116 Collections.sort(matches, fgProposalComparator);
107 117
108 return (ICompletionProposal[]) matches.toArray(new ICompletionProposal[matches.size()]); 118 return arraycast!(ICompletionProposal)( matches.toArray());
109 } 119 }
110 120
111 /** 121 /**
112 * Creates a new proposal. 122 * Creates a new proposal.
113 * <p> 123 * <p>