Changeset 3382 for devel-tools/trunk
- Timestamp:
- Feb 6, 2008, 6:09:19 PM (13 years ago)
- Location:
- devel-tools/trunk/eclipse/org.refal.plus.rfpdt.editor/src/org/refal/plus/rfpdt/editor
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
devel-tools/trunk/eclipse/org.refal.plus.rfpdt.editor/src/org/refal/plus/rfpdt/editor/PresentationVisitor.java
r3365 r3382 8 8 import org.eclipse.swt.SWT; 9 9 import org.eclipse.swt.custom.StyleRange; 10 import org.refal.plus.rfpdt.comp.RfpResource; 10 11 import org.refal.plus.rfpdt.comp.SrcPosition; 11 12 import org.refal.plus.rfpdt.comp.ast.AstAlt; … … 52 53 public class PresentationVisitor implements ProgramVisitor, SentenceVisitor, ExpVisitor { 53 54 public static class StylePosition extends Position { 54 private final TextAttribute textAttribute; 55 56 public StylePosition (SrcPosition pos, TextAttribute textAttribute) { 55 private final String key; 56 private TextAttribute textAttribute = null; 57 58 public StylePosition (SrcPosition pos, String key) { 57 59 super(pos.charStart, pos.charEnd - pos.charStart); 58 this. textAttribute = textAttribute;60 this.key = key; 59 61 } 60 62 63 public void updateStyleRange (IPreferenceStore store) { 64 textAttribute = ColorScanner.getTextAttribute(store, key); 65 } 66 61 67 public StyleRange getStyleRange () { 62 StyleRange range = new StyleRange(offset, length, textAttribute.getForeground(), textAttribute 63 .getBackground()); 68 StyleRange styleRange = new StyleRange(offset, length, textAttribute.getForeground(), textAttribute.getBackground()); 64 69 int style = textAttribute.getStyle(); 65 range.fontStyle = style & (SWT.BOLD | SWT.ITALIC);66 range.strikeout = (style & TextAttribute.STRIKETHROUGH) == TextAttribute.STRIKETHROUGH;67 range.underline = (style & TextAttribute.UNDERLINE) == TextAttribute.STRIKETHROUGH;68 return range;70 styleRange.fontStyle = style & (SWT.BOLD | SWT.ITALIC); 71 styleRange.strikeout = (style & TextAttribute.STRIKETHROUGH) == TextAttribute.STRIKETHROUGH; 72 styleRange.underline = (style & TextAttribute.UNDERLINE) == TextAttribute.STRIKETHROUGH; 73 return styleRange; 69 74 } 70 75 } 71 76 72 public static StylePosition[] updateTextPresentation (AstImplem astImplem , IPreferenceStore store) {73 PresentationVisitor presentationVisitor = new PresentationVisitor( store);77 public static StylePosition[] updateTextPresentation (AstImplem astImplem) { 78 PresentationVisitor presentationVisitor = new PresentationVisitor(astImplem.pos.rfpResource); 74 79 astImplem.accept(presentationVisitor); 75 80 return presentationVisitor.styleRangeList.toArray(new StylePosition[presentationVisitor.styleRangeList.size()]); … … 77 82 78 83 private final ArrayList<StylePosition> styleRangeList; 79 private final IPreferenceStore store;80 81 private void addAstNameSty pe (AstNode name, String key) {82 if ( name == null || name.pos.rfpResource.isInterface) // TODO - must be RfpResource84 private final RfpResource rfpResource; 85 86 private void addAstNameStyle (AstNode name, String key) { 87 if (! rfpResource.equals(name.pos.rfpResource)) 83 88 return; 84 styleRangeList.add(new StylePosition(name.pos, ColorScanner.getTextAttribute(store, key)));85 } 86 87 private PresentationVisitor ( IPreferenceStore store) {89 styleRangeList.add(new StylePosition(name.pos, key)); 90 } 91 92 private PresentationVisitor (RfpResource rfpResource) { 88 93 this.styleRangeList = new ArrayList<StylePosition>(); 89 this. store = store;94 this.rfpResource = rfpResource; 90 95 } 91 96 92 97 private void visitObjectDefinition (AstName name) { 93 addAstNameStype(name, IColorPreferences.IDENTIFIER_DEFINITION); 98 if (name != null) 99 addAstNameStyle(name, IColorPreferences.IDENTIFIER_DEFINITION); 94 100 } 95 101 96 102 private void visitObjectUse (AstName name) { 97 103 if (name != null && name.identifier.length() < name.pos.charEnd - name.pos.charStart) 98 addAstNameSty pe(name, IColorPreferences.IDENTIFIER_USE);104 addAstNameStyle(name, IColorPreferences.IDENTIFIER_USE); 99 105 } 100 106 101 107 private void visitVariableDefinition (AstName name) { 102 addAstNameStype(name, IColorPreferences.VARIABLE_DEFINITION); 108 if (name != null) 109 addAstNameStyle(name, IColorPreferences.VARIABLE_DEFINITION); 103 110 } 104 111 105 112 private void visitVariableUse (AstName name) { 106 113 // addAstNameStype(name, IColorPreferences.VARIABLE_USE); 107 114 } 108 115 109 116 private void visitSymbol (AstWordSymbol astWordSymbol) { 110 117 if (astWordSymbol.word.length() == astWordSymbol.pos.charEnd - astWordSymbol.pos.charStart) 111 addAstNameSty pe(astWordSymbol, IColorPreferences.SYMBOL);118 addAstNameStyle(astWordSymbol, IColorPreferences.SYMBOL); 112 119 } 113 120 -
devel-tools/trunk/eclipse/org.refal.plus.rfpdt.editor/src/org/refal/plus/rfpdt/editor/RfpEditor.java
r3372 r3382 145 145 private IPropertyChangeListener propertyChangeListener; 146 146 private RfpSourceViewerConfiguration rfpSourceViewerConfiguration; 147 private IPreferenceStore store; 147 148 148 149 RfpReconcilingStrategy rfpReconcilingStrategy = null; … … 167 168 stores.add(RfpEditorPlugin.getPluginPreferenceStore()); 168 169 stores.add(EditorsUI.getPreferenceStore()); 169 IPreferenceStorestore = new ChainedPreferenceStore(stores.toArray(new IPreferenceStore[stores.size()]));170 store = new ChainedPreferenceStore(stores.toArray(new IPreferenceStore[stores.size()])); 170 171 setPreferenceStore(store); 171 172 … … 177 178 propertyChangeListener = new IPropertyChangeListener() { 178 179 public void propertyChange (PropertyChangeEvent event) { 180 for (StylePosition position : stylePositionList) 181 position.updateStyleRange(store); 179 182 redrawTextAsync(); 180 183 } … … 187 190 public void changeTextPresentation (IDocument document, StylePosition[] stylePositionList) { 188 191 if (this.stylePositionList != null) 189 for (Position position : stylePositionList)192 for (Position position : this.stylePositionList) 190 193 document.removePosition(position); 194 for (StylePosition position : stylePositionList) 195 position.updateStyleRange(store); 191 196 this.stylePositionList = stylePositionList; 192 197 if (this.stylePositionList != null) 193 for ( Position position :stylePositionList)198 for (StylePosition position : this.stylePositionList) 194 199 try { 195 200 document.addPosition(position); -
devel-tools/trunk/eclipse/org.refal.plus.rfpdt.editor/src/org/refal/plus/rfpdt/editor/RfpReconcilingStrategy.java
r3380 r3382 2 2 3 3 import org.eclipse.core.resources.IFile; 4 import org.eclipse.jface.preference.IPreferenceStore;5 4 import org.eclipse.jface.text.DocumentEvent; 6 5 import org.eclipse.jface.text.IDocument; … … 14 13 public class RfpReconcilingStrategy implements IReconcilingStrategy, IDocumentListener { 15 14 private final RfpEditor editor; 16 private final IPreferenceStore store;17 15 private IDocument document = null; 18 16 private AstImplem astImplem = null; … … 29 27 } 30 28 31 public RfpReconcilingStrategy (RfpEditor editor , IPreferenceStore store) {29 public RfpReconcilingStrategy (RfpEditor editor) { 32 30 this.editor = editor; 33 this.store = store;34 31 editor.rfpReconcilingStrategy = this; 35 32 } … … 44 41 updateAstImplem(); 45 42 if (astImplem != null) 46 editor.changeTextPresentation(document, PresentationVisitor.updateTextPresentation(astImplem , store));43 editor.changeTextPresentation(document, PresentationVisitor.updateTextPresentation(astImplem)); 47 44 } 48 45 -
devel-tools/trunk/eclipse/org.refal.plus.rfpdt.editor/src/org/refal/plus/rfpdt/editor/RfpSourceViewerConfiguration.java
r3381 r3382 81 81 public IReconciler getReconciler (ISourceViewer sourceViewer) { 82 82 if (editor != null && editor.isEditable()) 83 return new MonoReconciler(new RfpReconcilingStrategy(editor , fPreferenceStore), false);83 return new MonoReconciler(new RfpReconcilingStrategy(editor), false); 84 84 return null; 85 85 }
Note: See TracChangeset
for help on using the changeset viewer.