Lines 42-48
Link Here
|
42 |
|
42 |
|
43 |
import java.net.URL; |
43 |
import java.net.URL; |
44 |
import java.net.MalformedURLException; |
44 |
import java.net.MalformedURLException; |
45 |
import java.util.List; |
|
|
46 |
import javax.swing.text.Document; |
45 |
import javax.swing.text.Document; |
47 |
import javax.swing.text.StyledDocument; |
46 |
import javax.swing.text.StyledDocument; |
48 |
import org.openide.filesystems.FileStateInvalidException; |
47 |
import org.openide.filesystems.FileStateInvalidException; |
Lines 127-140
Link Here
|
127 |
LineCookie lineCookie = getCurrentLineCookie (); |
126 |
LineCookie lineCookie = getCurrentLineCookie (); |
128 |
Line.Set lineSet = lineCookie.getLineSet (); |
127 |
Line.Set lineSet = lineCookie.getLineSet (); |
129 |
try { |
128 |
try { |
130 |
//ln = 2 * ln - lineSet.getOriginal (ln).getLineNumber (); |
129 |
ln = 2 * ln - lineSet.getOriginal (ln).getLineNumber (); |
131 |
List l = lineSet.getLines (); |
|
|
132 |
int i, k = l.size (); |
133 |
for (i = 0; i < k; i++) { |
134 |
if (((Line) l.get (i)).getLineNumber () >= ln) { |
135 |
return i + 1; |
136 |
} |
137 |
} |
138 |
return ln + 1; |
130 |
return ln + 1; |
139 |
} catch (IndexOutOfBoundsException ex) { |
131 |
} catch (IndexOutOfBoundsException ex) { |
140 |
ex.printStackTrace (); |
132 |
ex.printStackTrace (); |
Lines 237-252
Link Here
|
237 |
*/ |
229 |
*/ |
238 |
public String getSelectedMethodName () { |
230 |
public String getSelectedMethodName () { |
239 |
EditorCookie e = getCurrentEditorCookie (); |
231 |
EditorCookie e = getCurrentEditorCookie (); |
240 |
if (e == null) return ""; |
232 |
if (e == null) return null; |
241 |
JEditorPane ep = getCurrentEditor (); |
233 |
JEditorPane ep = getCurrentEditor (); |
242 |
if (ep == null) return ""; |
234 |
if (ep == null) return null; |
243 |
StyledDocument doc = e.getDocument (); |
235 |
StyledDocument doc = e.getDocument (); |
244 |
int offset = ep.getCaret ().getDot (); |
236 |
int offset = ep.getCaret ().getDot (); |
245 |
String t = null; |
237 |
String t = null; |
246 |
// if ( (ep.getSelectionStart () <= offset) && |
238 |
// if ( (ep.getSelectionStart () <= offset) && |
247 |
// (offset <= ep.getSelectionEnd ()) |
239 |
// (offset <= ep.getSelectionEnd ()) |
248 |
// ) t = ep.getSelectedText (); |
240 |
// ) t = ep.getSelectedText (); |
249 |
// if (t != null) return t; |
241 |
// if (t != null) return t; |
250 |
|
242 |
|
251 |
int line = NbDocument.findLineNumber ( |
243 |
int line = NbDocument.findLineNumber ( |
252 |
doc, |
244 |
doc, |
Lines 261-267
Link Here
|
261 |
org.openide.text.NbDocument.findLineRootElement (doc). |
253 |
org.openide.text.NbDocument.findLineRootElement (doc). |
262 |
getElement (line); |
254 |
getElement (line); |
263 |
|
255 |
|
264 |
if (lineElem == null) return ""; |
256 |
if (lineElem == null) return null; |
265 |
int lineStartOffset = lineElem.getStartOffset (); |
257 |
int lineStartOffset = lineElem.getStartOffset (); |
266 |
int lineLen = lineElem.getEndOffset () - lineStartOffset; |
258 |
int lineLen = lineElem.getEndOffset () - lineStartOffset; |
267 |
// t contains current line in editor |
259 |
// t contains current line in editor |
Lines 281-293
Link Here
|
281 |
identEnd++; |
273 |
identEnd++; |
282 |
} |
274 |
} |
283 |
int i = t.indexOf ('(', identEnd); |
275 |
int i = t.indexOf ('(', identEnd); |
284 |
if (i < 0) return ""; |
276 |
if (i < 0) return null; |
285 |
if (t.substring (identEnd, i).trim ().length () > 0) return ""; |
277 |
if (t.substring (identEnd, i).trim ().length () > 0) return null; |
286 |
|
278 |
|
287 |
if (identStart == identEnd) return ""; |
279 |
if (identStart == identEnd) return null; |
|
|
280 |
System.out.println("suc: " + t.substring (identStart, identEnd)); |
288 |
return t.substring (identStart, identEnd); |
281 |
return t.substring (identStart, identEnd); |
289 |
} catch (javax.swing.text.BadLocationException ex) { |
282 |
} catch (javax.swing.text.BadLocationException ex) { |
290 |
return ""; |
283 |
return null; |
291 |
} |
284 |
} |
292 |
} |
285 |
} |
293 |
|
286 |
|