Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
View | Details | Raw Unified | Return to bug 169991 | Differences between
and this patch

Collapse All | Expand All

(-)a/csl.api/nbproject/project.xml (-2 lines)
 Lines 393-400    Link Here 
393
            </test-dependencies>
393
            </test-dependencies>
394
            <public-packages>
394
            <public-packages>
395
                <package>org.netbeans.modules.csl.api</package>
395
                <package>org.netbeans.modules.csl.api</package>
396
                <package>org.netbeans.modules.csl.core</package>
397
                <package>org.netbeans.modules.csl.editor</package>
398
                <package>org.netbeans.modules.csl.spi</package>
396
                <package>org.netbeans.modules.csl.spi</package>
399
                <package>org.netbeans.modules.csl.spi.support</package>
397
                <package>org.netbeans.modules.csl.spi.support</package>
400
            </public-packages>
398
            </public-packages>
(-)a/csl.api/src/META-INF/services/org.netbeans.spi.editor.mimelookup.MimeLookupInitializer (-1 lines)
Line 1    Link Here 
1
org.netbeans.modules.csl.core.MimeLookupInitializerImpl
(-)a/csl.api/src/org/netbeans/modules/csl/api/GsfLanguage.java (+4 lines)
 Lines 45-50    Link Here 
45
import org.netbeans.api.annotations.common.CheckForNull;
45
import org.netbeans.api.annotations.common.CheckForNull;
46
import org.netbeans.api.annotations.common.NonNull;
46
import org.netbeans.api.annotations.common.NonNull;
47
import org.netbeans.api.lexer.Language;
47
import org.netbeans.api.lexer.Language;
48
import org.netbeans.modules.parsing.spi.indexing.PathRecognizerRegistration;
48
49
49
50
50
/**
51
/**
 Lines 121-126    Link Here 
121
     * <b>no</b> source classpath.
122
     * <b>no</b> source classpath.
122
     *
123
     *
123
     * @return The set of source classpath IDs, can be empty or even <code>null</code>.
124
     * @return The set of source classpath IDs, can be empty or even <code>null</code>.
125
     * @deprecated Use {@link PathRecognizerRegistration} instead.
124
     */
126
     */
125
    Set<String> getSourcePathIds();
127
    Set<String> getSourcePathIds();
126
128
 Lines 131-136    Link Here 
131
     *
133
     *
132
     * @return The set of library classpath IDs, can be empty or even <code>null</code>.
134
     * @return The set of library classpath IDs, can be empty or even <code>null</code>.
133
     *   Please see {@link #getSourcePathIds()} for the exact meaning of those values.
135
     *   Please see {@link #getSourcePathIds()} for the exact meaning of those values.
136
     * @deprecated Use {@link PathRecognizerRegistration} instead.
134
     */
137
     */
135
    Set<String> getLibraryPathIds();
138
    Set<String> getLibraryPathIds();
136
139
 Lines 145-150    Link Here 
145
     *
148
     *
146
     * @return The set of binary library classpath IDs, can be empty or even <code>null</code>.
149
     * @return The set of binary library classpath IDs, can be empty or even <code>null</code>.
147
     *   Please see {@link #getLibraryPathIds()} for the exact meaning of those values.
150
     *   Please see {@link #getLibraryPathIds()} for the exact meaning of those values.
151
     * @deprecated Use {@link PathRecognizerRegistration} instead.
148
     */
152
     */
149
    Set<String> getBinaryLibraryPathIds();
153
    Set<String> getBinaryLibraryPathIds();
150
}
154
}
(-)a/csl.api/src/org/netbeans/modules/csl/core/AbstractCamelCasePosition.java (-1 / +1 lines)
 Lines 117-123    Link Here 
117
        if (name == null) return null;
117
        if (name == null) return null;
118
        String shortDesc;
118
        String shortDesc;
119
        try {
119
        try {
120
            shortDesc = NbBundle.getBundle(GsfEditorKitFactory.class).getString(name); // NOI18N
120
            shortDesc = NbBundle.getBundle(AbstractCamelCasePosition.class).getString(name); // NOI18N
121
        }catch (MissingResourceException mre){
121
        }catch (MissingResourceException mre){
122
            shortDesc = name;
122
            shortDesc = name;
123
        }
123
        }
(-)a/csl.api/src/org/netbeans/modules/csl/core/CamelCaseOperations.java (-3 / +3 lines)
 Lines 67-73    Link Here 
67
            return -1;
67
            return -1;
68
        }
68
        }
69
69
70
        KeystrokeHandler bc = GsfEditorKitFactory.getBracketCompletion(doc, offset);
70
        KeystrokeHandler bc = CslEditorKit.getBracketCompletion(doc, offset);
