Changeset 4067 for devel-tools
- Timestamp:
- Feb 5, 2009, 3:49:17 PM (12 years ago)
- Location:
- devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/editor/BracketMatcher.java
r3508 r4067 1 /**2 *3 */4 1 package org.refal.rfpdt.editor; 5 2 … … 12 9 public class BracketMatcher implements ICharacterPairMatcher { 13 10 private int fAnchor = -1; 11 12 public static boolean isBracket (IDocument doc, int offset) { 13 if (doc == null || offset < 0 || offset > doc.getLength()) 14 return false; 15 try { 16 offset = Math.max(offset - 1, 0); 17 char prevChar = doc.getChar(offset); 18 return Document.isOpen(prevChar) || Document.isClose(prevChar); 19 } catch (BadLocationException ble) { 20 return false; 21 } 22 } 14 23 15 24 public IRegion match (IDocument doc, int offset) { … … 43 52 fAnchor = -1; 44 53 } 45 46 54 } -
devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/editor/RfpEditorMessages.java
r3861 r4067 22 22 } 23 23 24 public static String GotoMatchingBracket _error_invalidSelection;25 public static String GotoMatchingBracket _error_noMatchingBracket;24 public static String GotoMatchingBracketAction_error_invalidSelection; 25 public static String GotoMatchingBracketAction_error_noMatchingBracket; 26 26 27 public static String OpenDeclaration _error_invalidSelection;27 public static String OpenDeclarationAction_error_invalidSelection; 28 28 } -
devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/editor/RfpEditorMessages.properties
r3861 r4067 1 GotoMatchingBracket _error_invalidSelection = No bracket selected2 GotoMatchingBracket _error_noMatchingBracket = No matching bracket found1 GotoMatchingBracketAction_error_invalidSelection = No bracket selected 2 GotoMatchingBracketAction_error_noMatchingBracket = No matching bracket found 3 3 4 OpenDeclaration _error_invalidSelection = Current selection doesn't resolve to Refal element4 OpenDeclarationAction_error_invalidSelection = Current selection doesn't resolve to Refal element -
devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/ui/actions/GotoMatchingBracketAction.java
r3861 r4067 6 6 import org.eclipse.jface.text.source.ISourceViewer; 7 7 import org.eclipse.swt.custom.StyledText; 8 import org.refal.rfpdt.editor.BracketMatcher; 8 9 import org.refal.rfpdt.editor.RfpEditorMessages; 9 10 10 11 public class GotoMatchingBracketAction extends RfpEditorActionDelegate { 11 12 public void run () { 12 /* 13 * TODO: Keep (extend and shrink as necessary) current selection while jumping to matching bracket. 14 */ 13 // TODO: Keep (extend and shrink as necessary) current selection while jumping to matching bracket. 15 14 ISourceViewer sourceViewer = editor.sourceViewer(); 16 15 IDocument document = sourceViewer.getDocument(); … … 18 17 return; 19 18 StyledText text = sourceViewer.getTextWidget(); 20 IRegion region = editor.getBracketMatcher().match(document, editor.widgetOffset2ModelOffset(text.getCaretOffset())); 21 if (region == null) { // FIXME: sometimes another error is needed (GotoMatchingBracket_error_invalidSelection) 22 editor.statusLineErrorMessage(RfpEditorMessages.GotoMatchingBracket_error_noMatchingBracket); 19 int modelOffset = editor.widgetOffset2ModelOffset(text.getCaretOffset()); 20 if (!BracketMatcher.isBracket(document, modelOffset)) { 21 editor.statusLineErrorMessage(RfpEditorMessages.GotoMatchingBracketAction_error_invalidSelection); 22 text.getDisplay().beep(); 23 return; 24 } 25 IRegion region = editor.getBracketMatcher().match(document, modelOffset); 26 if (region == null) { 27 editor.statusLineErrorMessage(RfpEditorMessages.GotoMatchingBracketAction_error_noMatchingBracket); 23 28 text.getDisplay().beep(); 24 29 return; -
devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/ui/actions/OpenDeclarationAction.java
r3863 r4067 17 17 AstNode astNode = editor.astInfo.getDeclaration(getSelection().getOffset()); 18 18 if (astNode == null) { 19 editor.statusLineErrorMessage(RfpEditorMessages.OpenDeclaration _error_invalidSelection);19 editor.statusLineErrorMessage(RfpEditorMessages.OpenDeclarationAction_error_invalidSelection); 20 20 sourceViewer.getTextWidget().getDisplay().beep(); 21 21 return;
Note: See TracChangeset
for help on using the changeset viewer.