This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 134448
Collapse All | Expand All

(-)a/editor.bracesmatching/nbproject/project.xml (+4 lines)
Lines 105-110 Link Here
105
                <test-type>
105
                <test-type>
106
                    <name>unit</name>
106
                    <name>unit</name>
107
                    <test-dependency>
107
                    <test-dependency>
108
                        <code-name-base>org.netbeans.insane</code-name-base>
109
                        <compile-dependency/>
110
                    </test-dependency>
111
                    <test-dependency>
108
                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
112
                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
109
                        <compile-dependency/>
113
                        <compile-dependency/>
110
                    </test-dependency>
114
                    </test-dependency>
(-)a/editor.bracesmatching/src/org/netbeans/spi/editor/bracesmatching/support/BracesMatcherSupport.java (+6 lines)
Lines 276-281 Link Here
276
                if (MatcherContext.isTaskCanceled()) {
276
                if (MatcherContext.isTaskCanceled()) {
277
                    return -1;
277
                    return -1;
278
                }
278
                }
279
                if (text.array[text.offset + i] == '"') {
280
                    return -1;
281
                }
279
                if (origin == text.array[text.offset + i]) {
282
                if (origin == text.array[text.offset + i]) {
280
                    count++;
283
                    count++;
281
                } else if (matching == text.array[text.offset + i]) {
284
                } else if (matching == text.array[text.offset + i]) {
Lines 296-301 Link Here
296
                if (MatcherContext.isTaskCanceled()) {
299
                if (MatcherContext.isTaskCanceled()) {
297
                    return -1;
300
                    return -1;
298
                }
301
                }
302
                if (text.array[text.offset + i] == '"') {
303
                    return -1;
304
                }
299
                if (origin == text.array[text.offset + i]) {
305
                if (origin == text.array[text.offset + i]) {
300
                    count++;
306
                    count++;
301
                } else if (matching == text.array[text.offset + i]) {
307
                } else if (matching == text.array[text.offset + i]) {
(-)a/editor.bracesmatching/test/unit/src/org/netbeans/modules/editor/bracesmatching/MasterMatcherTest.java (+45 lines)
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());

Return to bug 134448