71
        if (bc != null) {
71
        if (bc != null) {
72
            int nextOffset = bc.getNextWordOffset(doc, offset, false);
72
            int nextOffset = bc.getNextWordOffset(doc, offset, false);
73
            if (nextOffset != -1) {
73
            if (nextOffset != -1) {
 Lines 94-100    Link Here 
94
94
95
        final Document doc = textComponent.getDocument();
95
        final Document doc = textComponent.getDocument();
96
        
96
        
97
        KeystrokeHandler bc = GsfEditorKitFactory.getBracketCompletion(doc, offset);
97
        KeystrokeHandler bc = CslEditorKit.getBracketCompletion(doc, offset);
98
        if (bc != null) {
98
        if (bc != null) {
99
            int nextOffset = bc.getNextWordOffset(
99
            int nextOffset = bc.getNextWordOffset(
100
                    doc, offset, true);
100
                    doc, offset, true);
 Lines 124-130    Link Here 
124
        }
124
        }
125
        final Document document = textComponent.getDocument();
125
        final Document document = textComponent.getDocument();
126
        Runnable r = new Runnable() {
126
        Runnable r = new Runnable() {
127
            public void run() {
127
            public @Override void run() {
128
                try {
128
                try {
129
                    if (length > 0) {
129
                    if (length > 0) {
130
                        document.remove(offset, length);
130
                        document.remove(offset, length);
(-)a/csl.api/src/org/netbeans/modules/csl/core/CslEditorKit.java (+519 lines)
Line 0    Link Here 
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.csl.core;
41
42
import java.awt.event.ActionEvent;
43
import java.util.ArrayList;
44
import java.util.List;
45
import javax.swing.Action;
46
import javax.swing.JMenu;
47
import javax.swing.JMenuItem;
48
import javax.swing.KeyStroke;
49
import javax.swing.text.BadLocationException;
50
import javax.swing.text.Caret;
51
import javax.swing.text.Document;
52
import javax.swing.text.EditorKit;
53
import javax.swing.text.JTextComponent;
54
import javax.swing.text.Keymap;
55
import javax.swing.text.TextAction;
56
import org.netbeans.api.editor.mimelookup.MimePath;
57
import org.netbeans.editor.BaseAction;
58
import org.netbeans.editor.BaseDocument;
59
import org.netbeans.editor.BaseKit;
60
import org.netbeans.editor.SyntaxSupport;
61
import org.netbeans.editor.Utilities;
62
import org.netbeans.editor.ext.ExtKit;
63
import org.netbeans.editor.ext.ExtSyntaxSupport;
64
import org.netbeans.lib.editor.codetemplates.api.CodeTemplateManager;
65
import org.netbeans.modules.csl.api.GsfLanguage;
66
import org.netbeans.modules.csl.api.KeystrokeHandler;
67
import org.netbeans.modules.csl.api.OffsetRange;
68
import org.netbeans.modules.csl.editor.InstantRenameAction;
69
import org.netbeans.modules.csl.editor.ToggleBlockCommentAction;
70
import org.netbeans.modules.csl.editor.hyperlink.GoToSupport;
71
import org.netbeans.modules.csl.editor.semantic.GoToMarkOccurrencesAction;
72
import org.netbeans.modules.csl.spi.CommentHandler;
73
import org.netbeans.modules.csl.spi.DefaultLanguageConfig;
74
import org.netbeans.modules.editor.NbEditorKit;
75
import org.openide.awt.Mnemonics;
76
import org.openide.filesystems.FileObject;
77
import org.openide.util.Exceptions;
78
import org.openide.util.NbBundle;
79
80
/**
81
 *
82
 * @author vita
83
 */
84
public final class CslEditorKit extends NbEditorKit {
85
86
    public static EditorKit createEditorKitInstance(FileObject f) {
87
        String mimeType = detectMimeType(f);
88
        return mimeType != null ? new CslEditorKit(mimeType) : null;
89
    }
90
91
    public static org.netbeans.api.lexer.Language createLexerLanguageInstance(FileObject f) {
92
        String mimeType = detectMimeType(f);
93
        if (mimeType != null) {
94
            Language l = LanguageRegistry.getInstance().getLanguageByMimeType(mimeType);
95
            if (l != null) {
96
                return l.getGsfLanguage().getLexerLanguage();
97
            }
98
        }
99
        return null;
100
    }
101
102
    // this is public only because of tests
103
    public CslEditorKit(String mimeType) {
104
        this.mimeType = mimeType;
105
    }
106
107
    // -----------------------------------------------------------------------
108
    // NbEditorKit implementation
109
    // -----------------------------------------------------------------------
110
111
    @Override
112
    public String getContentType() {
113
        return mimeType;
114
    }
115
116
    @Override
117
    public Document createDefaultDocument() {
118
        return new GsfDocument(mimeType);
119
    }
120
121
    @Override
122
    public SyntaxSupport createSyntaxSupport(final BaseDocument doc) {
123
        return new ExtSyntaxSupport(doc) {
124
            @Override
125
            public int[] findMatchingBlock(int offset, boolean simpleSearch)
126
                    throws BadLocationException {
127
                // Do parenthesis matching, if applicable
128
                KeystrokeHandler bracketCompletion = getBracketCompletion(doc, offset);
129
                if (bracketCompletion != null) {
130
                    OffsetRange range = bracketCompletion.findMatching(getDocument(), offset/*, simpleSearch*/);
131
                    if (range == OffsetRange.NONE) {
132
                        return null;
133
                    } else {
134
                        return new int[] { range.getStart(), range.getEnd() };
135
                    }
136
                }
137
138
                return null;
139
            }
140
        };
141
    }
142
143
    @Override
144
    protected void initDocument(BaseDocument doc) {
145
        // XXX This appears in JavaKit, not sure why, but doing it just in case.
146
        //do not ask why, fire bug in the IZ:
147
        CodeTemplateManager.get(doc);
148
    }
149
150
    @Override
151
    protected Action[] createActions() {
152
        Action[] superActions = super.createActions();
153
        Language language = LanguageRegistry.getInstance().getLanguageByMimeType(mimeType);
154
        GsfLanguage gsfLanguage = language.getGsfLanguage();
155
156
        ArrayList<Action> actions = new ArrayList<Action>(30);
157
158
        actions.add(new GsfDefaultKeyTypedAction());
159
        actions.add(new GsfInsertBreakAction());
160
        actions.add(new GsfDeleteCharAction(deletePrevCharAction, false));
161
162
        String lineCommentPrefix = (gsfLanguage != null) ? gsfLanguage.getLineCommentPrefix() : null;
163
        if (lineCommentPrefix != null) {
164
            actions.add(new CommentAction(lineCommentPrefix));
165
            actions.add(new UncommentAction(lineCommentPrefix));
166
            actions.add(new ToggleCommentAction(lineCommentPrefix));
167
        }
168
169
        if(gsfLanguage instanceof DefaultLanguageConfig) {
170
            CommentHandler ch = ((DefaultLanguageConfig)gsfLanguage).getCommentHandler();
171
            if(ch != null) {
172
                actions.add(new ToggleBlockCommentAction(ch));
173
            }
174
175
        }
176
177
        actions.add(new InstantRenameAction());
178
        actions.add(new GenericGoToDeclarationAction());
179
        actions.add(new GenericGenerateGoToPopupAction());
180
        actions.add(new SelectCodeElementAction(SelectCodeElementAction.selectNextElementAction, true));
181
        actions.add(new SelectCodeElementAction(SelectCodeElementAction.selectPreviousElementAction, false));
182
        //actions.add(new ExpandAllCodeBlockFolds());
183
        //actions.add(new CollapseAllCodeBlockFolds());
184
        actions.add(new NextCamelCasePosition(findAction(superActions, nextWordAction)));
185
        actions.add(new PreviousCamelCasePosition(findAction(superActions, previousWordAction)));
186
        actions.add(new SelectNextCamelCasePosition(findAction(superActions, selectionNextWordAction)));
187
        actions.add(new SelectPreviousCamelCasePosition(findAction(superActions, selectionPreviousWordAction)));
188
        actions.add(new DeleteToNextCamelCasePosition(findAction(superActions, removeNextWordAction)));
189
        actions.add(new DeleteToPreviousCamelCasePosition(findAction(superActions, removePreviousWordAction)));
190
191
        if (language.hasOccurrencesFinder()) {
192
            actions.add(new GoToMarkOccurrencesAction(false));
193
            actions.add(new GoToMarkOccurrencesAction(true));
194
        }
195
196
        return TextAction.augmentList(superActions,
197
            actions.toArray(new Action[actions.size()]));
198
    }
199
200
    // -----------------------------------------------------------------------
201
    // Private implementation
202
    // -----------------------------------------------------------------------
203
204
    private final String mimeType;
205
206
    private static String detectMimeType(FileObject f) {
207
        String mimeType = f.getParent().getPath().substring("Editors/".length()); //NOI18N
208
        return MimePath.validate(mimeType) && mimeType.length() > 0 ? mimeType : null;
209
    }
210
211
    private static Action findAction(Action [] actions, String name) {
212
        for(Action a : actions) {
213
            Object nameObj = a.getValue(Action.NAME);
214
            if (nameObj instanceof String && name.equals(nameObj)) {
215
                return a;
216
            }
217
        }
218
        return null;
219
    }
220
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
    /**
234
     * Returns true if bracket completion is enabled in options.
235
     */
236
    private static boolean completionSettingEnabled() {
237
        //return ((Boolean)Settings.getValue(GsfEditorKit.class, JavaSettingsNames.PAIR_CHARACTERS_COMPLETION)).booleanValue();
238
        return true;
239
    }
240
241
    private final class GsfDefaultKeyTypedAction extends ExtDefaultKeyTypedAction {
242
        private JTextComponent currentTarget;
243
244
        @Override
245
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
246
            currentTarget = target;
247
            super.actionPerformed(evt, target);
248
            currentTarget = null;
249
        }
250
251
        @Override
252
        protected void insertString(BaseDocument doc, int dotPos, Caret caret, String str,
253
            boolean overwrite) throws BadLocationException {
254
            if (completionSettingEnabled()) {
255
                KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos);
256
257
                if (bracketCompletion != null) {
258
                    // TODO - check if we're in a comment etc. and if so, do nothing
259
                    boolean handled =
260
                        bracketCompletion.beforeCharInserted(doc, dotPos, currentTarget,
261
                            str.charAt(0));
262
263
                    if (!handled) {
264
                        super.insertString(doc, dotPos, caret, str, overwrite);
265
                        handled = bracketCompletion.afterCharInserted(doc, dotPos, currentTarget,
266
                                str.charAt(0));
267
                    }
268
269
                    return;
270
                }
271
            }
272
273
            super.insertString(doc, dotPos, caret, str, overwrite);
274
        }
275
276
        @Override
277
        protected void replaceSelection(JTextComponent target, int dotPos, Caret caret,
278
            String str, boolean overwrite) throws BadLocationException {
279
            char insertedChar = str.charAt(0);
280
            Document document = target.getDocument();
281
282
            if (document instanceof BaseDocument) {
283
                BaseDocument doc = (BaseDocument)document;
284
285
                if (completionSettingEnabled()) {
286
                    KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos);
287
288
                    if (bracketCompletion != null) {
289
                        try {
290
                            int caretPosition = caret.getDot();
291
292
                            boolean handled =
293
                                bracketCompletion.beforeCharInserted(doc, caretPosition,
294
                                    target, insertedChar);
295
296
                            int p0 = Math.min(caret.getDot(), caret.getMark());
297
                            int p1 = Math.max(caret.getDot(), caret.getMark());
298
299
                            if (p0 != p1) {
300
                                doc.remove(p0, p1 - p0);
301
                            }
302
303
                            if (!handled) {
304
                                if ((str != null) && (str.length() > 0)) {
305
                                    doc.insertString(p0, str, null);
306
                                }
307
308
                                bracketCompletion.afterCharInserted(doc, caret.getDot() - 1,
309
                                    target, insertedChar);
310
                            }
311
                        } catch (BadLocationException e) {
312
                            e.printStackTrace();
313
                        }
314
315
                        return;
316
                    }
317
                }
318
            }
319
320
            super.replaceSelection(target, dotPos, caret, str, overwrite);
321
        }
322
    }
323
324
    private final class GsfInsertBreakAction extends InsertBreakAction {
325
        static final long serialVersionUID = -1506173310438326380L;
326
327
        @Override
328
        protected Object beforeBreak(JTextComponent target, BaseDocument doc, Caret caret) {
329
            if (completionSettingEnabled()) {
330
                KeystrokeHandler bracketCompletion = getBracketCompletion(doc, caret.getDot());
331
332
                if (bracketCompletion != null) {
333
                    try {
334
                        int newOffset = bracketCompletion.beforeBreak(doc, caret.getDot(), target);
335
336
                        if (newOffset >= 0) {
337
                            return new Integer(newOffset);
338
                        }
339
                    } catch (BadLocationException ble) {
340
                        Exceptions.printStackTrace(ble);
341
                    }
342
                }
343
            }
344
345
            // return Boolean.TRUE;
346
            return null;
347
        }
348
349
        @Override
350
        protected void afterBreak(JTextComponent target, BaseDocument doc, Caret caret,
351
            Object cookie) {
352
            if (completionSettingEnabled()) {
353
                if (cookie != null) {
354
                    if (cookie instanceof Integer) {
355
                        // integer
356
                        int dotPos = ((Integer)cookie).intValue();
357
                        if (dotPos != -1) {
358
                            caret.setDot(dotPos);
359
                        } else {
360
                            int nowDotPos = caret.getDot();
361
                            caret.setDot(nowDotPos + 1);
362
                        }
363
                    }
364
                }
365
            }
366
        }
367
    }
368
369
    private final class GsfDeleteCharAction extends ExtDeleteCharAction {
370
        private JTextComponent currentTarget;
371
372
        public GsfDeleteCharAction(String nm, boolean nextChar) {
373
            super(nm, nextChar);
374
        }
375
376
        @Override
377
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
378
            currentTarget = target;
379
            super.actionPerformed(evt, target);
380
            currentTarget = null;
381
        }
382
383
        @Override
384
        protected void charBackspaced(BaseDocument doc, int dotPos, Caret caret, char ch)
385
            throws BadLocationException {
386
            if (completionSettingEnabled()) {
387
                KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos);
388
389
                if (bracketCompletion != null) {
390
                    boolean success = bracketCompletion.charBackspaced(doc, dotPos, currentTarget, ch);
391
                    return;
392
                }
393
            }
394
            super.charBackspaced(doc, dotPos, caret, ch);
395
        }
396
    }
397
398
    private final class GenericGoToDeclarationAction extends GotoDeclarationAction {
399
        @Override
400
        public boolean gotoDeclaration(JTextComponent target) {
401
            GoToSupport.performGoTo((BaseDocument)target.getDocument(),
402
                target.getCaretPosition());
403
404
            return true;
405
        }
406
    }
407
408
    private final class GenericGenerateGoToPopupAction extends NbGenerateGoToPopupAction {
409
        @Override
410
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
411
        }
412
413
        private void addAcceleretors(Action a, JMenuItem item, JTextComponent target) {
414
            // Try to get the accelerator
415
            Keymap km = target.getKeymap();
416
417
            if (km != null) {
418
                KeyStroke[] keys = km.getKeyStrokesForAction(a);
419
420
                if ((keys != null) && (keys.length > 0)) {
421
                    item.setAccelerator(keys[0]);
422
                } else if (a != null) {
423
                    KeyStroke ks = (KeyStroke)a.getValue(Action.ACCELERATOR_KEY);
424
425
                    if (ks != null) {
426
                        item.setAccelerator(ks);
427
                    }
428
                }
429
            }
430
        }
431
432
        private void addAction(JTextComponent target, JMenu menu, Action a) {
433
            if (a != null) {
434
                String actionName = (String)a.getValue(Action.NAME);
435
                JMenuItem item = null;
436
437
                if (a instanceof BaseAction) {
438
                    item = ((BaseAction)a).getPopupMenuItem(target);
439
                }
440
441
                if (item == null) {
442
                    // gets trimmed text that doesn' contain "go to"
443
                    String itemText = (String)a.getValue(ExtKit.TRIMMED_TEXT);
444
445
                    if (itemText == null) {
446
                        itemText = getItemText(target, actionName, a);
447
                    }
448
449
                    if (itemText != null) {
450
                        item = new JMenuItem(itemText);
451
                        Mnemonics.setLocalizedText(item, itemText);
452
                        item.addActionListener(a);
453
                        addAcceleretors(a, item, target);
454
                        item.setEnabled(a.isEnabled());
455
456
                        Object helpID = a.getValue("helpID"); // NOI18N
457
458
                        if ((helpID != null) && (helpID instanceof String)) {
459
                            item.putClientProperty("HelpID", helpID); // NOI18N
460
                        }
461
                    } else {
462
                        if (ExtKit.gotoSourceAction.equals(actionName)) {
463
                            item = new JMenuItem(NbBundle.getBundle(CslEditorKit.class)
464
                                                         .getString("goto_source_open_source_not_formatted")); //NOI18N
465
                            addAcceleretors(a, item, target);
466
                            item.setEnabled(false);
467
                        }
468
                    }
469
                }
470
471
                if (item != null) {
472
                    menu.add(item);
473
                }
474
            }
475
        }
476
477
        private void addAction(JTextComponent target, JMenu menu, String actionName) {
478
            BaseKit kit = Utilities.getKit(target);
479
480
            if (kit == null) {
481
                return;
482
            }
483
484
            Action a = kit.getActionByName(actionName);
485
486
            if (a != null) {
487
                addAction(target, menu, a);
488
            } else { // action-name is null, add the separator
489
                menu.addSeparator();
490
            }
491
        }
492
493
        private String getItemText(JTextComponent target, String actionName, Action a) {
494
            String itemText;
495
496
            if (a instanceof BaseAction) {
497
                itemText = ((BaseAction)a).getPopupMenuText(target);
498
            } else {
499
                itemText = actionName;
500
            }
501
502
            return itemText;
503
        }
504
505
        @Override
506
        public JMenuItem getPopupMenuItem(final JTextComponent target) {
507
            String menuText =
508
                NbBundle.getBundle(CslEditorKit.class).getString("generate-goto-popup"); //NOI18N
509
            JMenu jm = new JMenu(menuText);
510
            //addAction(target, jm, ExtKit.gotoSourceAction);
511
            addAction(target, jm, ExtKit.gotoDeclarationAction);
512
            //addAction(target, jm, gotoSuperImplementationAction);
513
            //addAction(target, jm, ExtKit.gotoAction);
514
            return jm;
515
        }
516
    }
517
518
519
}
(-)a/csl.api/src/org/netbeans/modules/csl/core/GsfDocument.java (-13 / +11 lines)
 Lines 50-73    Link Here 
50
 * @author Tor Norbye
50
 * @author Tor Norbye
51
 */
51
 */
52
public class GsfDocument extends NbEditorDocument {
52
public class GsfDocument extends NbEditorDocument {
53
    private Language language;
53
54
    private GsfLanguage language = null;
54
    
55
    
55
    public GsfDocument(Language language) {
56
    public GsfDocument(String mimeType) {
56
        super(language.getMimeType());
57
        super(mimeType);
57
        if (language.getGsfLanguage() != null) {
58
            putProperty(org.netbeans.api.lexer.Language.class, language.getGsfLanguage().getLexerLanguage());
59
        }
60
        
61
        this.language = language;
62
    }
58
    }
63
59
64
    @Override
60
    @Override
65
    public boolean isIdentifierPart(char ch) {
61
    public boolean isIdentifierPart(char ch) {
66
        GsfLanguage gsfLanguage = language.getGsfLanguage();
62
        if (language == null) {
67
        if (gsfLanguage != null) {
63
            Language l = LanguageRegistry.getInstance().getLanguageByMimeType((String) getProperty("mimeType")); //NOI18N
68
            return gsfLanguage.isIdentifierChar(ch);
64
            if (l != null) {
65
                language = l.getGsfLanguage();
66
            }
69
        }
67
        }
70
        
68
71
        return super.isIdentifierPart(ch);
69
        return language != null ? language.isIdentifierChar(ch) : super.isIdentifierPart(ch);
72
    }
70
    }
73
}
71
}
(-)a/csl.api/src/org/netbeans/modules/csl/core/GsfEditorKitFactory.java (-561 lines)
 Lines 1-561    Link Here 
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
package org.netbeans.modules.csl.core;
42
43
import java.awt.event.ActionEvent;
44
import java.util.ArrayList;
45
import java.util.List;
46
import javax.swing.Action;
47
import javax.swing.JMenu;
48
import javax.swing.JMenuItem;
49
import javax.swing.KeyStroke;
50
import javax.swing.text.BadLocationException;
51
import javax.swing.text.Caret;
52
import javax.swing.text.Document;
53
import javax.swing.text.JTextComponent;
54
import javax.swing.text.Keymap;
55
import javax.swing.text.TextAction;
56
import org.netbeans.api.editor.fold.FoldHierarchy;
57
import org.netbeans.api.editor.fold.FoldUtilities;
58
import org.netbeans.modules.csl.api.KeystrokeHandler;
59
import org.netbeans.modules.csl.api.GsfLanguage;
60
import org.netbeans.modules.csl.api.OffsetRange;
61
import org.netbeans.editor.BaseAction;
62
import org.netbeans.editor.BaseDocument;
63
import org.netbeans.editor.BaseKit;
64
import org.netbeans.editor.BaseKit.InsertBreakAction;
65
import org.netbeans.editor.SyntaxSupport;
66
import org.netbeans.editor.Utilities;
67
import org.netbeans.editor.ext.ExtKit;
68
import org.netbeans.editor.ext.ExtKit.ToggleCommentAction;
69
import org.netbeans.editor.ext.ExtSyntaxSupport;
70
import org.netbeans.lib.editor.codetemplates.api.CodeTemplateManager;
71
import org.netbeans.modules.csl.spi.CommentHandler;
72
import org.netbeans.modules.editor.NbEditorKit;
73
import org.netbeans.modules.csl.editor.InstantRenameAction;
74
import org.netbeans.modules.csl.editor.ToggleBlockCommentAction;
75
import org.netbeans.modules.csl.editor.fold.GsfFoldManager;
76
import org.netbeans.modules.csl.editor.hyperlink.GoToSupport;
77
import org.netbeans.modules.csl.editor.semantic.GoToMarkOccurrencesAction;
78
import org.netbeans.modules.csl.spi.DefaultLanguageConfig;
79
import org.openide.awt.Mnemonics;
80
import org.openide.util.Exceptions;
81
import org.openide.util.NbBundle;
82
83
84
/**
85
 * This class represents a generic Editor Kit which is shared by a number of different
86
 * languages. The EditorKit is an innerclass, because its superclass (BaseKit) calls
87
 * getContentType() as part of its constructor. Our getContentType implementation
88
 * relies on accessing one of the fields passed in to our constructor; but when the
89
 * super constructor is calling getContentType(), our own constructor has not yet been
90
 * called. This is worked around by having an outer class which holds the field
91
 * we need at constructor time (langauge).
92
 *
93
 * @author Tor Norbye
94
 * @author Jan Jancura
95
 */
96
public class GsfEditorKitFactory {
97
    public static final String expandAllCodeBlockFolds = "expand-all-code-block-folds"; //NOI18N
98
    public static final String collapseAllCodeBlockFolds = "collapse-all-code-block-folds"; //NOI18N
99
100
    Language language;
101
    String mimeType;
102
103
    public GsfEditorKitFactory(Language language) {
104
        assert language != null;
105
        this.language = language;
106
        this.mimeType = language.getMimeType();
107
    }
108
109
    /**
110
     * Return the actual kit. This is necessary because NbEditorKit's constructor
111
     * winds up calling getContentType(), before we've actually had a chance to
112
     * construct our own editor kit (where getContentType() depends on construction
113
     * of the object. The trick is to use an outer class, construct that first, and
114
     *
115
     */
116
    public GsfEditorKit kit() {
117
        return new GsfEditorKit();
118
    }
119
120
    public static Action findAction(Action [] actions, String name) {
121
        for(Action a : actions) {
122
            Object nameObj = a.getValue(Action.NAME);
123
            if (nameObj instanceof String && name.equals(nameObj)) {
124
                return a;
125
            }
126
        }
127
        return null;
128
    }
129
130
    static KeystrokeHandler getBracketCompletion(Document doc, int offset) {
131
        BaseDocument baseDoc = (BaseDocument)doc;
132
        List<Language> list = LanguageRegistry.getInstance().getEmbeddedLanguages(baseDoc, offset);
133
        for (Language l : list) {
134
            if (l.getBracketCompletion() != null) {
135
                return l.getBracketCompletion();
136
            }
137
        }
138
139
        return null;
140
    }
141
142
    /**
143
     * Returns true if bracket completion is enabled in options.
144
     */
145
    private static boolean completionSettingEnabled() {
146
        //return ((Boolean)Settings.getValue(GsfEditorKit.class, JavaSettingsNames.PAIR_CHARACTERS_COMPLETION)).booleanValue();
147
        return true;
148
    }
149
    
150
    public class GsfEditorKit extends NbEditorKit {
151
152
        public GsfEditorKit() {
153
        }
154
155
        @Override
156
        public String getContentType() {
157
            return language.getMimeType();
158
        }
159
160
        @Override
161
        public Document createDefaultDocument() {
162
            Document doc = new GsfDocument(language);
163
            doc.putProperty("mimeType", getContentType()); //NOI18N
164
            return doc;
165
        }
166
167
        @Override
168
        public SyntaxSupport createSyntaxSupport(final BaseDocument doc) {
169
            return new ExtSyntaxSupport(doc) {
170
                @Override
171
                public int[] findMatchingBlock(int offset, boolean simpleSearch)
172
                        throws BadLocationException {
173
                    // Do parenthesis matching, if applicable
174
                    KeystrokeHandler bracketCompletion = getBracketCompletion(doc, offset);
175
                    if (bracketCompletion != null) {
176
                        OffsetRange range = bracketCompletion.findMatching(getDocument(), offset/*, simpleSearch*/);
177
                        if (range == OffsetRange.NONE) {
178
                            return null;
179
                        } else {
180
                            return new int[] { range.getStart(), range.getEnd() };
181
                        }
182
                    }
183
                    
184
                    return null;
185
                }
186
            };
187
        }
188
189
        @Override
190
        protected void initDocument(BaseDocument doc) {
191
            // XXX This appears in JavaKit, not sure why, but doing it just in case.
192
            //do not ask why, fire bug in the IZ:
193
            CodeTemplateManager.get(doc);
194
        }
195
196
        @Override
197
        public Object clone() {
198
            return new GsfEditorKit();
199
        }
200
201
        @Override
202
        protected Action[] createActions() {
203
            Action[] superActions = super.createActions();
204
            GsfLanguage gsfLanguage = language.getGsfLanguage();
205
206
            ArrayList<Action> actions = new ArrayList<Action>(30);
207
208
            actions.add(new GsfDefaultKeyTypedAction());
209
            actions.add(new GsfInsertBreakAction());
210
            actions.add(new GsfDeleteCharAction(deletePrevCharAction, false));
211
212
            String lineCommentPrefix = (gsfLanguage != null) ? gsfLanguage.getLineCommentPrefix() : null;
213
            if (lineCommentPrefix != null) {
214
                actions.add(new CommentAction(lineCommentPrefix));
215
                actions.add(new UncommentAction(lineCommentPrefix));
216
                actions.add(new ToggleCommentAction(lineCommentPrefix));
217
            }
218
219
            if(gsfLanguage instanceof DefaultLanguageConfig) {
220
                CommentHandler ch = ((DefaultLanguageConfig)gsfLanguage).getCommentHandler();
221
                if(ch != null) {
222
                    actions.add(new ToggleBlockCommentAction(ch));
223
                }
224
225
            }
226
227
            actions.add(new InstantRenameAction());
228
            actions.add(new GenericGoToDeclarationAction());
229
            actions.add(new GenericGenerateGoToPopupAction());
230
            actions.add(new SelectCodeElementAction(SelectCodeElementAction.selectNextElementAction, true));
231
            actions.add(new SelectCodeElementAction(SelectCodeElementAction.selectPreviousElementAction, false));
232
            //actions.add(new ExpandAllCodeBlockFolds());
233
            //actions.add(new CollapseAllCodeBlockFolds());
234
            actions.add(new NextCamelCasePosition(findAction(superActions, nextWordAction)));
235
            actions.add(new PreviousCamelCasePosition(findAction(superActions, previousWordAction)));
236
            actions.add(new SelectNextCamelCasePosition(findAction(superActions, selectionNextWordAction)));
237
            actions.add(new SelectPreviousCamelCasePosition(findAction(superActions, selectionPreviousWordAction)));
238
            actions.add(new DeleteToNextCamelCasePosition(findAction(superActions, removeNextWordAction)));
239
            actions.add(new DeleteToPreviousCamelCasePosition(findAction(superActions, removePreviousWordAction)));
240
            
241
            if (language.hasOccurrencesFinder()) {
242
                actions.add(new GoToMarkOccurrencesAction(false));
243
                actions.add(new GoToMarkOccurrencesAction(true));
244
            }
245
            
246
            return TextAction.augmentList(superActions,
247
                actions.toArray(new Action[actions.size()]));
248
        }
249
        
250
        public class GsfDefaultKeyTypedAction extends ExtDefaultKeyTypedAction {
251
            private JTextComponent currentTarget;
252
253
            @Override
254
            public void actionPerformed(ActionEvent evt, JTextComponent target) {
255
                currentTarget = target;
256
                super.actionPerformed(evt, target);
257
                currentTarget = null;
258
            }
259
260
            @Override
261
            protected void insertString(BaseDocument doc, int dotPos, Caret caret, String str,
262
                boolean overwrite) throws BadLocationException {
263
                if (completionSettingEnabled()) {
264
                    KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos);
265
266
                    if (bracketCompletion != null) {
267
                        // TODO - check if we're in a comment etc. and if so, do nothing
268
                        boolean handled =
269
                            bracketCompletion.beforeCharInserted(doc, dotPos, currentTarget,
270
                                str.charAt(0));
271
272
                        if (!handled) {
273
                            super.insertString(doc, dotPos, caret, str, overwrite);
274
                            handled = bracketCompletion.afterCharInserted(doc, dotPos, currentTarget,
275
                                    str.charAt(0));
276
                        }
277
278
                        return;
279
                    }
280
                }
281
282
                super.insertString(doc, dotPos, caret, str, overwrite);
283
            }
284
285
            @Override
286
            protected void replaceSelection(JTextComponent target, int dotPos, Caret caret,
287
                String str, boolean overwrite) throws BadLocationException {
288
                char insertedChar = str.charAt(0);
289
                Document document = target.getDocument();
290
291
                if (document instanceof BaseDocument) {
292
                    BaseDocument doc = (BaseDocument)document;
293
294
                    if (completionSettingEnabled()) {
295
                        KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos);
296
297
                        if (bracketCompletion != null) {
298
                            try {
299
                                int caretPosition = caret.getDot();
300
301
                                boolean handled =
302
                                    bracketCompletion.beforeCharInserted(doc, caretPosition,
303
                                        target, insertedChar);
304
305
                                int p0 = Math.min(caret.getDot(), caret.getMark());
306
                                int p1 = Math.max(caret.getDot(), caret.getMark());
307
308
                                if (p0 != p1) {
309
                                    doc.remove(p0, p1 - p0);
310
                                }
311
312
                                if (!handled) {
313
                                    if ((str != null) && (str.length() > 0)) {
314
                                        doc.insertString(p0, str, null);
315
                                    }
316
317
                                    bracketCompletion.afterCharInserted(doc, caret.getDot() - 1,
318
                                        target, insertedChar);
319
                                }
320
                            } catch (BadLocationException e) {
321
                                e.printStackTrace();
322
                            }
323
324
                            return;
325
                        }
326
                    }
327
                }
328
329
                super.replaceSelection(target, dotPos, caret, str, overwrite);
330
            }
331
        }
332
333
        public class GsfInsertBreakAction extends InsertBreakAction {
334
            static final long serialVersionUID = -1506173310438326380L;
335
336
            @Override
337
            protected Object beforeBreak(JTextComponent target, BaseDocument doc, Caret caret) {
338
                if (completionSettingEnabled()) {
339
                    KeystrokeHandler bracketCompletion = getBracketCompletion(doc, caret.getDot());
340
341
                    if (bracketCompletion != null) {
342
                        try {
343
                            int newOffset = bracketCompletion.beforeBreak(doc, caret.getDot(), target);
344
345
                            if (newOffset >= 0) {
346
                                return new Integer(newOffset);
347
                            }
348
                        } catch (BadLocationException ble) {
349
                            Exceptions.printStackTrace(ble);
350
                        }
351
                    }
352
                }
353
354
                // return Boolean.TRUE;
355
                return null;
356
            }
357
358
            @Override
359
            protected void afterBreak(JTextComponent target, BaseDocument doc, Caret caret,
360
                Object cookie) {
361
                if (completionSettingEnabled()) {
362
                    if (cookie != null) {
363
                        if (cookie instanceof Integer) {
364
                            // integer
365
                            int dotPos = ((Integer)cookie).intValue();
366
                            if (dotPos != -1) {
367
                                caret.setDot(dotPos);
368
                            } else {
369
                                int nowDotPos = caret.getDot();
370
                                caret.setDot(nowDotPos + 1);
371
                            }
372
                        }
373
                    }
374
                }
375
            }
376
        }
377
378
        public class GsfDeleteCharAction extends ExtDeleteCharAction {
379
            private JTextComponent currentTarget;
380
            
381
            public GsfDeleteCharAction(String nm, boolean nextChar) {
382
                super(nm, nextChar);
383
            }
384
385
            @Override
386
            public void actionPerformed(ActionEvent evt, JTextComponent target) {
387
                currentTarget = target;
388
                super.actionPerformed(evt, target);
389
                currentTarget = null;
390
            }
391
392
            @Override
393
            protected void charBackspaced(BaseDocument doc, int dotPos, Caret caret, char ch)
394
                throws BadLocationException {
395
                if (completionSettingEnabled()) {
396
                    KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos);
397
398
                    if (bracketCompletion != null) {
399
                        boolean success = bracketCompletion.charBackspaced(doc, dotPos, currentTarget, ch);
400
                        return;
401
                    }
402
                }
403
                super.charBackspaced(doc, dotPos, caret, ch);
404
            }
405
        }
406
407
        private class GenericGoToDeclarationAction extends GotoDeclarationAction {
408
            @Override
409
            public boolean gotoDeclaration(JTextComponent target) {
410
                GoToSupport.performGoTo((BaseDocument)target.getDocument(),
411
                    target.getCaretPosition());
412
413
                return true;
414
            }
415
        }
416
417
        private class GenericGenerateGoToPopupAction extends NbGenerateGoToPopupAction {
418
            @Override
419
            public void actionPerformed(ActionEvent evt, JTextComponent target) {
420
            }
421
422
            private void addAcceleretors(Action a, JMenuItem item, JTextComponent target) {
423
                // Try to get the accelerator
424
                Keymap km = target.getKeymap();
425
426
                if (km != null) {
427
                    KeyStroke[] keys = km.getKeyStrokesForAction(a);
428
429
                    if ((keys != null) && (keys.length > 0)) {
430
                        item.setAccelerator(keys[0]);
431
                    } else if (a != null) {
432
                        KeyStroke ks = (KeyStroke)a.getValue(Action.ACCELERATOR_KEY);
433
434
                        if (ks != null) {
435
                            item.setAccelerator(ks);
436
                        }
437
                    }
438
                }
439
            }
440
441
            private void addAction(JTextComponent target, JMenu menu, Action a) {
442
                if (a != null) {
443
                    String actionName = (String)a.getValue(Action.NAME);
444
                    JMenuItem item = null;
445
446
                    if (a instanceof BaseAction) {
447
                        item = ((BaseAction)a).getPopupMenuItem(target);
448
                    }
449
450
                    if (item == null) {
451
                        // gets trimmed text that doesn' contain "go to"
452
                        String itemText = (String)a.getValue(ExtKit.TRIMMED_TEXT);
453
454
                        if (itemText == null) {
455
                            itemText = getItemText(target, actionName, a);
456
                        }
457
458
                        if (itemText != null) {
459
                            item = new JMenuItem(itemText);
460
                            Mnemonics.setLocalizedText(item, itemText);
461
                            item.addActionListener(a);
462
                            addAcceleretors(a, item, target);
463
                            item.setEnabled(a.isEnabled());
464
465
                            Object helpID = a.getValue("helpID"); // NOI18N
466
467
                            if ((helpID != null) && (helpID instanceof String)) {
468
                                item.putClientProperty("HelpID", helpID); // NOI18N
469
                            }
470
                        } else {
471
                            if (ExtKit.gotoSourceAction.equals(actionName)) {
472
                                item = new JMenuItem(NbBundle.getBundle(GsfEditorKit.class)
473
                                                             .getString("goto_source_open_source_not_formatted")); //NOI18N
474
                                addAcceleretors(a, item, target);
475
                                item.setEnabled(false);
476
                            }
477
                        }
478
                    }
479
480
                    if (item != null) {
481
                        menu.add(item);
482
                    }
483
                }
484
            }
485
486
            private void addAction(JTextComponent target, JMenu menu, String actionName) {
487
                BaseKit kit = Utilities.getKit(target);
488
489
                if (kit == null) {
490
                    return;
491
                }
492
493
                Action a = kit.getActionByName(actionName);
494
495
                if (a != null) {
496
                    addAction(target, menu, a);
497
                } else { // action-name is null, add the separator
498
                    menu.addSeparator();
499
                }
500
            }
501
502
            private String getItemText(JTextComponent target, String actionName, Action a) {
503
                String itemText;
504
505
                if (a instanceof BaseAction) {
506
                    itemText = ((BaseAction)a).getPopupMenuText(target);
507
                } else {
508
                    itemText = actionName;
509
                }
510
511
                return itemText;
512
            }
513
514
            @Override
515
            public JMenuItem getPopupMenuItem(final JTextComponent target) {
516
                String menuText =
517
                    NbBundle.getBundle(GsfEditorKit.class).getString("generate-goto-popup"); //NOI18N
518
                JMenu jm = new JMenu(menuText);
519
                //addAction(target, jm, ExtKit.gotoSourceAction);
520
                addAction(target, jm, ExtKit.gotoDeclarationAction);
521
                //addAction(target, jm, gotoSuperImplementationAction);
522
                //addAction(target, jm, ExtKit.gotoAction);
523
                return jm;
524
            }
525
        }
526
    }
527
528
    public static class ExpandAllCodeBlockFolds extends BaseAction{
529
        public ExpandAllCodeBlockFolds(){
530
            super(expandAllCodeBlockFolds);
531
            putValue(SHORT_DESCRIPTION, NbBundle.getBundle(GsfEditorKitFactory.class).getString("expand-all-code-block-folds"));
532
            putValue(BaseAction.POPUP_MENU_TEXT, NbBundle.getBundle(GsfEditorKitFactory.class).getString("popup-expand-all-code-block-folds"));
533
        }
534
    
535
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
536
            FoldHierarchy hierarchy = FoldHierarchy.get(target);
537
            // Hierarchy locking done in the utility method
538
            List types = new ArrayList();
539
            types.add(GsfFoldManager.CODE_BLOCK_FOLD_TYPE);
540
            //types.add(GsfFoldManager.IMPORTS_FOLD_TYPE);
541
            FoldUtilities.expand(hierarchy, types);
542
        }
543
    }
544
    
545
    public static class CollapseAllCodeBlockFolds extends BaseAction{
546
        public CollapseAllCodeBlockFolds(){
547
            super(collapseAllCodeBlockFolds);
548
            putValue(SHORT_DESCRIPTION, NbBundle.getBundle(GsfEditorKitFactory.class).getString("collapse-all-code-block-folds"));
549
            putValue(BaseAction.POPUP_MENU_TEXT, NbBundle.getBundle(GsfEditorKitFactory.class).getString("popup-collapse-all-code-block-folds"));
550
        }
551
    
552
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
553
            FoldHierarchy hierarchy = FoldHierarchy.get(target);
554
            // Hierarchy locking done in the utility method
555
            List types = new ArrayList();
556
            types.add(GsfFoldManager.CODE_BLOCK_FOLD_TYPE);
557
            ///types.add(GsfFoldManager.IMPORTS_FOLD_TYPE);
558
            FoldUtilities.collapse(hierarchy, types);
559
        }
560
    }
561
}
(-)a/csl.api/src/org/netbeans/modules/csl/core/LanguageRegistrationProcessor.java (-3 / +43 lines)
 Lines 48-59    Link Here 
48
import javax.annotation.processing.SupportedAnnotationTypes;
48
import javax.annotation.processing.SupportedAnnotationTypes;
49
import javax.annotation.processing.SupportedSourceVersion;
49
import javax.annotation.processing.SupportedSourceVersion;
50
import javax.lang.model.SourceVersion;
50
import javax.lang.model.SourceVersion;
51
import javax.lang.model.element.AnnotationMirror;
51
import javax.lang.model.element.Element;
52
import javax.lang.model.element.Element;
52
import javax.lang.model.element.ExecutableElement;
53
import javax.lang.model.element.ExecutableElement;
53
import javax.lang.model.element.TypeElement;
54
import javax.lang.model.element.TypeElement;
54
import javax.lang.model.util.ElementFilter;
55
import javax.lang.model.util.ElementFilter;
55
import javax.swing.JSeparator;
56
import javax.swing.JSeparator;
57
import javax.swing.text.EditorKit;
56
import org.netbeans.api.editor.mimelookup.MimePath;
58
import org.netbeans.api.editor.mimelookup.MimePath;
59
import org.netbeans.api.lexer.Language;
57
import org.netbeans.lib.editor.codetemplates.CodeTemplateCompletionProvider;
60
import org.netbeans.lib.editor.codetemplates.CodeTemplateCompletionProvider;
58
import org.netbeans.lib.editor.hyperlink.spi.HyperlinkProviderExt;
61
import org.netbeans.lib.editor.hyperlink.spi.HyperlinkProviderExt;
59
import org.netbeans.modules.csl.editor.GsfCodeFoldingSideBarFactory;
62
import org.netbeans.modules.csl.editor.GsfCodeFoldingSideBarFactory;
 Lines 68-73    Link Here 
68
import org.netbeans.modules.csl.navigation.ClassMemberPanel;
71
import org.netbeans.modules.csl.navigation.ClassMemberPanel;
69
import org.netbeans.modules.csl.spi.LanguageRegistration;
72
import org.netbeans.modules.csl.spi.LanguageRegistration;
70
import org.netbeans.modules.editor.errorstripe.privatespi.MarkProviderCreator;
73
import org.netbeans.modules.editor.errorstripe.privatespi.MarkProviderCreator;
74
import org.netbeans.modules.editor.indent.spi.IndentTask;
75
import org.netbeans.modules.editor.indent.spi.ReformatTask;
71
import org.netbeans.modules.parsing.spi.ParserFactory;
76
import org.netbeans.modules.parsing.spi.ParserFactory;
72
import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexerFactory;
77
import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexerFactory;
73
import org.netbeans.modules.parsing.spi.indexing.PathRecognizer;
78
import org.netbeans.modules.parsing.spi.indexing.PathRecognizer;
 Lines 107-112    Link Here 
107
                throw new LayerGenerationException("Class " + cls + " is not subclass of " + dlc, e); //NOI18N
112
                throw new LayerGenerationException("Class " + cls + " is not subclass of " + dlc, e); //NOI18N
108
            }
