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 251531
Collapse All | Expand All

(-)a/php.dbgp/nbproject/project.xml (-1 / +1 lines)
Lines 159-165 Link Here
159
                    <compile-dependency/>
159
                    <compile-dependency/>
160
                    <run-dependency>
160
                    <run-dependency>
161
                        <release-version>1</release-version>
161
                        <release-version>1</release-version>
162
                        <specification-version>2.13</specification-version>
162
                        <specification-version>2.50</specification-version>
163
                    </run-dependency>
163
                    </run-dependency>
164
                </dependency>
164
                </dependency>
165
                <dependency>
165
                <dependency>
(-)a/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/Utils.java (-52 / +2 lines)
Lines 43-60 Link Here
43
 */
43
 */
44
package org.netbeans.modules.php.dbgp.breakpoints;
44
package org.netbeans.modules.php.dbgp.breakpoints;
45
45
46
import java.util.List;
47
import java.util.Set;
46
import java.util.Set;
48
import java.util.logging.Level;
47
import java.util.logging.Level;
49
import java.util.logging.Logger;
48
import java.util.logging.Logger;
50
import javax.swing.text.AbstractDocument;
51
import javax.swing.text.Document;
52
import javax.swing.text.StyledDocument;
53
import org.netbeans.api.debugger.Breakpoint;
49
import org.netbeans.api.debugger.Breakpoint;
54
import org.netbeans.api.debugger.DebuggerManager;
50
import org.netbeans.api.debugger.DebuggerManager;
55
import org.netbeans.api.lexer.LanguagePath;
56
import org.netbeans.api.lexer.TokenHierarchy;
57
import org.netbeans.api.lexer.TokenSequence;
58
import org.netbeans.api.options.OptionsDisplayer;
51
import org.netbeans.api.options.OptionsDisplayer;
59
import org.netbeans.modules.php.dbgp.DebugSession;
52
import org.netbeans.modules.php.dbgp.DebugSession;
60
import org.netbeans.modules.php.dbgp.SessionId;
53
import org.netbeans.modules.php.dbgp.SessionId;
Lines 64-76 Link Here
64
import org.netbeans.modules.php.dbgp.packets.BrkpntSetCommand;
57
import org.netbeans.modules.php.dbgp.packets.BrkpntSetCommand;
65
import org.netbeans.modules.php.dbgp.packets.BrkpntSetCommand.State;
58
import org.netbeans.modules.php.dbgp.packets.BrkpntSetCommand.State;
66
import org.netbeans.spi.debugger.ui.EditorContextDispatcher;
59
import org.netbeans.spi.debugger.ui.EditorContextDispatcher;
67
import org.openide.cookies.EditorCookie;
68
import org.openide.cookies.LineCookie;
60
import org.openide.cookies.LineCookie;
69
import org.openide.filesystems.FileObject;
61
import org.openide.filesystems.FileObject;
70
import org.openide.loaders.DataObject;
62
import org.openide.loaders.DataObject;
71
import org.openide.loaders.DataObjectNotFoundException;
63
import org.openide.loaders.DataObjectNotFoundException;
72
import org.openide.text.Line;
64
import org.openide.text.Line;
73
import org.openide.text.NbDocument;
74
65
75
/**
66
/**
76
 * @author ads
67
 * @author ads
Lines 217-265 Link Here
217
        if (!isPhpFile(fo)) {
208
        if (!isPhpFile(fo)) {
218
            return false;
209
            return false;
219
        }
210
        }
220
        EditorCookie editorCookie = line.getLookup().lookup(EditorCookie.class);
211
        Set<String> mimeTypesOnLine = EditorContextDispatcher.getDefault().getMIMETypesOnLine(line);
221
        StyledDocument document = editorCookie.getDocument();
212
        return mimeTypesOnLine.contains(MIME_TYPE);
222
        Boolean isPhp = null;
223
        ((AbstractDocument) document).readLock();
224
        try {
225
            TokenHierarchy<Document> th = TokenHierarchy.get((Document) document);
226
            int ln = line.getLineNumber();
227
            int offset = NbDocument.findLineOffset(document, ln);
228
            int maxOffset = document.getLength() - 1;
229
            int maxLine = NbDocument.findLineNumber(document, maxOffset);
230
            int offset2;
231
            if (ln + 1 > maxLine) {
232
                offset2 = maxOffset;
233
            } else {
234
                offset2 = NbDocument.findLineOffset(document, ln+1) - 1;
235
            }
236
            // The line has offsets <offset, offset2>
237
            Set<LanguagePath> languagePaths = th.languagePaths();
238
            for (LanguagePath lp : languagePaths) {
239
                List<TokenSequence<?>> tsl = th.tokenSequenceList(lp, offset, offset2);
240
                for (TokenSequence ts : tsl) {
241
                    if (ts.moveNext()) {
242
                        //int to = ts.offset();
243
                        //if (!(offset <= to && to < offset2)) {
244
                        //    continue;
245
                        //}
246
                        TokenSequence ets;
247
                        ets = ts.embedded();
248
                        if (ets != null) {
249
                            ts = ets;
250
                        }
251
                        String mimeType = ts.language().mimeType();
252
                        if (isPhp == null && MIME_TYPE.equals(mimeType)) {
253
                            isPhp = true;
254
                            break;
255
                        }
256
                    }
257
                }
258
            }
259
        } finally {
260
            ((AbstractDocument) document).readUnlock();
261
        }
262
        return isPhp != null && isPhp;
263
    }
213
    }
264
214
265
}
215
}
(-)a/spi.debugger.ui/apichanges.xml (+19 lines)
Lines 229-234 Link Here
229
        <issue number="248626"/>
229
        <issue number="248626"/>
230
    </change>
230
    </change>
231
231
232
    <change id="GetMIMETypesOnLine">
233
        <api name="DebuggerCoreSPI"/>
234
        <summary>A method for retrieving a set of language MIME types on a line in a document is added.</summary>
235
        <version major="2" minor="50"/>
236
        <date day="31" month="03" year="2015"/>
237
        <author login="mentlicher"/>
238
        <compatibility binary="compatible" source="compatible" addition="yes" semantic="compatible"/>
239
        <description>
240
            <p>
241
                Methods <code>getMIMETypesOnCurrentLine()</code> and
242
                <code>getMIMETypesOnLine()</code> added to
243
                <code>EditorContextDispatcher</code> class. They provide a set of
244
                MIME types of languages found on the line.
245
            </p>
246
        </description>
247
        <class package="org.netbeans.spi.debugger.ui" name="EditorContextDispatcher"/>
248
        <issue number="251531"/>
249
    </change>
250
232
</changes>
251
</changes>
233
252
234
  <!-- Now the surrounding HTML text and document structure: -->
253
  <!-- Now the surrounding HTML text and document structure: -->
(-)a/spi.debugger.ui/manifest.mf (-1 / +1 lines)
Lines 2-7 Link Here
2
OpenIDE-Module: org.netbeans.spi.debugger.ui/1
2
OpenIDE-Module: org.netbeans.spi.debugger.ui/1
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/debugger/ui/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/debugger/ui/Bundle.properties
4
OpenIDE-Module-Layer: org/netbeans/modules/debugger/resources/mf-layer.xml
4
OpenIDE-Module-Layer: org/netbeans/modules/debugger/resources/mf-layer.xml
5
OpenIDE-Module-Specification-Version: 2.49
5
OpenIDE-Module-Specification-Version: 2.50
6
OpenIDE-Module-Provides: org.netbeans.spi.debugger.ui
6
OpenIDE-Module-Provides: org.netbeans.spi.debugger.ui
7
OpenIDE-Module-Install: org/netbeans/modules/debugger/ui/DebuggerModule.class
7
OpenIDE-Module-Install: org/netbeans/modules/debugger/ui/DebuggerModule.class
(-)a/spi.debugger.ui/src/org/netbeans/spi/debugger/ui/EditorContextDispatcher.java (-2 / +13 lines)
Lines 294-300 Link Here
294
        }
294
        }
295
    }
295
    }
296
    
296
    
297
    Set<String> getMIMETypesOnCurrentLine() {
297
    /**
298
     * Get a list of MIME types of languages found on the current line.
299
     * @return A set of MIME types.
300
     * @since 2.50
301
     */
302
    public Set<String> getMIMETypesOnCurrentLine() {
298
        Line line = getCurrentLine();
303
        Line line = getCurrentLine();
299
        if (line == null) {
304
        if (line == null) {
300
            return Collections.EMPTY_SET;
305
            return Collections.EMPTY_SET;
Lines 302-308 Link Here
302
        return getMIMETypesOnLine(line);
307
        return getMIMETypesOnLine(line);
303
    }
308
    }
304
    
309
    
305
    Set<String> getMIMETypesOnLine(Line line) {
310
    /**
311
     * Get a list of MIME types of languages found on the line.
312
     * @param line The line to search for the MIME types.
313
     * @return A set of MIME types.
314
     * @since 2.50
315
     */
316
    public Set<String> getMIMETypesOnLine(Line line) {
306
        EditorCookie editorCookie = line.getLookup().lookup(EditorCookie.class);
317
        EditorCookie editorCookie = line.getLookup().lookup(EditorCookie.class);
307
        StyledDocument document = editorCookie.getDocument();
318
        StyledDocument document = editorCookie.getDocument();
308
        Set<String> mimeTypes = null;
319
        Set<String> mimeTypes = null;

Return to bug 251531