Lines 44-49
Link Here
|
44 |
import org.netbeans.spi.editor.highlighting.support.OffsetsBag; |
44 |
import org.netbeans.spi.editor.highlighting.support.OffsetsBag; |
45 |
|
45 |
|
46 |
import org.netbeans.api.editor.mimelookup.test.MockMimeLookup; |
46 |
import org.netbeans.api.editor.mimelookup.test.MockMimeLookup; |
|
|
47 |
import org.netbeans.spi.editor.bracesmatching.support.BracesMatcherSupport; |
47 |
import org.netbeans.spi.editor.highlighting.HighlightsSequence; |
48 |
import org.netbeans.spi.editor.highlighting.HighlightsSequence; |
48 |
|
49 |
|
49 |
/** |
50 |
/** |
Lines 107-112
Link Here
|
107 |
} |
108 |
} |
108 |
} |
109 |
} |
109 |
|
110 |
|
|
|
111 |
public void testIgnoreWithinText() throws Exception { |
112 |
JEditorPane c = new JEditorPane(); |
113 |
Document d = c.getDocument(); |
114 |
MockServices.setServices(MockMimeLookup.class); |
115 |
MockMimeLookup.setInstances(MimePath.EMPTY, new BracesMatcherFactory() { |
116 |
|
117 |
@Override |
118 |
public BracesMatcher createMatcher(MatcherContext context) { |
119 |
return BracesMatcherSupport.defaultMatcher(context, 0, Integer.MAX_VALUE); |
120 |
} |
121 |
}); |
122 |
|
123 |
AttributeSet EAS = SimpleAttributeSet.EMPTY; |
124 |
c.putClientProperty(MasterMatcher.PROP_MAX_BACKWARD_LOOKAHEAD, 256); |
125 |
c.putClientProperty(MasterMatcher.PROP_MAX_FORWARD_LOOKAHEAD, 256); |
126 |
OffsetsBag bag = new OffsetsBag(d); |
127 |
|
128 |
d.insertString(0, "text text { text } text", null); |
129 |
MasterMatcher.get(c).highlight(d, 0, bag, EAS, EAS, EAS, EAS); |
130 |
Thread.sleep(300); |
131 |
{ |
132 |
HighlightsSequence hs = bag.getHighlights(0, Integer.MAX_VALUE); |
133 |
assertTrue("Wrong number of highlighted areas", hs.moveNext()); |
134 |
} |
135 |
|
136 |
c.setText(null); |
137 |
d.insertString(0, "text text text text", null); |
138 |
MasterMatcher.get(c).highlight(d, 0, bag, EAS, EAS, EAS, EAS); |
139 |
Thread.sleep(300); |
140 |
{ |
141 |
HighlightsSequence hs = bag.getHighlights(0, Integer.MAX_VALUE); |
142 |
assertFalse("Wrong number of highlighted areas", hs.moveNext()); |
143 |
} |
144 |
|
145 |
c.setText(null); |
146 |
d.insertString(0, "text text { \"text }\" }text", null); |
147 |
MasterMatcher.get(c).highlight(d, 17, bag, EAS, EAS, EAS, EAS); |
148 |
Thread.sleep(300); |
149 |
{ |
150 |
HighlightsSequence hs = bag.getHighlights(17, Integer.MAX_VALUE); |
151 |
assertFalse("Wrong number of highlighted areas", hs.moveNext()); |
152 |
} |
153 |
} |
154 |
|
110 |
public void testAreas() throws Exception { |
155 |
public void testAreas() throws Exception { |
111 |
MockServices.setServices(MockMimeLookup.class); |
156 |
MockServices.setServices(MockMimeLookup.class); |
112 |
MockMimeLookup.setInstances(MimePath.EMPTY, new TestMatcher()); |
157 |
MockMimeLookup.setInstances(MimePath.EMPTY, new TestMatcher()); |