113
            }
109
114
115
            boolean isAnnotatedByPathRecognizerRegistration = false;
116
            TypeElement prr = processingEnv.getElementUtils().getTypeElement("org.netbeans.modules.parsing.spi.indexing.PathRecognizerRegistration"); //NOI18N
117
            for(AnnotationMirror am : cls.getAnnotationMirrors()) {
118
                if (am.getAnnotationType().asElement().equals(prr)) {
119
                    isAnnotatedByPathRecognizerRegistration = true;
120
                    break;
121
                }
122
            }
123
110
            List<ExecutableElement> methodsList = ElementFilter.methodsIn(cls.getEnclosedElements());
124
            List<ExecutableElement> methodsList = ElementFilter.methodsIn(cls.getEnclosedElements());
111
            Map<String, ExecutableElement> methods = new HashMap<String, ExecutableElement>(methodsList.size());
125
            Map<String, ExecutableElement> methods = new HashMap<String, ExecutableElement>(methodsList.size());
112
            for(ExecutableElement m : methodsList) {
126
            for(ExecutableElement m : methodsList) {
 Lines 126-135    Link Here 
126
                }
140
                }
127
141
128
                if (!languageRegistration.useCustomEditorKit()) {
142
                if (!languageRegistration.useCustomEditorKit()) {
143
                    registerEditorKit(lb, mimeType);
129
                    registerLoader(lb, mimeType);
144
                    registerLoader(lb, mimeType);
130
                    registerPathRecognizer(lb, mimeType);
145
                    if (methods.containsKey("getLexerLanguage")) { //NOI18N
131
                    registerParser(lb, mimeType);
146
                        registerLexer(lb, mimeType);
132
                    registerIndexer(lb, mimeType);
147
                    }
148
                    if (methods.containsKey("getParser")) { //NOI18N
149
                        registerParser(lb, mimeType);
150
                    }
151
                        if (methods.containsKey("getIndexerFactory")) { //NOI18N
152
                        registerIndexer(lb, mimeType);
153
                        if (!isAnnotatedByPathRecognizerRegistration) {
154
                            registerPathRecognizer(lb, mimeType);
155
                        }
156
                    }
133
                    registerCodeCompletion(lb, mimeType);
157
                    registerCodeCompletion(lb, mimeType);
134
                    registerCodeFolding(lb, mimeType);
158
                    registerCodeFolding(lb, mimeType);
135
                    registerCodeTemplates(lb, mimeType);
159
                    registerCodeTemplates(lb, mimeType);
 Lines 140-145    Link Here 
140
                    registerUpToDateStatus(lb, mimeType);
164
                    registerUpToDateStatus(lb, mimeType);
141
                    registerContextMenu(lb, mimeType, methods);
165
                    registerContextMenu(lb, mimeType, methods);
142
                    registerCommentUncommentToolbarButtons(lb, mimeType);
166
                    registerCommentUncommentToolbarButtons(lb, mimeType);
167
                    if (methods.containsKey("getFormatter")) { //NOI18N
168
                        registerFormatterIndenter(lb, mimeType);
169
                    }
143
                }
170
                }
