Lines 41-47
Link Here
|
41 |
|
41 |
|
42 |
import java.awt.event.ActionEvent; |
42 |
import java.awt.event.ActionEvent; |
43 |
import java.util.ArrayList; |
43 |
import java.util.ArrayList; |
44 |
import java.util.List; |
|
|
45 |
import javax.swing.Action; |
44 |
import javax.swing.Action; |
46 |
import javax.swing.JMenu; |
45 |
import javax.swing.JMenu; |
47 |
import javax.swing.JMenuItem; |
46 |
import javax.swing.JMenuItem; |
Lines 62-72
Link Here
|
62 |
import org.netbeans.editor.ext.ExtKit; |
61 |
import org.netbeans.editor.ext.ExtKit; |
63 |
import org.netbeans.editor.ext.ExtSyntaxSupport; |
62 |
import org.netbeans.editor.ext.ExtSyntaxSupport; |
64 |
import org.netbeans.lib.editor.codetemplates.api.CodeTemplateManager; |
63 |
import org.netbeans.lib.editor.codetemplates.api.CodeTemplateManager; |
|
|
64 |
import org.netbeans.modules.csl.api.DeleteToNextCamelCasePosition; |
65 |
import org.netbeans.modules.csl.api.DeleteToPreviousCamelCasePosition; |
65 |
import org.netbeans.modules.csl.api.GsfLanguage; |
66 |
import org.netbeans.modules.csl.api.GsfLanguage; |
|
|
67 |
import org.netbeans.modules.csl.api.InstantRenameAction; |
66 |
import org.netbeans.modules.csl.api.KeystrokeHandler; |
68 |
import org.netbeans.modules.csl.api.KeystrokeHandler; |
|
|
69 |
import org.netbeans.modules.csl.api.NextCamelCasePosition; |
67 |
import org.netbeans.modules.csl.api.OffsetRange; |
70 |
import org.netbeans.modules.csl.api.OffsetRange; |
68 |
import org.netbeans.modules.csl.editor.InstantRenameAction; |
71 |
import org.netbeans.modules.csl.api.PreviousCamelCasePosition; |
69 |
import org.netbeans.modules.csl.editor.ToggleBlockCommentAction; |
72 |
import org.netbeans.modules.csl.api.SelectCodeElementAction; |
|
|
73 |
import org.netbeans.modules.csl.api.SelectNextCamelCasePosition; |
74 |
import org.netbeans.modules.csl.api.SelectPreviousCamelCasePosition; |
75 |
import org.netbeans.modules.csl.api.ToggleBlockCommentAction; |
76 |
import org.netbeans.modules.csl.api.UiUtils; |
70 |
import org.netbeans.modules.csl.editor.hyperlink.GoToSupport; |
77 |
import org.netbeans.modules.csl.editor.hyperlink.GoToSupport; |
71 |
import org.netbeans.modules.csl.editor.semantic.GoToMarkOccurrencesAction; |
78 |
import org.netbeans.modules.csl.editor.semantic.GoToMarkOccurrencesAction; |
72 |
import org.netbeans.modules.csl.spi.CommentHandler; |
79 |
import org.netbeans.modules.csl.spi.CommentHandler; |
Lines 125-131
Link Here
|
125 |
public int[] findMatchingBlock(int offset, boolean simpleSearch) |
132 |
public int[] findMatchingBlock(int offset, boolean simpleSearch) |
126 |
throws BadLocationException { |
133 |
throws BadLocationException { |
127 |
// Do parenthesis matching, if applicable |
134 |
// Do parenthesis matching, if applicable |
128 |
KeystrokeHandler bracketCompletion = getBracketCompletion(doc, offset); |
135 |
KeystrokeHandler bracketCompletion = UiUtils.getBracketCompletion(doc, offset); |
129 |
if (bracketCompletion != null) { |
136 |
if (bracketCompletion != null) { |
130 |
OffsetRange range = bracketCompletion.findMatching(getDocument(), offset/*, simpleSearch*/); |
137 |
OffsetRange range = bracketCompletion.findMatching(getDocument(), offset/*, simpleSearch*/); |
131 |
if (range == OffsetRange.NONE) { |
138 |
if (range == OffsetRange.NONE) { |
Lines 218-235
Link Here
|
218 |
return null; |
225 |
return null; |
219 |
} |
226 |
} |
220 |
|
227 |
|
221 |
/* package */ static KeystrokeHandler getBracketCompletion(Document doc, int offset) { |
|
|
222 |
BaseDocument baseDoc = (BaseDocument)doc; |
223 |
List<Language> list = LanguageRegistry.getInstance().getEmbeddedLanguages(baseDoc, offset); |
224 |
for (Language l : list) { |
225 |
if (l.getBracketCompletion() != null) { |
226 |
return l.getBracketCompletion(); |
227 |
} |
228 |
} |
229 |
|
230 |
return null; |
231 |
} |
232 |
|
233 |
/** |
228 |
/** |
234 |
* Returns true if bracket completion is enabled in options. |
229 |
* Returns true if bracket completion is enabled in options. |
235 |
*/ |
230 |
*/ |
Lines 252-258
Link Here
|
252 |
protected void insertString(BaseDocument doc, int dotPos, Caret caret, String str, |
247 |
protected void insertString(BaseDocument doc, int dotPos, Caret caret, String str, |
253 |
boolean overwrite) throws BadLocationException { |
248 |
boolean overwrite) throws BadLocationException { |
254 |
if (completionSettingEnabled()) { |
249 |
if (completionSettingEnabled()) { |
255 |
KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos); |
250 |
KeystrokeHandler bracketCompletion = UiUtils.getBracketCompletion(doc, dotPos); |
256 |
|
251 |
|
257 |
if (bracketCompletion != null) { |
252 |
if (bracketCompletion != null) { |
258 |
// TODO - check if we're in a comment etc. and if so, do nothing |
253 |
// TODO - check if we're in a comment etc. and if so, do nothing |
Lines 283-289
Link Here
|
283 |
BaseDocument doc = (BaseDocument)document; |
278 |
BaseDocument doc = (BaseDocument)document; |
284 |
|
279 |
|
285 |
if (completionSettingEnabled()) { |
280 |
if (completionSettingEnabled()) { |
286 |
KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos); |
281 |
KeystrokeHandler bracketCompletion = UiUtils.getBracketCompletion(doc, dotPos); |
287 |
|
282 |
|
288 |
if (bracketCompletion != null) { |
283 |
if (bracketCompletion != null) { |
289 |
try { |
284 |
try { |
Lines 327-333
Link Here
|
327 |
@Override |
322 |
@Override |
328 |
protected Object beforeBreak(JTextComponent target, BaseDocument doc, Caret caret) { |
323 |
protected Object beforeBreak(JTextComponent target, BaseDocument doc, Caret caret) { |
329 |
if (completionSettingEnabled()) { |
324 |
if (completionSettingEnabled()) { |
330 |
KeystrokeHandler bracketCompletion = getBracketCompletion(doc, caret.getDot()); |
325 |
KeystrokeHandler bracketCompletion = UiUtils.getBracketCompletion(doc, caret.getDot()); |
331 |
|
326 |
|
332 |
if (bracketCompletion != null) { |
327 |
if (bracketCompletion != null) { |
333 |
try { |
328 |
try { |
Lines 384-390
Link Here
|
384 |
protected void charBackspaced(BaseDocument doc, int dotPos, Caret caret, char ch) |
379 |
protected void charBackspaced(BaseDocument doc, int dotPos, Caret caret, char ch) |
385 |
throws BadLocationException { |
380 |
throws BadLocationException { |
386 |
if (completionSettingEnabled()) { |
381 |
if (completionSettingEnabled()) { |
387 |
KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos); |
382 |
KeystrokeHandler bracketCompletion = UiUtils.getBracketCompletion(doc, dotPos); |
388 |
|
383 |
|
389 |
if (bracketCompletion != null) { |
384 |
if (bracketCompletion != null) { |
390 |
boolean success = bracketCompletion.charBackspaced(doc, dotPos, currentTarget, ch); |
385 |
boolean success = bracketCompletion.charBackspaced(doc, dotPos, currentTarget, ch); |