Changeset 1857
- Timestamp:
- 03/17/14 00:13:56 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/org.modelica.mdt.ui/src/org/modelica/mdt/ui/editor/ModelicaSourceViewerConfig.java
r1127 r1857 2 2 * @author Adrian Pop 3 3 * Copyright (c) 2006 Adrian Pop, adrpo@ida.liu.se 4 * All rights reserved. 4 * All rights reserved. 5 5 * Permission to use, copy, modify, and distribute this software and 6 * its documentation for NON-COMMERCIAL purposes and without fee is hereby 7 * granted, provided that this copyright notice appear in all copies and 6 * its documentation for NON-COMMERCIAL purposes and without fee is hereby 7 * granted, provided that this copyright notice appear in all copies and 8 8 * that both the copyright notice and this permission notice and warranty 9 9 * disclaimer appear in supporting documentation, and that the name of 10 10 * The Author not be used in advertising or publicity pertaining to 11 11 * distribution of the software without specific, written prior permission. 12 * 13 * COMMERCIAL use, copy, modification and distribution 12 * 13 * COMMERCIAL use, copy, modification and distribution 14 14 * is NOT permitted without prior agreement with Adrian Pop. 15 * 15 * 16 16 * THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 17 17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. … … 66 66 67 67 /** 68 * 68 * 69 69 * @author Adrian Pop 70 70 * - big changes, splited scanners for different partitions, etc 71 71 */ 72 public class ModelicaSourceViewerConfig extends TextSourceViewerConfiguration 73 { 72 public class ModelicaSourceViewerConfig extends TextSourceViewerConfiguration 73 { 74 74 private ModelicaCodeScanner fCodeScanner; /* for code parts and strings */ 75 75 private ModelicaMultilineCommentScanner fMultilineCommentScanner; /* for C comments */ 76 76 private ModelicaSinglelineCommentScanner fSinglelineCommentScanner; /* for single line comments */ 77 77 private ModelicaStringScanner fStringScanner; /* for strings and comment strings */ 78 78 79 79 private ITextEditor textEditor; 80 80 81 81 private String fDocumentPartitioning; 82 83 public ModelicaSourceViewerConfig(ITextEditor textEditor, String partitioning) 82 83 public ModelicaSourceViewerConfig(ITextEditor textEditor, String partitioning) 84 84 { 85 85 this.textEditor = textEditor; … … 87 87 } 88 88 89 protected ModelicaCodeScanner getCodeScanner() 90 { 91 if (fCodeScanner == null) 89 protected ModelicaCodeScanner getCodeScanner() 90 { 91 if (fCodeScanner == null) 92 92 { 93 93 fCodeScanner = new ModelicaCodeScanner(); … … 97 97 return fCodeScanner; 98 98 } 99 100 protected ModelicaMultilineCommentScanner getMultilineCommentScanner() 101 { 102 if (fMultilineCommentScanner == null) 99 100 protected ModelicaMultilineCommentScanner getMultilineCommentScanner() 101 { 102 if (fMultilineCommentScanner == null) 103 103 { 104 104 fMultilineCommentScanner = new ModelicaMultilineCommentScanner(); … … 109 109 } 110 110 111 protected ModelicaSinglelineCommentScanner getSinglelineCommentScanner() 112 { 113 if (fSinglelineCommentScanner == null) 111 protected ModelicaSinglelineCommentScanner getSinglelineCommentScanner() 112 { 113 if (fSinglelineCommentScanner == null) 114 114 { 115 115 fSinglelineCommentScanner = new ModelicaSinglelineCommentScanner(); … … 120 120 } 121 121 122 protected ModelicaStringScanner getStringScanner() 123 { 124 if (fStringScanner == null) 122 protected ModelicaStringScanner getStringScanner() 123 { 124 if (fStringScanner == null) 125 125 { 126 126 fStringScanner = new ModelicaStringScanner(); … … 130 130 return fStringScanner; 131 131 } 132 133 public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) 132 133 public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) 134 134 { 135 135 PresentationReconciler reconciler = new PresentationReconciler(); 136 136 137 137 reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer)); 138 138 139 139 DefaultDamagerRepairer drCode = new DefaultDamagerRepairer(getCodeScanner()); 140 140 reconciler.setDamager(drCode, IDocument.DEFAULT_CONTENT_TYPE); 141 141 reconciler.setRepairer(drCode, IDocument.DEFAULT_CONTENT_TYPE); 142 143 DefaultDamagerRepairer drMultilineComments = new DefaultDamagerRepairer(getMultilineCommentScanner()); 142 143 DefaultDamagerRepairer drMultilineComments = new DefaultDamagerRepairer(getMultilineCommentScanner()); 144 144 reconciler.setDamager(drMultilineComments, IModelicaPartitions.MODELICA_MULTI_LINE_COMMENT); 145 reconciler.setRepairer(drMultilineComments, IModelicaPartitions.MODELICA_MULTI_LINE_COMMENT); 146 147 DefaultDamagerRepairer drSingleComments = new DefaultDamagerRepairer(getSinglelineCommentScanner()); 145 reconciler.setRepairer(drMultilineComments, IModelicaPartitions.MODELICA_MULTI_LINE_COMMENT); 146 147 DefaultDamagerRepairer drSingleComments = new DefaultDamagerRepairer(getSinglelineCommentScanner()); 148 148 reconciler.setDamager(drSingleComments, IModelicaPartitions.MODELICA_SINGLE_LINE_COMMENT); 149 149 reconciler.setRepairer(drSingleComments, IModelicaPartitions.MODELICA_SINGLE_LINE_COMMENT); 150 150 151 151 DefaultDamagerRepairer drStrings = new DefaultDamagerRepairer(getStringScanner()); 152 152 reconciler.setDamager(drStrings, IModelicaPartitions.MODELICA_STRING); 153 reconciler.setRepairer(drStrings, IModelicaPartitions.MODELICA_STRING); 154 153 reconciler.setRepairer(drStrings, IModelicaPartitions.MODELICA_STRING); 154 155 155 return reconciler; 156 156 } 157 157 158 158 public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) 159 159 { 160 160 ContentAssistant assistant = new ContentAssistant(); 161 161 162 162 assistant.setContentAssistProcessor(new ModelicaCompletionProcessor(textEditor), IDocument.DEFAULT_CONTENT_TYPE); 163 163 DialogSettings s = new DialogSettings("completion_proposal_size"); 164 164 s.put(ContentAssistant.STORE_SIZE_X, "550"); 165 s.put(ContentAssistant.STORE_SIZE_Y, "280"); 165 s.put(ContentAssistant.STORE_SIZE_Y, "280"); 166 166 assistant.setRestoreCompletionProposalSize(s); 167 167 assistant.enableAutoActivation(true); … … 173 173 assistant.setInformationControlCreator(getInformationPresenterControlCreator(sourceViewer)); 174 174 assistant.setRepeatedInvocationMode(true); 175 175 assistant.enableAutoInsert(true); 176 176 177 177 return assistant; 178 178 } 179 179 180 180 //TODO Adrian Pop, please add the tab length to the Modelica Preferences page! 181 public int getTabWidth(ISourceViewer sourceViewer) 181 public int getTabWidth(ISourceViewer sourceViewer) 182 182 { 183 183 /* return the peter fritzson constant */ … … 205 205 return fDocumentPartitioning; 206 206 return super.getConfiguredDocumentPartitioning(sourceViewer); 207 } 207 } 208 208 209 209 public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) { … … 223 223 } 224 224 225 226 public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) 227 { 228 225 226 public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) 227 { 228 229 229 if (contentType.equals(IDocument.DEFAULT_CONTENT_TYPE)) 230 230 { … … 235 235 else return super.getTextHover(sourceViewer, contentType); 236 236 } 237 237 238 238 public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) { 239 239 return getTextHover(sourceViewer, contentType, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK); 240 240 } 241 242 241 242 243 243 /** 244 244 * Returns the information presenter control creator. The creator is a factory creating the … … 259 259 }; 260 260 } 261 262 261 262 263 263 /* 264 264 * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer) 265 265 * @since 2.0 266 266 */ 267 public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) 267 public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) 268 268 { 269 269 InformationPresenter presenter= new InformationPresenter(getInformationPresenterControlCreator(sourceViewer)); … … 276 276 return presenter; 277 277 } 278 278 279 279 /* 280 280 * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer) … … 282 282 public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) { 283 283 return new ModelicaAnnotationHover() { 284 protected boolean isIncluded(Annotation annotation) 284 protected boolean isIncluded(Annotation annotation) 285 285 { 286 286 return isShowInVerticalRuler(annotation); 287 } 287 } 288 288 }; 289 289 } … … 295 295 public IAnnotationHover getOverviewRulerAnnotationHover(ISourceViewer sourceViewer) { 296 296 return new ModelicaAnnotationHover() { 297 protected boolean isIncluded(Annotation annotation) 297 protected boolean isIncluded(Annotation annotation) 298 298 { 299 299 return isShowInOverviewRuler(annotation); … … 331 331 { 332 332 return null; 333 } 334 333 } 334 335 335 }
Note: See TracChangeset
for help on using the changeset viewer.