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 |
} |