comparison dwtx/jface/text/contentassist/CompletionProposalPopup.d @ 138:b6bad70d540a

Regex instanceof changes
author Frank Benoit <benoit@tionex.de>
date Sun, 24 Aug 2008 02:26:23 +0200
parents 6dcb0baaa031
children 26688fec6d23
comparison
equal deleted inserted replaced
137:25170b5a8951 138:b6bad70d540a
936 936
937 try { 937 try {
938 938
939 IDocument document= fContentAssistSubjectControlAdapter.getDocument(); 939 IDocument document= fContentAssistSubjectControlAdapter.getDocument();
940 940
941 if (fViewer instanceof ITextViewerExtension) { 941 if ( cast(ITextViewerExtension)fViewer ) {
942 ITextViewerExtension extension= cast(ITextViewerExtension) fViewer; 942 ITextViewerExtension extension= cast(ITextViewerExtension) fViewer;
943 target= extension.getRewriteTarget(); 943 target= extension.getRewriteTarget();
944 } 944 }
945 945
946 if (target !is null) 946 if (target !is null)
947 target.beginCompoundChange(); 947 target.beginCompoundChange();
948 948
949 if (fViewer instanceof IEditingSupportRegistry) { 949 if ( cast(IEditingSupportRegistry)fViewer ) {
950 IEditingSupportRegistry registry= cast(IEditingSupportRegistry) fViewer; 950 IEditingSupportRegistry registry= cast(IEditingSupportRegistry) fViewer;
951 registry.register(helper); 951 registry.register(helper);
952 } 952 }
953 953
954 954
955 if (p instanceof ICompletionProposalExtension2 && fViewer !is null) { 955 if (p instanceof ICompletionProposalExtension2 && fViewer !is null) {
956 ICompletionProposalExtension2 e= cast(ICompletionProposalExtension2) p; 956 ICompletionProposalExtension2 e= cast(ICompletionProposalExtension2) p;
957 e.apply(fViewer, trigger, stateMask, offset); 957 e.apply(fViewer, trigger, stateMask, offset);
958 } else if (p instanceof ICompletionProposalExtension) { 958 } else if ( cast(ICompletionProposalExtension)p ) {
959 ICompletionProposalExtension e= cast(ICompletionProposalExtension) p; 959 ICompletionProposalExtension e= cast(ICompletionProposalExtension) p;
960 e.apply(document, trigger, offset); 960 e.apply(document, trigger, offset);
961 } else { 961 } else {
962 p.apply(document); 962 p.apply(document);
963 } 963 }
970 970
971 IContextInformation info= p.getContextInformation(); 971 IContextInformation info= p.getContextInformation();
972 if (info !is null) { 972 if (info !is null) {
973 973
974 int contextInformationOffset; 974 int contextInformationOffset;
975 if (p instanceof ICompletionProposalExtension) { 975 if ( cast(ICompletionProposalExtension)p ) {
976 ICompletionProposalExtension e= cast(ICompletionProposalExtension) p; 976 ICompletionProposalExtension e= cast(ICompletionProposalExtension) p;
977 contextInformationOffset= e.getContextInformationPosition(); 977 contextInformationOffset= e.getContextInformationPosition();
978 } else { 978 } else {
979 if (selection is null) 979 if (selection is null)
980 selection= fContentAssistSubjectControlAdapter.getSelectedRange(); 980 selection= fContentAssistSubjectControlAdapter.getSelectedRange();
988 988
989 } finally { 989 } finally {
990 if (target !is null) 990 if (target !is null)
991 target.endCompoundChange(); 991 target.endCompoundChange();
992 992
993 if (fViewer instanceof IEditingSupportRegistry) { 993 if ( cast(IEditingSupportRegistry)fViewer ) {
994 IEditingSupportRegistry registry= cast(IEditingSupportRegistry) fViewer; 994 IEditingSupportRegistry registry= cast(IEditingSupportRegistry) fViewer;
995 registry.unregister(helper); 995 registry.unregister(helper);
996 } 996 }
997 fInserting= false; 997 fInserting= false;
998 } 998 }
1034 */ 1034 */
1035 public void hide() { 1035 public void hide() {
1036 1036
1037 unregister(); 1037 unregister();
1038 1038
1039 if (fViewer instanceof IEditingSupportRegistry) { 1039 if ( cast(IEditingSupportRegistry)fViewer ) {
1040 IEditingSupportRegistry registry= cast(IEditingSupportRegistry) fViewer; 1040 IEditingSupportRegistry registry= cast(IEditingSupportRegistry) fViewer;
1041 registry.unregister(fFocusHelper); 1041 registry.unregister(fFocusHelper);
1042 } 1042 }
1043 1043
1044 if (Helper.okToUse(fProposalShell)) { 1044 if (Helper.okToUse(fProposalShell)) {
1205 return true; 1205 return true;
1206 } 1206 }
1207 1207
1208 }; 1208 };
1209 } 1209 }
1210 if (fViewer instanceof IEditingSupportRegistry) { 1210 if ( cast(IEditingSupportRegistry)fViewer ) {
1211 IEditingSupportRegistry registry= cast(IEditingSupportRegistry) fViewer; 1211 IEditingSupportRegistry registry= cast(IEditingSupportRegistry) fViewer;
1212 registry.register(fFocusHelper); 1212 registry.register(fFocusHelper);
1213 } 1213 }
1214 1214
1215 1215
1340 fProposalShell.setFocus(); 1340 fProposalShell.setFocus();
1341 return false; 1341 return false;
1342 1342
1343 default: 1343 default:
1344 ICompletionProposal p= getSelectedProposal(); 1344 ICompletionProposal p= getSelectedProposal();
1345 if (p instanceof ICompletionProposalExtension) { 1345 if ( cast(ICompletionProposalExtension)p ) {
1346 ICompletionProposalExtension t= cast(ICompletionProposalExtension) p; 1346 ICompletionProposalExtension t= cast(ICompletionProposalExtension) p;
1347 char[] triggers= t.getTriggerCharacters(); 1347 char[] triggers= t.getTriggerCharacters();
1348 if (contains(triggers, key)) { 1348 if (contains(triggers, key)) {
1349 e.doit= false; 1349 e.doit= false;
1350 hide(); 1350 hide();
1528 * <code>false</code> otherwise 1528 * <code>false</code> otherwise
1529 * @since 3.1 1529 * @since 3.1
1530 */ 1530 */
1531 private bool canAutoInsert(ICompletionProposal proposal) { 1531 private bool canAutoInsert(ICompletionProposal proposal) {
1532 if (fContentAssistant.isAutoInserting()) { 1532 if (fContentAssistant.isAutoInserting()) {
1533 if (proposal instanceof ICompletionProposalExtension4) { 1533 if ( cast(ICompletionProposalExtension4)proposal ) {
1534 ICompletionProposalExtension4 ext= cast(ICompletionProposalExtension4) proposal; 1534 ICompletionProposalExtension4 ext= cast(ICompletionProposalExtension4) proposal;
1535 return ext.isAutoInsertable(); 1535 return ext.isAutoInsertable();
1536 } 1536 }
1537 return true; // default behavior before ICompletionProposalExtension4 was introduced 1537 return true; // default behavior before ICompletionProposalExtension4 was introduced
1538 } 1538 }
1635 List wrongCase= new ArrayList(); 1635 List wrongCase= new ArrayList();
1636 1636
1637 for (int i= 0; i < fFilteredProposals.length; i++) { 1637 for (int i= 0; i < fFilteredProposals.length; i++) {
1638 ICompletionProposal proposal= fFilteredProposals[i]; 1638 ICompletionProposal proposal= fFilteredProposals[i];
1639 1639
1640 if (!(proposal instanceof ICompletionProposalExtension3)) 1640 if (!( cast(ICompletionProposalExtension3)proposal ))
1641 return false; 1641 return false;
1642 1642
1643 int start= (cast(ICompletionProposalExtension3)proposal).getPrefixCompletionStart(fContentAssistSubjectControlAdapter.getDocument(), fFilterOffset); 1643 int start= (cast(ICompletionProposalExtension3)proposal).getPrefixCompletionStart(fContentAssistSubjectControlAdapter.getDocument(), fFilterOffset);
1644 CharSequence insertion= (cast(ICompletionProposalExtension3)proposal).getPrefixCompletionText(fContentAssistSubjectControlAdapter.getDocument(), fFilterOffset); 1644 CharSequence insertion= (cast(ICompletionProposalExtension3)proposal).getPrefixCompletionText(fContentAssistSubjectControlAdapter.getDocument(), fFilterOffset);
1645 if (insertion is null) 1645 if (insertion is null)