1 19 20 package org.netbeans.modules.editor.errorstripe; 21 import java.util.HashMap ; 22 import java.util.Map ; 23 import javax.swing.text.BadLocationException ; 24 import javax.swing.text.Position ; 25 import junit.framework.*; 26 import org.netbeans.editor.AnnotationDesc; 27 import org.netbeans.editor.AnnotationType; 28 import org.netbeans.editor.AnnotationType.Severity; 29 import org.netbeans.editor.AnnotationTypes; 30 import org.netbeans.editor.AnnotationTypes.Loader; 31 import org.netbeans.editor.BaseDocument; 32 import org.netbeans.editor.Utilities; 33 34 35 39 public class AnnotationTestUtilities extends TestCase { 40 41 static final String NAME_TEST_ANNOTATION_DESC1 = "test-annotation-1"; 42 static final String NAME_TEST_ANNOTATION_DESC2 = "test-annotation-2"; 43 44 static final String SD_TEST_ANNOTATION_DESC1 = "Test1"; 45 static final String SD_TEST_ANNOTATION_DESC2 = "Test2"; 46 47 48 static class TestAnnotationDesc1 extends AnnotationDesc { 49 50 private BaseDocument doc; 51 private Position position; 52 53 public TestAnnotationDesc1(BaseDocument bd, Position position) { 54 super(position.getOffset(), -1); 55 this.doc = bd; 56 this.position = position; 57 } 58 59 public String getShortDescription() { 60 return SD_TEST_ANNOTATION_DESC1; 61 } 62 63 public String getAnnotationType() { 64 return NAME_TEST_ANNOTATION_DESC1; 65 } 66 67 public int getOffset() { 68 return position.getOffset(); 69 } 70 71 public int getLine() { 72 try { 73 return Utilities.getLineOffset(doc, getOffset()); 74 } catch (BadLocationException e) { 75 IllegalStateException exc = new IllegalStateException (); 76 77 exc.initCause(e); 78 79 throw exc; 80 } 81 } 82 83 } 84 85 static class TestAnnotationDesc2 extends AnnotationDesc { 86 87 private BaseDocument doc; 88 private Position position; 89 90 public TestAnnotationDesc2(BaseDocument bd, Position position) { 91 super(position.getOffset(), -1); 92 this.doc = bd; 93 this.position = position; 94 } 95 96 public String getShortDescription() { 97 return SD_TEST_ANNOTATION_DESC2; 98 } 99 100 public String getAnnotationType() { 101 return NAME_TEST_ANNOTATION_DESC2; 102 } 103 104 public int getOffset() { 105 return position.getOffset(); 106 } 107 108 public int getLine() { 109 try { 110 return Utilities.getLineOffset(doc, getOffset()); 111 } catch (BadLocationException e) { 112 IllegalStateException exc = new IllegalStateException (); 113 114 exc.initCause(e); 115 116 throw exc; 117 } 118 } 119 120 } 121 122 } 123 | Popular Tags |