144
            }
171
            }
145
        }
172
        }
 Lines 431-436    Link Here 
431
//        }
458
//        }
432
    }
459
    }
433
460
461
    private static void registerEditorKit(LayerBuilder b, String mimeType) {
462
        instanceFile(b, "Editors/" + mimeType, null, CslEditorKit.class, "createEditorKitInstance", EditorKit.class).write(); //NOI18N
463
    }
464
465
    private static void registerLexer(LayerBuilder b, String mimeType) {
466
        instanceFile(b, "Editors/" + mimeType, null, CslEditorKit.class, "createLexerLanguageInstance", Language.class).write(); //NOI18N
467
    }
468
469
    private static void registerFormatterIndenter(LayerBuilder b, String mimeType) {
470
        instanceFile(b, "Editors/" + mimeType, null, GsfReformatTaskFactory.class, null, ReformatTask.class).write(); //NOI18N
471
        instanceFile(b, "Editors/" + mimeType, null, GsfIndentTaskFactory.class, null, IndentTask.class).write(); //NOI18N
472
    }
473
434
    private static String makeFilesystemName(String s) {
474
    private static String makeFilesystemName(String s) {
435
        StringBuilder sb = new StringBuilder(s.length());
475
        StringBuilder sb = new StringBuilder(s.length());
436
        for(int i = 0; i < s.length(); i++) {
476
        for(int i = 0; i < s.length(); i++) {
(-)a/csl.api/src/org/netbeans/modules/csl/core/MimeLookupInitializerImpl.java (-189 lines)
 Lines 1-189    Link Here 
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
package org.netbeans.modules.csl.core;
42
43
import java.util.HashMap;
44
import java.util.Map;
45
import org.netbeans.modules.csl.core.GsfIndentTaskFactory;
46
import org.netbeans.spi.editor.mimelookup.MimeLookupInitializer;
47
import org.openide.util.Lookup;
48
import org.openide.util.lookup.InstanceContent;
49
import org.openide.util.lookup.Lookups;
50
51
52
/**
53
 * Listen for editor lookup requests for a particular mime type, and lazily
54
 * initialize language support and construct an editor kit for the given
55
 * mime type.
56
 *
57
 * Based on MimeLookupInitializer in the Schliemann prototype by Jan Jancura.
58
 *
59
 * @author Jan Jancura
60
 * @author Tor Norbye
61
 */
62
public class MimeLookupInitializerImpl implements MimeLookupInitializer {
63
64
    private static final int EDITOR_KIT_ID = 1;
65
    private static final int INDENT_ID = 2;
66
    private static final int FORMAT_ID = 3;
67
    private static final int BRACES_ID = 4;
68
69
    private String[] mimeTypes;
70
    private Map<String, Lookup.Result> children = new HashMap<String,Lookup.Result>(); //<mimetype, child Lookup.Result>
71
    private Lookup lookup;
72
73
    public MimeLookupInitializerImpl() {
74
        this(new String[0]);
75
    }
76
77
    public MimeLookupInitializerImpl(String[] mimeTypes) {
78
        this.mimeTypes = mimeTypes;
79
    }
80
81
    /**
82
     * Retrieves a Lookup.Result of MimeLookupInitializers for the given sub-mimeType.
83
     *
84
     * @param mimeType mime-type string representation e.g. "text/x-java"
85
     * @return non-null lookup result of MimeLookupInitializer(s).
86
     *  <br/>
87
     *  Typically there should be just one child initializer although if there
88
     *  will be more than one all of them will be taken into consideration.
89
     *  <br/>
90
     *  If there will be no specific initializers for the particular mime-type
91
     *  then an empty result should be returned.
92
     */
93
    public Lookup.Result child(String mimeType) {
94
        synchronized (children) {
95
            String[] newMimeType = new String[mimeTypes.length + 1];
96
            System.arraycopy(mimeTypes, 0, newMimeType, 0, mimeTypes.length);
97
            newMimeType[mimeTypes.length] = mimeType;
98
99
            Lookup.Result child = children.get(mimeType);
100
101
            if (child == null) {
102
                child = Lookups.fixed(new Object[]{new MimeLookupInitializerImpl(newMimeType)}).lookup(new Lookup.Template(MimeLookupInitializerImpl.class));
103
                children.put(mimeType, child);
104
            }
105
106
            return child;
107
        }
108
    }
109
110
    /**
111
     * Lookup providing mime-type sensitive or global-level data
112
     * depending on which level this initializer is defined.
113
     *
114
     * @return Lookup or null, if there are no lookup-able objects for mime or global level.
115
     */
116
    public Lookup lookup() {
117
        if (lookup == null) {
118
            if (mimeTypes.length != 1) {
119
                lookup = Lookup.EMPTY;
120
121
                return lookup;
122
            }
123
124
            if (LanguageRegistry.getInstance().isSupported(mimeTypes[0])) {
125
                final Language language = LanguageRegistry.getInstance().getLanguageByMimeType(mimeTypes[0]);
126
                assert language != null;
127
                
128
                if (language.useCustomEditorKit()) {
129
                    return null;
130
                }
131
132
                Integer[] supportedOps = null;
133
                if (language.hasFormatter()) {
134
                    supportedOps = new Integer[]{Integer.valueOf(EDITOR_KIT_ID), Integer.valueOf(INDENT_ID), Integer.valueOf(FORMAT_ID) };
135
                } else {
136
                    supportedOps = new Integer[]{Integer.valueOf(EDITOR_KIT_ID), Integer.valueOf(INDENT_ID) };
137
                }
138
                
139
                lookup = Lookups.fixed(supportedOps, new InstanceContent.Convertor<Integer, Object>() {
140
141
                    public Object convert(Integer i) {
142
                        switch (i.intValue()) {
143
                        case EDITOR_KIT_ID: {
144
                            GsfEditorKitFactory outer = new GsfEditorKitFactory(language);
145
146
                            return outer.kit();
147
                        }
148
                        //case BRACES_ID: {
149
                        //    return new BraceHighlighting(mimeTypes[0]);
150
                        //}
151
                        case FORMAT_ID:
152
                            return new GsfReformatTaskFactory();
153
                        case INDENT_ID:
154
                            return new GsfIndentTaskFactory();
155
                        }
156
157
                        return null;
158
                    }
159
160
                    public Class<? extends Object> type(Integer i) {
161
                        switch (i.intValue()) {
162
                        case EDITOR_KIT_ID:
163
                            return GsfEditorKitFactory.GsfEditorKit.class;
164
                        case FORMAT_ID:
165
                            return GsfReformatTaskFactory.class;
166
                        case INDENT_ID:
167
                            return GsfIndentTaskFactory.class;
168
                        //case BRACES_ID:
169
                        //    return BracesMatcherFactory.class;
170
                        }
171
172
173
                        return null;
174
                    }
175
176
                    public String id(Integer i) {
177
                        return i.toString();
178
                    }
179
180
                    public String displayName(Integer i) {
181
                        return i.toString();
182
                    }
183
                });
184
            }
185
        }
186
187
        return lookup;
188
    }
189
}
(-)a/csl.api/src/org/netbeans/modules/csl/core/SelectCodeElementAction.java (-5 / +5 lines)
 Lines 105-118    Link Here 
105
        if (name == null) return null;
105
        if (name == null) return null;
106
        String shortDesc;
106
        String shortDesc;
107
        try {
107
        try {
108
            shortDesc = NbBundle.getBundle(GsfEditorKitFactory.class).getString(name); // NOI18N
108
            shortDesc = NbBundle.getBundle(SelectCodeElementAction.class).getString(name); // NOI18N
109
        }catch (MissingResourceException mre){
109
        }catch (MissingResourceException mre){
110
            shortDesc = name;
110
            shortDesc = name;
111
        }
111
        }
112
        return shortDesc;
112
        return shortDesc;
113
    }
113
    }
114
    
114
    
115
    public void actionPerformed(ActionEvent evt, JTextComponent target) {
115
    public @Override void actionPerformed(ActionEvent evt, JTextComponent target) {
116
        if (target != null) {
116
        if (target != null) {
117
            int selectionStartOffset = target.getSelectionStart();
117
            int selectionStartOffset = target.getSelectionStart();
118
            int selectionEndOffset = target.getSelectionEnd();
118
            int selectionEndOffset = target.getSelectionEnd();
 Lines 181-187    Link Here 
181
            ignoreNextCaretUpdate = true;
181
            ignoreNextCaretUpdate = true;
182
        }
182
        }
183
        
183
        
184
        public void caretUpdate(CaretEvent e) {
184
        public @Override void caretUpdate(CaretEvent e) {
185
            if (!ignoreNextCaretUpdate) {
185
            if (!ignoreNextCaretUpdate) {
186
                synchronized (this) {
186
                synchronized (this) {
187
                    selectionInfos = null;
187
                    selectionInfos = null;
 Lines 194-200    Link Here 
194
        public void cancel() {
194
        public void cancel() {
195
        }
195
        }
196
196
197
        public void run (ResultIterator resultIterator) throws ParseException {
197
        public @Override void run (ResultIterator resultIterator) throws ParseException {
198
            Parser.Result parserResult = resultIterator.getParserResult (target.getCaretPosition ());
198
            Parser.Result parserResult = resultIterator.getParserResult (target.getCaretPosition ());
199
            if(!(parserResult instanceof ParserResult)) {
199
            if(!(parserResult instanceof ParserResult)) {
200
                return ;
200
                return ;
 Lines 256-262    Link Here 
256
            return selIndex;
256
            return selIndex;
257
        }
257
        }
258
258
259
        public void run() {
259
        public @Override void run() {
260
            if (selIndex == -1) {
260
            if (selIndex == -1) {
261
                // Try to figure out the selected AST index based on the editor selection
261
                // Try to figure out the selected AST index based on the editor selection
262
                selIndex = computeSelIndex(true);
262
                selIndex = computeSelIndex(true);
(-)a/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java (-3 / +2 lines)
 Lines 160-166    Link Here 
160
import org.netbeans.modules.csl.api.OffsetRange;
160
import org.netbeans.modules.csl.api.OffsetRange;
161
import org.netbeans.modules.csl.api.PreviewableFix;
161
import org.netbeans.modules.csl.api.PreviewableFix;
162
import org.netbeans.modules.csl.api.Severity;
162
import org.netbeans.modules.csl.api.Severity;
163
import org.netbeans.modules.csl.core.GsfEditorKitFactory;
163
import org.netbeans.modules.csl.core.CslEditorKit;
164
import org.netbeans.modules.csl.core.GsfIndentTaskFactory;
164
import org.netbeans.modules.csl.core.GsfIndentTaskFactory;
165
import org.netbeans.modules.csl.core.GsfReformatTaskFactory;
165
import org.netbeans.modules.csl.core.GsfReformatTaskFactory;
166
import org.netbeans.modules.csl.core.LanguageRegistry;
166
import org.netbeans.modules.csl.core.LanguageRegistry;
 Lines 2068-2075    Link Here 
2068
        org.netbeans.modules.csl.core.Language language = LanguageRegistry.getInstance().getLanguageByMimeType(mimeType);
2068
        org.netbeans.modules.csl.core.Language language = LanguageRegistry.getInstance().getLanguageByMimeType(mimeType);
2069
        assertNotNull(language);
2069
        assertNotNull(language);
2070
        if (!language.useCustomEditorKit()) {
2070
        if (!language.useCustomEditorKit()) {
2071
            GsfEditorKitFactory factory = new GsfEditorKitFactory(language);
2071
            return new CslEditorKit(mimeType);
2072
            return factory.kit();
2073
        }
2072
        }
2074
        fail("Must override getEditorKit() for useCustomEditorKit languages");
2073
        fail("Must override getEditorKit() for useCustomEditorKit languages");
2075
        return null;
2074
        return null;
(-)a/css.editor/src/org/netbeans/modules/css/resources/layer.xml (-1 / +3 lines)
 Lines 34-40    Link Here 
34
                    <attr name="instanceOf" stringvalue="org.netbeans.api.lexer.Language"/>
34
                    <attr name="instanceOf" stringvalue="org.netbeans.api.lexer.Language"/>
35
                </file>
35
                </file>
36
                
36
                
37
                <file name="org-netbeans-modules-css-editor-indent-CssIndentTaskFactory.instance"/>
37
                <file name="org-netbeans-modules-css-editor-indent-CssIndentTaskFactory.instance">
38
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.editor.indent.spi.IndentTask$Factory"/>
39
                </file>
38
40
39
                <folder name="BracesMatchers">
41
                <folder name="BracesMatchers">
40
                    <file name="org-netbeans-modules-css-editor-CssBracesMatcherFactory.instance">
42
                    <file name="org-netbeans-modules-css-editor-CssBracesMatcherFactory.instance">
(-)a/groovy.editor/src/org/netbeans/modules/groovy/editor/api/parser/GroovyLanguage.java (-2 / +2 lines)
 Lines 48-54    Link Here 
48
import org.netbeans.modules.csl.api.CodeCompletionHandler;
48
import org.netbeans.modules.csl.api.CodeCompletionHandler;
49
import org.netbeans.modules.csl.api.DeclarationFinder;
49
import org.netbeans.modules.csl.api.DeclarationFinder;
50
import org.netbeans.modules.csl.api.Formatter;
50
import org.netbeans.modules.csl.api.Formatter;
51
import org.netbeans.modules.csl.api.HintsProvider;
52
import org.netbeans.modules.csl.api.IndexSearcher;
51
import org.netbeans.modules.csl.api.IndexSearcher;
53
import org.netbeans.modules.csl.api.InstantRenamer;
52
import org.netbeans.modules.csl.api.InstantRenamer;
54
import org.netbeans.modules.csl.api.KeystrokeHandler;
53
import org.netbeans.modules.csl.api.KeystrokeHandler;
 Lines 65-74    Link Here 
65
import org.netbeans.modules.groovy.editor.api.GroovyUtils;
64
import org.netbeans.modules.groovy.editor.api.GroovyUtils;
66
import org.netbeans.modules.groovy.editor.api.StructureAnalyzer;
65
import org.netbeans.modules.groovy.editor.api.StructureAnalyzer;
67
import org.netbeans.modules.groovy.editor.api.completion.CompletionHandler;
66
import org.netbeans.modules.groovy.editor.api.completion.CompletionHandler;
68
import org.netbeans.modules.groovy.editor.hints.infrastructure.GroovyHintsProvider;
69
import org.netbeans.modules.groovy.editor.api.lexer.GroovyTokenId;
67
import org.netbeans.modules.groovy.editor.api.lexer.GroovyTokenId;
70
import org.netbeans.modules.parsing.spi.Parser;
68
import org.netbeans.modules.parsing.spi.Parser;
71
import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexerFactory;
69
import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexerFactory;
70
import org.netbeans.modules.parsing.spi.indexing.PathRecognizerRegistration;
72
71
73
/**
72
/**
74
 * Language/lexing configuration for Groovy
73
 * Language/lexing configuration for Groovy
 Lines 77-82    Link Here 
77
 * @author Martin Adamek
76
 * @author Martin Adamek
78
 */
77
 */
79
@LanguageRegistration(mimeType="text/x-groovy")
78
@LanguageRegistration(mimeType="text/x-groovy")
79
@PathRecognizerRegistration(mimeTypes="text/x-groovy", sourcePathIds=ClassPath.SOURCE, libraryPathIds={}, binaryLibraryPathIds={}) //NOI18N
80
public class GroovyLanguage extends DefaultLanguageConfig {
80
public class GroovyLanguage extends DefaultLanguageConfig {
81
    
81
    
82
    public GroovyLanguage() {
82
    public GroovyLanguage() {
(-)a/groovy.gsp/src/org/netbeans/modules/groovy/gsp/GspLanguage.java (-63 lines)
 Lines 42-59    Link Here 
42
package org.netbeans.modules.groovy.gsp;
42
package org.netbeans.modules.groovy.gsp;
43
43
44
import org.netbeans.api.lexer.Language;
44
import org.netbeans.api.lexer.Language;
45
import org.netbeans.modules.csl.api.CodeCompletionHandler;
46
import org.netbeans.modules.csl.api.DeclarationFinder;
47
import org.netbeans.modules.csl.api.Formatter;
48
import org.netbeans.modules.csl.api.HintsProvider;
49
import org.netbeans.modules.csl.api.InstantRenamer;
50
import org.netbeans.modules.csl.api.KeystrokeHandler;
51
import org.netbeans.modules.csl.api.OccurrencesFinder;
52
import org.netbeans.modules.csl.api.SemanticAnalyzer;
45
import org.netbeans.modules.csl.api.SemanticAnalyzer;
53
import org.netbeans.modules.csl.api.StructureScanner;
46
import org.netbeans.modules.csl.api.StructureScanner;
54
import org.netbeans.modules.csl.spi.DefaultLanguageConfig;
47
import org.netbeans.modules.csl.spi.DefaultLanguageConfig;
55
import org.netbeans.modules.csl.spi.LanguageRegistration;
48
import org.netbeans.modules.csl.spi.LanguageRegistration;
56
import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexerFactory;
57
import org.netbeans.modules.groovy.editor.api.GroovyUtils;
49
import org.netbeans.modules.groovy.editor.api.GroovyUtils;
58
import org.netbeans.modules.groovy.gsp.lexer.GspTokenId;
50
import org.netbeans.modules.groovy.gsp.lexer.GspTokenId;
59
import org.netbeans.modules.parsing.spi.Parser;
51
import org.netbeans.modules.parsing.spi.Parser;
 Lines 97-148    Link Here 
97
    }
89
    }
98
90
99
    @Override
91
    @Override
100
    public CodeCompletionHandler getCompletionHandler() {
101
        return null;
102
    }
103
104
    @Override
105
    public DeclarationFinder getDeclarationFinder() {
106
        return null;
107
    }
108
109
    @Override
110
    public boolean hasFormatter() {
111
        return false;
112
    }
113
    
114
    @Override
115
    public Formatter getFormatter() {
116
        return null;
117
    }
118
119
    @Override
120
    public EmbeddingIndexerFactory getIndexerFactory() {
121
        return null;
122
    }
123
124
125
    @Override
126
    public InstantRenamer getInstantRenamer() {
127
        return null;
128
    }
129
130
    @Override
131
    public KeystrokeHandler getKeystrokeHandler() {
132
        return null;
133
    }
134
135
    @Override
136
    public boolean hasOccurrencesFinder() {
137
        return false;
138
    }
139
140
    @Override
141
    public OccurrencesFinder getOccurrencesFinder() {
142
        return null;
143
    }
144
145
    @Override
146
    public Parser getParser() {
92
    public Parser getParser() {
147
        return new GspParser();
93
        return new GspParser();
148
    }
94
    }
 Lines 162-174    Link Here 
162
        return new GspStructureScanner();
108
        return new GspStructureScanner();
163
    }
109
    }
164
110
165
    @Override
166
    public boolean hasHintsProvider() {
167
        return false;
168
    }
169
170
    @Override
171
    public HintsProvider getHintsProvider() {
172
        return null;
173
    }
174
}
111
}
(-)a/groovy.gsp/src/org/netbeans/modules/groovy/gsp/editor/GspKit.java (-7 / +15 lines)
 Lines 58-64    Link Here 
58
import org.netbeans.editor.ext.ExtKit.ExtDefaultKeyTypedAction;
58
import org.netbeans.editor.ext.ExtKit.ExtDefaultKeyTypedAction;
59
import org.netbeans.modules.csl.core.DeleteToNextCamelCasePosition;
59
import org.netbeans.modules.csl.core.DeleteToNextCamelCasePosition;
60
import org.netbeans.modules.csl.core.DeleteToPreviousCamelCasePosition;
60
import org.netbeans.modules.csl.core.DeleteToPreviousCamelCasePosition;
61
import org.netbeans.modules.csl.core.GsfEditorKitFactory;
62
import org.netbeans.modules.csl.core.NextCamelCasePosition;
61
import org.netbeans.modules.csl.core.NextCamelCasePosition;
63
import org.netbeans.modules.csl.core.PreviousCamelCasePosition;
62
import org.netbeans.modules.csl.core.PreviousCamelCasePosition;
64
import org.netbeans.modules.csl.core.SelectCodeElementAction;
63
import org.netbeans.modules.csl.core.SelectCodeElementAction;
 Lines 116-131    Link Here 
116
//            new GspToggleCommentAction(),
115
//            new GspToggleCommentAction(),
117
            new SelectCodeElementAction(SelectCodeElementAction.selectNextElementAction, true),
116
            new SelectCodeElementAction(SelectCodeElementAction.selectNextElementAction, true),
118
            new SelectCodeElementAction(SelectCodeElementAction.selectPreviousElementAction, false),
117
            new SelectCodeElementAction(SelectCodeElementAction.selectPreviousElementAction, false),
119
            new NextCamelCasePosition(GsfEditorKitFactory.findAction(superActions, nextWordAction)),
118
            new NextCamelCasePosition(findAction(superActions, nextWordAction)),
120
            new PreviousCamelCasePosition(GsfEditorKitFactory.findAction(superActions, previousWordAction)),
119
            new PreviousCamelCasePosition(findAction(superActions, previousWordAction)),
121
            new SelectNextCamelCasePosition(GsfEditorKitFactory.findAction(superActions, selectionNextWordAction)),
120
            new SelectNextCamelCasePosition(findAction(superActions, selectionNextWordAction)),
122
            new SelectPreviousCamelCasePosition(GsfEditorKitFactory.findAction(superActions, selectionPreviousWordAction)),
121
            new SelectPreviousCamelCasePosition(findAction(superActions, selectionPreviousWordAction)),
123
            new DeleteToNextCamelCasePosition(GsfEditorKitFactory.findAction(superActions, removeNextWordAction)),
122
            new DeleteToNextCamelCasePosition(findAction(superActions, removeNextWordAction)),
124
            new DeleteToPreviousCamelCasePosition(GsfEditorKitFactory.findAction(superActions, removePreviousWordAction)),
123
            new DeleteToPreviousCamelCasePosition(findAction(superActions, removePreviousWordAction)),
125
            new InstantRenameAction(),
124
            new InstantRenameAction(),
126
         });
125
         });
127
    }
126
    }
128
127
128
    private static Action findAction(Action [] actions, String name) {
129
        for(Action a : actions) {
130
            Object nameObj = a.getValue(Action.NAME);
131
            if (nameObj instanceof String && name.equals(nameObj)) {
132
                return a;
133
            }
134
        }
135
        return null;
136
    }
129
    private boolean handleDeletion(BaseDocument doc, int dotPos) {
137
    private boolean handleDeletion(BaseDocument doc, int dotPos) {
130
        if (dotPos > 0) {
138
        if (dotPos > 0) {
131
            try {
139
            try {
(-)a/groovy.gsp/src/org/netbeans/modules/groovy/gsp/resources/layer.xml (-5 / +15 lines)
 Lines 97-108    Link Here 
97
                <file name="org-netbeans-modules-groovy-gsp-editor-embedding-GroovyEmbeddingProvider$Factory.instance">
97
                <file name="org-netbeans-modules-groovy-gsp-editor-embedding-GroovyEmbeddingProvider$Factory.instance">
98
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
98
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
99
                </file>
99
                </file>
100
                <file name="org-netbeans-modules-groovy-gsp-editor-embedding-HtmlEmbeddingProvider$Factory.instance"/>
100
                <file name="org-netbeans-modules-groovy-gsp-editor-embedding-HtmlEmbeddingProvider$Factory.instance">
101
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
102
                </file>
101
103
102
                <file name="org-netbeans-modules-groovy-gsp-GspIndentTaskFactory.instance"/>
104
                <file name="org-netbeans-modules-groovy-gsp-GspIndentTaskFactory.instance">
103
                <file name="org-netbeans-modules-groovy-gsp-EmbeddedSectionsHighlighting$Factory.instance"/>
105
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.editor.indent.spi.IndentTask$Factory"/>
104
                <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance"/>
106
                </file>
105
                <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance"/>
107
                <file name="org-netbeans-modules-groovy-gsp-EmbeddedSectionsHighlighting$Factory.instance">
108
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
109
                </file>
110
                <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance">
111
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
112
                </file>
113
                <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance">
114
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
115
                </file>
106
                <file name="org-netbeans-modules-csl-core-GsfParserFactory.instance">
116
                <file name="org-netbeans-modules-csl-core-GsfParserFactory.instance">
107
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.ParserFactory"/>
117
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.ParserFactory"/>
108
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.csl.core.GsfParserFactory.create"/>
118
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.csl.core.GsfParserFactory.create"/>
(-)a/html.editor/src/org/netbeans/modules/html/editor/resources/layer.xml (-7 / +21 lines)
 Lines 95-101    Link Here 
95
                    <attr name="instanceOf" stringvalue="org.netbeans.api.lexer.Language"/>
95
                    <attr name="instanceOf" stringvalue="org.netbeans.api.lexer.Language"/>
96
                </file>
96
                </file>
97
97
98
                <file name="org-netbeans-modules-html-editor-xhtml-XhtmlElEmbeddingProvider$Factory.instance"/>
98
                <file name="org-netbeans-modules-html-editor-xhtml-XhtmlElEmbeddingProvider$Factory.instance">
99
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
100
                </file>
99
101
100
                <file name="org-netbeans-modules-html-editor-HtmlCaretAwareSourceTask$Factory.instance">
102
                <file name="org-netbeans-modules-html-editor-HtmlCaretAwareSourceTask$Factory.instance">
101
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
103
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
 Lines 105-113    Link Here 
105
                    <file name="org-netbeans-modules-html-editor-preferences.xml" url="Preferences.xml"/>
107
                    <file name="org-netbeans-modules-html-editor-preferences.xml" url="Preferences.xml"/>
106
                </folder>
108
                </folder>
107
109
108
                <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance"/>
110
                <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance">
109
                <file name="org-netbeans-modules-html-editor-xhtml.XhtmlElHighlighting$Factory.instance"/>
111
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
110
                <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance"/>
112
                </file>
113
                <file name="org-netbeans-modules-html-editor-xhtml.XhtmlElHighlighting$Factory.instance">
114
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
115
                </file>
116
                <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance">
117
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
118
                </file>
111
                <file name="org-netbeans-modules-csl-core-GsfParserFactory.instance">
119
                <file name="org-netbeans-modules-csl-core-GsfParserFactory.instance">
112
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.ParserFactory"/>
120
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.ParserFactory"/>
113
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.csl.core.GsfParserFactory.create"/>
121
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.csl.core.GsfParserFactory.create"/>
 Lines 208-215    Link Here 
208
                    <file name="org-netbeans-modules-html-editor-preferences.xml" url="Preferences.xml"/>
216
                    <file name="org-netbeans-modules-html-editor-preferences.xml" url="Preferences.xml"/>
209
                </folder>
217
                </folder>
210
                
218
                
211
                <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance"/>
219
                <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance">
212
                <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance"/>
220
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
221
                </file>
222
                <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance">
223
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
224
                </file>
213
                <file name="org-netbeans-modules-csl-core-GsfParserFactory.instance">
225
                <file name="org-netbeans-modules-csl-core-GsfParserFactory.instance">
214
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.ParserFactory"/>
226
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.ParserFactory"/>
215
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.csl.core.GsfParserFactory.create"/>
227
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.csl.core.GsfParserFactory.create"/>
 Lines 235-241    Link Here 
235
                    </file>
247
                    </file>
236
                </folder>
248
                </folder>
237
249
238
                <file name="org-netbeans-modules-html-editor-indent-HtmlIndentTaskFactory.instance"/>
250
                <file name="org-netbeans-modules-html-editor-indent-HtmlIndentTaskFactory.instance">
251
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.editor.indent.spi.IndentTask$Factory"/>
252
                </file>
239
                
253
                
240
                <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.html.editor.resources.Bundle"/>
254
                <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.html.editor.resources.Bundle"/>
241
                <folder name="FontsColors">
255
                <folder name="FontsColors">
(-)a/javascript.editing/src/org/netbeans/modules/javascript/editing/JsLanguage.java (+2 lines)
 Lines 60-65    Link Here 
60
import org.netbeans.modules.javascript.editing.lexer.JsTokenId;
60
import org.netbeans.modules.javascript.editing.lexer.JsTokenId;
61
import org.netbeans.modules.parsing.spi.Parser;
61
import org.netbeans.modules.parsing.spi.Parser;
62
import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexerFactory;
62
import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexerFactory;
63
import org.netbeans.modules.parsing.spi.indexing.PathRecognizerRegistration;
63
64
64
65
65
/*
66
/*
 Lines 68-73    Link Here 
68
 * @author Tor Norbye
69
 * @author Tor Norbye
69
 */
70
 */
70
@LanguageRegistration(mimeType="text/javascript") //NOI18N
71
@LanguageRegistration(mimeType="text/javascript") //NOI18N
72
@PathRecognizerRegistration(mimeTypes="text/javascript", libraryPathIds=JsClassPathProvider.BOOT_CP, binaryLibraryPathIds={})
71
public class JsLanguage extends DefaultLanguageConfig {
73
public class JsLanguage extends DefaultLanguageConfig {
72
74
73
    private static boolean jsClassPathRegistered = false;
75
    private static boolean jsClassPathRegistered = false;
(-)a/javascript.editing/src/org/netbeans/modules/javascript/editing/JsonLanguage.java (+2 lines)
 Lines 53-58    Link Here 
53
import org.netbeans.modules.csl.spi.LanguageRegistration;
53
import org.netbeans.modules.csl.spi.LanguageRegistration;
54
import org.netbeans.modules.javascript.editing.lexer.JsTokenId;
54
import org.netbeans.modules.javascript.editing.lexer.JsTokenId;
55
import org.netbeans.modules.parsing.spi.Parser;
55
import org.netbeans.modules.parsing.spi.Parser;
56
import org.netbeans.modules.parsing.spi.indexing.PathRecognizerRegistration;
56
57
57
/**
58
/**
58
 * Configuration for JSON
59
 * Configuration for JSON
 Lines 60-65    Link Here 
60
 * @author Tor Norbye
61
 * @author Tor Norbye
61
 */
62
 */
62
@LanguageRegistration(mimeType="text/x-json") //NOI18N
63
@LanguageRegistration(mimeType="text/x-json") //NOI18N
64
@PathRecognizerRegistration(mimeTypes="text/x-json", libraryPathIds=JsClassPathProvider.BOOT_CP, binaryLibraryPathIds={})
63
public class JsonLanguage extends DefaultLanguageConfig {
65
public class JsonLanguage extends DefaultLanguageConfig {
64
66
65
    public JsonLanguage() {
67
    public JsonLanguage() {
(-)a/languages.yaml/src/org/netbeans/modules/languages/yaml/layer.xml (-1 / +3 lines)
 Lines 64-70    Link Here 
64
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
64
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
65
                </file>
65
                </file>
66
66
67
                <file name="org-netbeans-modules-languages-yaml-EmbeddedSectionsHighlighting$Factory.instance"/>
67
                <file name="org-netbeans-modules-languages-yaml-EmbeddedSectionsHighlighting$Factory.instance">
68
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
69
                </file>
68
70
69
                <folder name="FontsColors">
71
                <folder name="FontsColors">
70
                    <folder name="NetBeans">
72
                    <folder name="NetBeans">
(-)a/parsing.api/apichanges.xml (+15 lines)
 Lines 107-112    Link Here 
107
<!-- ACTUAL CHANGES BEGIN HERE: -->
107
<!-- ACTUAL CHANGES BEGIN HERE: -->
108
108
109
  <changes>
109
  <changes>
110
  <change id="adding-PathRecognizerRegistration-annotation">
111
      <api name="ParsingAPI"/>
112
      <summary>Adding PathRecognizerRegistration annotation</summary>
113
      <version major="1" minor="32"/>
114
      <date day="26" month="1" year="2010"/>
115
      <author login="vstejskal"/>
116
      <compatibility source="compatible" binary="compatible" semantic="compatible" deletion="no" addition="yes" modification="no"/>
117
      <description>
118
          <p>
119
              Added <code>PathRecognizerRegistration</code> annotation that simplyfies registering <code>PathRecognizer</code>s.
120
          </p>
121
      </description>
122
      <class package="org.netbeans.modules.parsing.spi.indexing" name="PathRecognizerRegistration"/>
123
      <issue number="169991"/>
124
  </change>
110
  <change id="errors-cache">
125
  <change id="errors-cache">
111
      <api name="ParsingAPI"/>
126
      <api name="ParsingAPI"/>
112
      <summary>Adding ErrorsCache</summary>
127
      <summary>Adding ErrorsCache</summary>
(-)a/parsing.api/nbproject/project.properties (-1 / +1 lines)
 Lines 2-5    Link Here 
2
javac.source=1.6
2
javac.source=1.6
3
javadoc.apichanges=${basedir}/apichanges.xml
3
javadoc.apichanges=${basedir}/apichanges.xml
4
javadoc.arch=${basedir}/arch.xml
4
javadoc.arch=${basedir}/arch.xml
5
spec.version.base=1.31.0
5
spec.version.base=1.32.0
(-)a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/DefaultPathRecognizer.java (+165 lines)
Line 0    Link Here 
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.parsing.impl.indexing;
41
42
import java.util.Collections;
43
import java.util.HashSet;
44
import java.util.Map;
45
import java.util.Set;
46
import java.util.logging.Level;
47
import java.util.logging.Logger;
48
import org.netbeans.api.editor.mimelookup.MimePath;
49
import org.netbeans.modules.parsing.spi.indexing.PathRecognizer;
50
51
/**
52
 *
53
 * @author vita
54
 */
55
public final class DefaultPathRecognizer extends PathRecognizer {
56
57
    // ------------------------------------------------------------------------
58
    // PathRecognizer implementation
59
    // ------------------------------------------------------------------------
60
61
    @Override
62
    public Set<String> getSourcePathIds() {
63
        return sourcePathIds;
64
    }
65
66
    @Override
67
    public Set<String> getBinaryLibraryPathIds() {
68
        return binaryLibraryPathIds;
69
    }
70
71
    @Override
72
    public Set<String> getLibraryPathIds() {
73
        return libraryPathIds;
74
    }
75
76
    @Override
77
    public Set<String> getMimeTypes() {
78
        return mimeTypes;
79
    }
80
81
    // ------------------------------------------------------------------------
82
    // Public implementation
83
    // ------------------------------------------------------------------------
84
85
    public static PathRecognizer createInstance(Map fileAttributes) {
86
        
87
        // path ids
88
        Set<String> sourcePathIds = readIdsAttribute(fileAttributes, "sourcePathIds"); //NOI18N
89
        Set<String> libraryPathIds = readIdsAttribute(fileAttributes, "libraryPathIds"); //NOI18N
90
        Set<String> binaryLibraryPathIds = readIdsAttribute(fileAttributes, "binaryLibraryPathIds"); //NOI18N
91
92
        // mime types
93
        Set<String> mimeTypes = new HashSet<String>();
94
        Object mts = fileAttributes.get("mimeTypes"); //NOI18N
95
        if (mts instanceof String) {
96
            String [] arr = ((String) mts).split(","); //NOI18N
97
            for(String mt : arr) {
98
                mt = mt.trim();
99
                if (mt.length() > 0 && MimePath.validate(mt)) {
100
                    mimeTypes.add(mt);
101
                } else {
102
                    LOG.log(Level.WARNING, "Invalid mimetype {0}, ignoring.", mt); //NOI18N
103
                }
104
            }
105
        }
106
107
        return new DefaultPathRecognizer(sourcePathIds, libraryPathIds, binaryLibraryPathIds, Collections.unmodifiableSet(mimeTypes));
108
    }
109
110
    @Override
111
    public String toString() {
112
        return super.toString()
113
                + "[sourcePathIds=" + sourcePathIds //NOI18N
114
                + ", libraryPathIds=" + libraryPathIds //NOI18N
115
                + ", binaryLibraryPathIds=" + binaryLibraryPathIds //NOI18N
116
                + ", mimeTypes=" + mimeTypes; //NOI18N
117
    }
118
119
    // ------------------------------------------------------------------------
120
    // Private implementation
121
    // ------------------------------------------------------------------------
122
123
    private static final Logger LOG = Logger.getLogger(DefaultPathRecognizer.class.getName());
124
125
    private final Set<String> sourcePathIds;
126
    private final Set<String> libraryPathIds;
127
    private final Set<String> binaryLibraryPathIds;
128
    private final Set<String> mimeTypes;
129
130
    private DefaultPathRecognizer(Set<String> sourcePathIds, Set<String> libraryPathIds, Set<String> binaryLibraryPathIds, Set<String> mimeTypes) {
131
        this.sourcePathIds = sourcePathIds;
132
        this.libraryPathIds = libraryPathIds;
133
        this.binaryLibraryPathIds = binaryLibraryPathIds;
134
        this.mimeTypes = mimeTypes;
135
    }
136
137
    private static Set<String> readIdsAttribute(Map fileAttributes, String attributeName) {
138
        Set<String> ids = new HashSet<String>();
139
        
140
        Object attributeValue = fileAttributes.get(attributeName); //NOI18N
141
        if (attributeValue instanceof String) {
142
            String [] varr = ((String) attributeValue).split(","); //NOI18N
143
            for(String v : varr) {
144
                v = v.trim();
145
                if (v.equals("ANY")) { //NOI18N
146
                    ids = null;
147
                    break;
148
                } else if (v.length() > 0) {
149
                    ids.add(v);
150
                } else {
151
                    LOG.log(Level.WARNING, "Empty IDs are not alowed in {0} attribute, ignoring.", attributeName); //NOI18N
152
                }
153
            }
154
        } else {
155
            if (attributeValue != null) {
156
                LOG.log(Level.WARNING, "Invalid {0} attribute value, expecting java.lang.String, but got {1}, {2}", //NOI18N
157
                        new Object [] { attributeName, attributeValue, attributeValue == null ? null : attributeValue.getClass()});
158
            }
159
            
160
            ids = Collections.<String>emptySet();
161
        }
162
163
        return ids == null ? null : Collections.unmodifiableSet(ids);
164
    }
165
}
(-)a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/PathRecognizerRegistrationProcessor.java (+195 lines)
Line 0    Link Here 
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.parsing.impl.indexing;
41
42
import java.util.Set;
43
import javax.annotation.processing.Processor;
44
import javax.annotation.processing.RoundEnvironment;
45
import javax.annotation.processing.SupportedAnnotationTypes;
46
import javax.annotation.processing.SupportedSourceVersion;
47
import javax.lang.model.SourceVersion;
48
import javax.lang.model.element.Element;
49
import javax.lang.model.element.TypeElement;
50
import org.netbeans.modules.parsing.spi.indexing.PathRecognizer;
51
import org.netbeans.modules.parsing.spi.indexing.PathRecognizerRegistration;
52
import org.openide.filesystems.annotations.LayerBuilder;
53
import org.openide.filesystems.annotations.LayerBuilder.File;
54
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
55
import org.openide.filesystems.annotations.LayerGenerationException;
56
import org.openide.util.lookup.ServiceProvider;
57
58
/**
59
 *
60
 * @author Vita Stejskal
61
 */
62
@ServiceProvider(service=Processor.class)
63
@SupportedAnnotationTypes("org.netbeans.modules.parsing.spi.indexing.PathRecognizerRegistration") //NOI18N
64
@SupportedSourceVersion(SourceVersion.RELEASE_6)
65
public class PathRecognizerRegistrationProcessor extends LayerGeneratingProcessor {
66
67
    @Override
68
    protected boolean handleProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws LayerGenerationException {
69
        for(Element e : roundEnv.getElementsAnnotatedWith(PathRecognizerRegistration.class)) {
70
            TypeElement cls = (TypeElement) e;
71
            PathRecognizerRegistration prr = cls.getAnnotation(PathRecognizerRegistration.class);
72
73
            String sourcePathIds = processIds(prr.sourcePathIds());
74
            String libraryPathIds = processIds(prr.libraryPathIds());
75
            String binaryLibraryPathIds = processIds(prr.binaryLibraryPathIds());
76
            String mimeTypes = processMts(prr.mimeTypes());
77
78
            if (mimeTypes != null && (sourcePathIds != null || libraryPathIds != null || binaryLibraryPathIds != null)) {
79
                final LayerBuilder lb = layer(cls);
80
                File f = instanceFile(lb,
81
                        "Services/Hidden/PathRecognizers", //NOI18N
82
                        makeFilesystemName(cls.getQualifiedName().toString()),
83
                        DefaultPathRecognizer.class,
84
                        "createInstance", //NOI18N
85
                        PathRecognizer.class);
86
87
                if (sourcePathIds != null) {
88
                    f.stringvalue("sourcePathIds", sourcePathIds); //NOI18N
89
                }
90
                if (libraryPathIds != null) {
91
                    f.stringvalue("libraryPathIds", libraryPathIds); //NOI18N
92
                }
93
                if (binaryLibraryPathIds != null) {
94
                    f.stringvalue("binaryLibraryPathIds", binaryLibraryPathIds); //NOI18N
95
                }
96
                if (mimeTypes != null) {
97
                    f.stringvalue("mimeTypes", mimeTypes); //NOI18N
98
                }
99
100
                f.write();
101
            }
102
        }
103
        return true;
104
    }
105
106
    private static String processIds(String [] ids) {
107
        if (ids.length == 0) {
108
            return null;
109
        } else if (ids.length == 1 && ids[0].equals("ANY")) {
110
            return "ANY"; //NOI18N
111
        } else {
112
            StringBuilder sb = new StringBuilder();
113
            for(String s : ids) {
114
                if (s == null) {
115
                    continue;
116
                }
117
118
                s = s.trim();
119
                if (s.length() == 0 || s.equals("ANY")) {
120
                    continue;
121
                }
122
123
                if (sb.length() > 0) {
124
                    sb.append(','); //NOI18N
125
                }
126
                sb.append(s);
127
            }
128
            return sb.length() > 0 ? sb.toString() : null;
129
        }
130
    }
131
132
    private static String processMts(String [] mts) {
133
        if (mts == null || mts.length == 0) {
134
            return null;
135
        } else {
136
            StringBuilder sb = new StringBuilder();
137
            for(String s : mts) {
138
                if (s == null) {
139
                    continue;
140
                }
141
142
                s = s.trim();
143
                if (s.length() == 0) {
144
                    continue;
145
                }
146
147
                if (sb.length() > 0) {
148
                    sb.append(','); //NOI18N
149
                }
150
                sb.append(s);
151
            }
152
            return sb.length() > 0 ? sb.toString() : null;
153
        }
154
    }
155
156
    private static File instanceFile(LayerBuilder b, String folder, String name, Class implClass, String factoryMethod, Class... instanceOf) {
157
        String basename;
158
        if (name == null) {
159
            basename = implClass.getName().replace('.', '-'); //NOI18N
160
            if (factoryMethod != null) {
161
                basename += "-" + factoryMethod; //NOI18N
162
            }
163
        } else {
164
            basename = name;
165
        }
166
167
        File f = b.file(folder + "/" + basename + ".instance"); //NOI18N
168
        if (implClass != null) {
169
            if (factoryMethod != null) {
170
                f.methodvalue("instanceCreate", implClass.getName(), factoryMethod); //NOI18N
171
            } else {
172
                f.stringvalue("instanceClass", implClass.getName()); //NOI18N
173
            }
174
        }
175
176
        for(Class c : instanceOf) {
177
            f.stringvalue("instanceOf", c.getName()); //NOI18N
178
        }
179
180
        return f;
181
    }
182
183
    private static String makeFilesystemName(String s) {
184
        StringBuilder sb = new StringBuilder(s.length());
185
        for(int i = 0; i < s.length(); i++) {
186
            char c = s.charAt(i);
187
            if (Character.isLetterOrDigit(c)) {
188
                sb.append(c);
189
            } else {
190
                sb.append("-"); //NOI18N
191
            }
192
        }
193
        return sb.toString();
194
    }
195
}
(-)a/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/PathRecognizerRegistration.java (+96 lines)
Line 0    Link Here 
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.parsing.spi.indexing;
41
42
import java.lang.annotation.ElementType;
43
import java.lang.annotation.Retention;
44
import java.lang.annotation.RetentionPolicy;
45
import java.lang.annotation.Target;
46
import org.netbeans.api.java.classpath.GlobalPathRegistry;
47
48
/**
49
 * Registers a <code>PathRecognizer</code> in the default <code>Lookup</code>.
50
 * 
51
 * <p class="nonnormative">
52
 * This annotation can be added to any type, but typically you should add it to an
53
 * indexer factory or a CSL language definition.
54
 *
55
 * @author Vita Stejskal
56
 * @since 1.32
57
 */
58
@Target(ElementType.TYPE)
59
@Retention(RetentionPolicy.SOURCE)
60
public @interface PathRecognizerRegistration {
61
62
    /**
63
     * Gets classpath IDs for source paths registered in
64
     * the {@link GlobalPathRegistry}.
65
     *
66
     * @return The list of source path IDs; <code>"ANY"</code> means any source path ID
67
     *   and an empty array (<code>{}</code>) means no source path ID.
68
     */
69
    public String [] sourcePathIds() default "ANY"; //NOI18N
70
71
    /**
72
     * Gets classpath IDs for library paths registered in
73
     * the {@link GlobalPathRegistry}.
74
     *
75
     * @return The list of source path IDs; <code>"ANY"</code> means any source path ID
76
     *   and an empty array (<code>{}</code>) means no source path ID.
77
     */
78
    public String [] libraryPathIds() default "ANY"; //NOI18N
79
80
    /**
81
     * Gets classpath IDs for binray library paths registered in
82
     * the {@link GlobalPathRegistry}.
83
     *
84
     * @return The list of source path IDs; <code>"ANY"</code> means any source path ID
85
     *   and an empty array (<code>{}</code>) means no source path ID.
86
     */
87
    public String [] binaryLibraryPathIds() default "ANY"; //NOI18N
88
89
    /**
90
     * Gets mime types of files relevant for the paths identified by the other methods.
91
     *
92
     * @return The list of mime types;  <code>null</code>, an empty array (<code>{}</code>)
93
     *   and empty strings (<code>""</code>) are ignored.
94
     */
95
    public String [] mimeTypes() default {};
96
}
(-)a/php.editor/src/org/netbeans/modules/php/editor/PHPLanguage.java (+2 lines)
 Lines 56-61    Link Here 
56
import org.netbeans.modules.csl.spi.LanguageRegistration;
56
import org.netbeans.modules.csl.spi.LanguageRegistration;
57
import org.netbeans.modules.parsing.spi.Parser;
57
import org.netbeans.modules.parsing.spi.Parser;
58
import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexerFactory;
58
import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexerFactory;
59
import org.netbeans.modules.parsing.spi.indexing.PathRecognizerRegistration;
59
import org.netbeans.modules.php.editor.indent.PHPBracketCompleter;
60
import org.netbeans.modules.php.editor.indent.PHPBracketCompleter;
60
import org.netbeans.modules.php.editor.indent.PHPFormatter;
61
import org.netbeans.modules.php.editor.indent.PHPFormatter;
61
import org.netbeans.modules.php.editor.index.PHPIndexer;
62
import org.netbeans.modules.php.editor.index.PHPIndexer;
 Lines 75-80    Link Here 
75
 * @author Petr Pisl
76
 * @author Petr Pisl
76
 */
77
 */
77
@LanguageRegistration(mimeType="text/x-php5") //NOI18N
78
@LanguageRegistration(mimeType="text/x-php5") //NOI18N
79
@PathRecognizerRegistration(mimeTypes="text/x-php5", sourcePathIds=PhpSourcePath.SOURCE_CP, libraryPathIds=PhpSourcePath.BOOT_CP, binaryLibraryPathIds={}) //NOI18N
78
public class PHPLanguage extends DefaultLanguageConfig {
80
public class PHPLanguage extends DefaultLanguageConfig {
79
81
80
    @Override
82
    @Override
(-)a/php.editor/src/org/netbeans/modules/php/editor/resources/layer.xml (-2 / +6 lines)
 Lines 41-48    Link Here 
41
                        <attr name="position" intvalue="0"/>
41
                        <attr name="position" intvalue="0"/>
42
                    </file>
42
                    </file>
43
                </folder>
43
                </folder>
44
                <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance"/>
44
                <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance">
45
                <file name="org-netbeans-modules-php-editor-PhpEmbeddingProvider$Factory.instance"/>
45
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
46
                </file>
47
                <file name="org-netbeans-modules-php-editor-PhpEmbeddingProvider$Factory.instance">
48
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
49
                </file>
46
                <folder name="FontsColors">
50
                <folder name="FontsColors">
47
                    <folder name="NetBeans">
51
                    <folder name="NetBeans">
48
                        <folder name="Defaults">
52
                        <folder name="Defaults">
(-)a/ruby.rhtml/src/org/netbeans/modules/ruby/rhtml/RhtmlLanguage.java (+2 lines)
 Lines 51-61    Link Here 
51
import org.netbeans.modules.csl.spi.DefaultLanguageConfig;
51
import org.netbeans.modules.csl.spi.DefaultLanguageConfig;
52
import org.netbeans.modules.csl.spi.LanguageRegistration;
52
import org.netbeans.modules.csl.spi.LanguageRegistration;
53
import org.netbeans.modules.parsing.spi.Parser;
53
import org.netbeans.modules.parsing.spi.Parser;
54
import org.netbeans.modules.parsing.spi.indexing.PathRecognizerRegistration;
54
import org.netbeans.modules.ruby.RubyIndexer;
55
import org.netbeans.modules.ruby.RubyIndexer;
55
import org.netbeans.modules.ruby.RubyStructureAnalyzer;
56
import org.netbeans.modules.ruby.RubyStructureAnalyzer;
56
import org.netbeans.modules.ruby.RubyUtils;
57
import org.netbeans.modules.ruby.RubyUtils;
57
58
58
@LanguageRegistration(mimeType="application/x-httpd-eruby", useCustomEditorKit=true) //NOI18N
59
@LanguageRegistration(mimeType="application/x-httpd-eruby", useCustomEditorKit=true) //NOI18N
60
@PathRecognizerRegistration(mimeTypes="application/x-httpd-eruby", sourcePathIds=RubyLanguage.SOURCE, libraryPathIds=RubyLanguage.BOOT, binaryLibraryPathIds={}) //NOI18N
59
public class RhtmlLanguage extends DefaultLanguageConfig {
61
public class RhtmlLanguage extends DefaultLanguageConfig {
60
    
62
    
61
    public RhtmlLanguage() {
63
    public RhtmlLanguage() {
(-)a/ruby.rhtml/src/org/netbeans/modules/ruby/rhtml/editor/RhtmlKit.java (-8 / +16 lines)
 Lines 62-68    Link Here 
62
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
62
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
63
import org.netbeans.modules.csl.core.DeleteToNextCamelCasePosition;
63
import org.netbeans.modules.csl.core.DeleteToNextCamelCasePosition;
64
import org.netbeans.modules.csl.core.DeleteToPreviousCamelCasePosition;
64
import org.netbeans.modules.csl.core.DeleteToPreviousCamelCasePosition;
65
import org.netbeans.modules.csl.core.GsfEditorKitFactory;
66
import org.netbeans.modules.csl.core.NextCamelCasePosition;
65
import org.netbeans.modules.csl.core.NextCamelCasePosition;
67
import org.netbeans.modules.csl.core.PreviousCamelCasePosition;
66
import org.netbeans.modules.csl.core.PreviousCamelCasePosition;
68
import org.netbeans.modules.csl.core.SelectCodeElementAction;
67
import org.netbeans.modules.csl.core.SelectCodeElementAction;
 Lines 74-80    Link Here 
74
import org.netbeans.modules.ruby.lexer.RubyTokenId;
73
import org.netbeans.modules.ruby.lexer.RubyTokenId;
75
import org.netbeans.modules.ruby.rhtml.lexer.api.RhtmlTokenId;
74
import org.netbeans.modules.ruby.rhtml.lexer.api.RhtmlTokenId;
76
import org.netbeans.modules.ruby.rhtml.spi.DtdResolver;
75
import org.netbeans.modules.ruby.rhtml.spi.DtdResolver;
77
import org.openide.util.Exceptions;
78
import org.openide.util.Lookup;
76
import org.openide.util.Lookup;
79
77
80
/**
78
/**
 Lines 155-170    Link Here 
155
            new RhtmlToggleCommentAction(),
153
            new RhtmlToggleCommentAction(),
156
            new SelectCodeElementAction(SelectCodeElementAction.selectNextElementAction, true),
154
            new SelectCodeElementAction(SelectCodeElementAction.selectNextElementAction, true),
157
            new SelectCodeElementAction(SelectCodeElementAction.selectPreviousElementAction, false),
155
            new SelectCodeElementAction(SelectCodeElementAction.selectPreviousElementAction, false),
158
            new NextCamelCasePosition(GsfEditorKitFactory.findAction(superActions, nextWordAction)),
156
            new NextCamelCasePosition(findAction(superActions, nextWordAction)),
159
            new PreviousCamelCasePosition(GsfEditorKitFactory.findAction(superActions, previousWordAction)),
157
            new PreviousCamelCasePosition(findAction(superActions, previousWordAction)),
160
            new SelectNextCamelCasePosition(GsfEditorKitFactory.findAction(superActions, selectionNextWordAction)),
158
            new SelectNextCamelCasePosition(findAction(superActions, selectionNextWordAction)),
161
            new SelectPreviousCamelCasePosition(GsfEditorKitFactory.findAction(superActions, selectionPreviousWordAction)),
159
            new SelectPreviousCamelCasePosition(findAction(superActions, selectionPreviousWordAction)),
162
            new DeleteToNextCamelCasePosition(GsfEditorKitFactory.findAction(superActions, removeNextWordAction)),
160
            new DeleteToNextCamelCasePosition(findAction(superActions, removeNextWordAction)),
163
            new DeleteToPreviousCamelCasePosition(GsfEditorKitFactory.findAction(superActions, removePreviousWordAction)),
161
            new DeleteToPreviousCamelCasePosition(findAction(superActions, removePreviousWordAction)),
164
            new InstantRenameAction(),
162
            new InstantRenameAction(),
165
         });
163
         });
166
    }
164
    }
167
165
166
    private static Action findAction(Action [] actions, String name) {
167
        for(Action a : actions) {
168
            Object nameObj = a.getValue(Action.NAME);
169
            if (nameObj instanceof String && name.equals(nameObj)) {
170
                return a;
171
            }
172
        }
173
        return null;
174
    }
175
168
    private boolean handleDeletion(BaseDocument doc, int dotPos) {
176
    private boolean handleDeletion(BaseDocument doc, int dotPos) {
169
        if (dotPos > 0) {
177
        if (dotPos > 0) {
170
            try {
178
            try {
(-)a/ruby.rhtml/src/org/netbeans/modules/ruby/rhtml/resources/layer.xml (-6 / +18 lines)
 Lines 108-120    Link Here 
108
                        <attr name="position" intvalue="0"/>
108
                        <attr name="position" intvalue="0"/>
109
                    </file>
109
                    </file>
110
                </folder>
110
                </folder>
111
                <file name="org-netbeans-modules-ruby-rhtml-editor-RubyEmbeddingProvider$Factory.instance"/>
111
                <file name="org-netbeans-modules-ruby-rhtml-editor-RubyEmbeddingProvider$Factory.instance">
112
                <file name="org-netbeans-modules-ruby-rhtml-editor-HtmlEmbeddingProvider$Factory.instance"/>
112
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
113
                </file>
114
                <file name="org-netbeans-modules-ruby-rhtml-editor-HtmlEmbeddingProvider$Factory.instance">
115
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
116
                </file>
113
117
114
                <file name="org-netbeans-modules-ruby-rhtml-RhtmlIndentTaskFactory.instance"/>
118
                <file name="org-netbeans-modules-ruby-rhtml-RhtmlIndentTaskFactory.instance">
115
                <file name="org-netbeans-modules-ruby-rhtml-EmbeddedSectionsHighlighting$Factory.instance"/>
119
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.editor.indent.spi.IndentTask$Factory"/>
116
                <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance"/>
120
                </file>
117
                <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance"/>
121
                <file name="org-netbeans-modules-ruby-rhtml-EmbeddedSectionsHighlighting$Factory.instance">
122
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
123
                </file>
124
                <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance">
125
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
126
                </file>
127
                <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance">
128
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
129
                </file>
118
                <file name="org-netbeans-modules-csl-core-GsfParserFactory.instance">
130
                <file name="org-netbeans-modules-csl-core-GsfParserFactory.instance">
119
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.ParserFactory"/>
131
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.ParserFactory"/>
120
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.csl.core.GsfParserFactory.create"/>
132
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.csl.core.GsfParserFactory.create"/>
(-)a/ruby/src/org/netbeans/modules/ruby/RubyLanguage.java (+2 lines)
 Lines 56-61    Link Here 
56
import org.netbeans.modules.csl.spi.LanguageRegistration;
56
import org.netbeans.modules.csl.spi.LanguageRegistration;
57
import org.netbeans.modules.parsing.spi.Parser;
57
import org.netbeans.modules.parsing.spi.Parser;
58
import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexerFactory;
58
import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexerFactory;
59
import org.netbeans.modules.parsing.spi.indexing.PathRecognizerRegistration;
59
import org.netbeans.modules.ruby.lexer.RubyTokenId;
60
import org.netbeans.modules.ruby.lexer.RubyTokenId;
60
61
61
/*
62
/*
 Lines 64-69    Link Here 
64
 * @author Tor Norbye
65
 * @author Tor Norbye
65
 */
66
 */
66
@LanguageRegistration(mimeType="text/x-ruby")
67
@LanguageRegistration(mimeType="text/x-ruby")
68
@PathRecognizerRegistration(mimeTypes="text/x-ruby", sourcePathIds=RubyLanguage.SOURCE, libraryPathIds=RubyLanguage.BOOT, binaryLibraryPathIds={}) //NOI18N
67
public class RubyLanguage extends DefaultLanguageConfig {
69
public class RubyLanguage extends DefaultLanguageConfig {
68
70
69
    public final static String BOOT = "ruby/classpath/boot";
71
    public final static String BOOT = "ruby/classpath/boot";
(-)a/web.core.syntax/src/org/netbeans/modules/web/core/syntax/resources/layer.xml (-15 / +45 lines)
 Lines 54-60    Link Here 
54
                </file>
54
                </file>
55
                <folder name="text">
55
                <folder name="text">
56
                    <folder name="x-java">
56
                    <folder name="x-java">
57
                        <file name="org-netbeans-modules-web-core-syntax-indent-JspJavaIndentTaskFactory.instance"/>
57
                        <file name="org-netbeans-modules-web-core-syntax-indent-JspJavaIndentTaskFactory.instance">
58
                            <attr name="instanceOf" stringvalue="org.netbeans.modules.editor.indent.spi.IndentTask$Factory"/>
59
                        </file>
58
                        <folder name="CodeTemplates">
60
                        <folder name="CodeTemplates">
59
                            <folder name="Defaults">
61
                            <folder name="Defaults">
60
                                <file name="codetemplates.shadow">
62
                                <file name="codetemplates.shadow">
 Lines 90-99    Link Here 
90
                        <attr name="scrollable" boolvalue="false"/>
92
                        <attr name="scrollable" boolvalue="false"/>
91
                    </file>
93
                    </file>
92
                </folder>
94
                </folder>
93
                <file name="org-netbeans-modules-web-core-syntax-indent-JspIndentTaskFactory.instance"/>
95
                <file name="org-netbeans-modules-web-core-syntax-indent-JspIndentTaskFactory.instance">
94
                <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance"/>
96
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.editor.indent.spi.IndentTask$Factory"/>
95
                <file name="org-netbeans-modules-web-core-syntax-EmbeddedSectionsHighlighting$Factory.instance"/>
97
                </file>
96
                <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance"/>
98
                <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance">
99
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
100
                </file>
101
                <file name="org-netbeans-modules-web-core-syntax-EmbeddedSectionsHighlighting$Factory.instance">
102
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
103
                </file>
104
                <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance">
105
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
106
                </file>
97
                <file name="org-netbeans-modules-csl-core-GsfParserFactory.instance">
107
                <file name="org-netbeans-modules-csl-core-GsfParserFactory.instance">
98
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.ParserFactory"/>
108
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.ParserFactory"/>
99
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.csl.core.GsfParserFactory.create"/>
109
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.csl.core.GsfParserFactory.create"/>
 Lines 179-190    Link Here 
179
                        <attr name="instanceOf" stringvalue="org.netbeans.lib.editor.hyperlink.spi.HyperlinkProviderExt"/>
189
                        <attr name="instanceOf" stringvalue="org.netbeans.lib.editor.hyperlink.spi.HyperlinkProviderExt"/>
180
                    </file>
190
                    </file>
181
                </folder>
191
                </folder>
182
                <file name="org-netbeans-modules-web-core-syntax-JspParserFactory.instance"/>
192
                <file name="org-netbeans-modules-web-core-syntax-JspParserFactory.instance">
183
                <file name="org-netbeans-modules-web-core-syntax-EmbeddingProviderImpl$Factory.instance"/>
193
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.ParserFactory"/>
184
                <file name="org-netbeans-modules-web-core-syntax-gsf-JspEmbeddingProvider$Factory.instance"/>
194
                </file>
195
                <file name="org-netbeans-modules-web-core-syntax-EmbeddingProviderImpl$Factory.instance">
196
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
197
                </file>
198
                <file name="org-netbeans-modules-web-core-syntax-gsf-JspEmbeddingProvider$Factory.instance">
199
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
200
                </file>
185
            </folder>
201
            </folder>
186
            <folder name="x-el">
202
            <folder name="x-el">
187
                <file name="org-netbeans-modules-web-core-syntax-indent-ExpressionLanguageIndentTaskFactory.instance"/>
203
                <file name="org-netbeans-modules-web-core-syntax-indent-ExpressionLanguageIndentTaskFactory.instance">
204
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.editor.indent.spi.IndentTask$Factory"/>
205
                </file>
188
            </folder>
206
            </folder>
189
            <folder name="x-tag">
207
            <folder name="x-tag">
190
                <file name="TagImportProcesor.instance">
208
                <file name="TagImportProcesor.instance">
 Lines 208-217    Link Here 
208
                        <attr name="scrollable" boolvalue="false"/>
226
                        <attr name="scrollable" boolvalue="false"/>
209
                    </file>
227
                    </file>
210
                </folder>
228
                </folder>
211
                <file name="org-netbeans-modules-web-core-syntax-indent-JspIndentTaskFactory.instance"/>
229
                <file name="org-netbeans-modules-web-core-syntax-indent-JspIndentTaskFactory.instance">
212
                <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance"/>
230
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.editor.indent.spi.IndentTask$Factory"/>
213
                <file name="org-netbeans-modules-web-core-syntax-EmbeddedSectionsHighlighting$Factory.instance"/>
231
                </file>
214
                <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance"/>
232
                <file name="org-netbeans-modules-html-editor-coloring-EmbeddingHighlightsLayerFactory.instance">
233
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
234
                </file>
235
                <file name="org-netbeans-modules-web-core-syntax-EmbeddedSectionsHighlighting$Factory.instance">
236
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
237
                </file>
238
                <file name="org-netbeans-modules-csl-editor-semantic-HighlightsLayerFactoryImpl.instance">
239
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.editor.highlighting.HighlightsLayerFactory"/>
240
                </file>
215
                <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.web.core.syntax.resources.Bundle"/>
241
                <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.web.core.syntax.resources.Bundle"/>
216
                <folder name="FontsColors">
242
                <folder name="FontsColors">
217
                    <folder name="NetBeans">
243
                    <folder name="NetBeans">
 Lines 285-292    Link Here 
285
                        <attr name="instanceOf" stringvalue="org.netbeans.lib.editor.hyperlink.spi.HyperlinkProviderExt"/>
311
                        <attr name="instanceOf" stringvalue="org.netbeans.lib.editor.hyperlink.spi.HyperlinkProviderExt"/>
286
                    </file>
312
                    </file>
287
                </folder>
313
                </folder>
288
                <file name="org-netbeans-modules-web-core-syntax-EmbeddingProviderImpl$Factory.instance"/>
314
                <file name="org-netbeans-modules-web-core-syntax-EmbeddingProviderImpl$Factory.instance">
289
                <file name="org-netbeans-modules-web-core-syntax-gsf-JspEmbeddingProvider$Factory.instance"/>
315
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
316
                </file>
317
                <file name="org-netbeans-modules-web-core-syntax-gsf-JspEmbeddingProvider$Factory.instance">
318
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.parsing.spi.TaskFactory"/>
319
                </file>
290
            </folder>
320
            </folder>
291
        </folder>
321
        </folder>
292
    </folder>
322
    </folder>

Return to bug 169991
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo