This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 207960
Collapse All | Expand All

(-)a/apisupport.refactoring/nbproject/project.xml (-273 / +281 lines)
Lines 1-4 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
2
<!--
3
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
4
Lines 42-316 Link Here
42
However, if you add GPL Version 2 code and therefore, elected the GPL
42
However, if you add GPL Version 2 code and therefore, elected the GPL
43
Version 2 license, then the option applies only if the new code is
43
Version 2 license, then the option applies only if the new code is
44
made subject to such option by the copyright holder.
44
made subject to such option by the copyright holder.
45
-->
45
-->
46
<project xmlns="http://www.netbeans.org/ns/project/1">
46
<project xmlns="http://www.netbeans.org/ns/project/1">
47
    <type>org.netbeans.modules.apisupport.project</type>
47
    <type>org.netbeans.modules.apisupport.project</type>
48
    <configuration>
48
    <configuration>
49
        <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
49
        <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
50
            <code-name-base>org.netbeans.modules.apisupport.refactoring</code-name-base>
50
            <code-name-base>org.netbeans.modules.apisupport.refactoring</code-name-base>
51
            <module-dependencies>
51
            <module-dependencies>
52
                <dependency>
52
                <dependency>
53
                    <code-name-base>org.netbeans.api.annotations.common</code-name-base>
53
                    <code-name-base>org.netbeans.api.annotations.common</code-name-base>
54
                    <build-prerequisite/>
54
                    <build-prerequisite/>
55
                    <compile-dependency/>
55
                    <compile-dependency/>
56
                    <run-dependency>
56
                    <run-dependency>
57
                        <release-version>1</release-version>
57
                        <release-version>1</release-version>
58
                        <specification-version>1.6</specification-version>
58
                        <specification-version>1.6</specification-version>
59
                    </run-dependency>
59
                    </run-dependency>
60
                </dependency>
60
                </dependency>
61
                <dependency>
61
                <dependency>
62
                    <code-name-base>org.netbeans.api.java</code-name-base>
62
                    <code-name-base>org.netbeans.api.java</code-name-base>
63
                    <build-prerequisite/>
63
                    <build-prerequisite/>
64
                    <compile-dependency/>
64
                    <compile-dependency/>
65
                    <run-dependency>
65
                    <run-dependency>
66
                        <release-version>1</release-version>
66
                        <release-version>1</release-version>
67
                        <specification-version>1.18</specification-version>
67
                        <specification-version>1.18</specification-version>
68
                    </run-dependency>
68
                    </run-dependency>
69
                </dependency>
69
                </dependency>
70
                <dependency>
70
                <dependency>
71
                    <code-name-base>org.netbeans.api.java.classpath</code-name-base>
71
                    <code-name-base>org.netbeans.api.java.classpath</code-name-base>
72
                    <build-prerequisite/>
72
                    <build-prerequisite/>
73
                    <compile-dependency/>
73
                    <compile-dependency/>
74
                    <run-dependency>
74
                    <run-dependency>
75
                        <release-version>1</release-version>
75
                        <release-version>1</release-version>
76
                        <specification-version>1.0</specification-version>
76
                        <specification-version>1.0</specification-version>
77
                    </run-dependency>
77
                    </run-dependency>
78
                </dependency>
78
                </dependency>
79
                <dependency>
79
                <dependency>
80
                    <code-name-base>org.netbeans.libs.javacapi</code-name-base>
80
                    <code-name-base>org.netbeans.libs.javacapi</code-name-base>
81
                    <build-prerequisite/>
81
                    <build-prerequisite/>
82
                    <compile-dependency/>
82
                    <compile-dependency/>
83
                    <run-dependency>
83
                    <run-dependency>
84
                        <specification-version>0.5</specification-version>
84
                        <specification-version>0.5</specification-version>
85
                    </run-dependency>
85
                    </run-dependency>
86
                </dependency>
86
                </dependency>
87
                <dependency>
87
                <dependency>
88
                    <code-name-base>org.netbeans.modules.apisupport.project</code-name-base>
88
                    <code-name-base>org.netbeans.modules.apisupport.project</code-name-base>
89
                    <build-prerequisite/>
89
                    <build-prerequisite/>
90
                    <compile-dependency/>
90
                    <compile-dependency/>
91
                    <run-dependency>
91
                    <run-dependency>
92
                        <release-version>1</release-version>
92
                        <release-version>1</release-version>
93
                        <specification-version>1.33</specification-version>
93
                        <specification-version>1.33</specification-version>
94
                    </run-dependency>
94
                    </run-dependency>
95
                </dependency>
95
                </dependency>
96
                <dependency>
96
                <dependency>
97
                    <code-name-base>org.netbeans.modules.editor.errorstripe.api</code-name-base>
97
                    <code-name-base>org.netbeans.modules.editor.errorstripe.api</code-name-base>
98
                    <build-prerequisite/>
98
                    <build-prerequisite/>
99
                    <compile-dependency/>
99
                    <compile-dependency/>
100
                    <run-dependency>
100
                    <run-dependency>
101
                        <release-version>1</release-version>
101
                        <release-version>1</release-version>
102
                        <specification-version>2.14</specification-version>
102
                        <specification-version>2.14</specification-version>
103
                    </run-dependency>
103
                    </run-dependency>
104
                </dependency>
104
                </dependency>
105
                <dependency>
105
                <dependency>
106
                    <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
106
                    <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
107
                    <build-prerequisite/>
107
                    <build-prerequisite/>
108
                    <compile-dependency/>
108
                    <compile-dependency/>
109
                    <run-dependency>
109
                    <run-dependency>
110
                        <release-version>1</release-version>
110
                        <release-version>1</release-version>
111
                        <specification-version>1.20</specification-version>
111
                        <specification-version>1.20</specification-version>
112
                    </run-dependency>
112
                    </run-dependency>
113
                </dependency>
113
                </dependency>
114
                <dependency>
114
                <dependency>
115
                    <code-name-base>org.netbeans.modules.java.project</code-name-base>
115
                    <code-name-base>org.netbeans.modules.java.project</code-name-base>
116
                    <build-prerequisite/>
116
                    <build-prerequisite/>
117
                    <compile-dependency/>
117
                    <compile-dependency/>
118
                    <run-dependency>
118
                    <run-dependency>
119
                        <release-version>1</release-version>
119
                        <release-version>1</release-version>
120
                        <specification-version>1.10</specification-version>
120
                        <specification-version>1.10</specification-version>
121
                    </run-dependency>
121
                    </run-dependency>
122
                </dependency>
122
                </dependency>
123
                <dependency>
123
                <dependency>
124
                    <code-name-base>org.netbeans.modules.java.source</code-name-base>
124
                    <code-name-base>org.netbeans.modules.java.source</code-name-base>
125
                    <build-prerequisite/>
125
                    <build-prerequisite/>
126
                    <compile-dependency/>
126
                    <compile-dependency/>
127
                    <run-dependency>
127
                    <run-dependency>
128
                        <specification-version>0.99</specification-version>
128
                        <specification-version>0.99</specification-version>
129
                    </run-dependency>
129
                    </run-dependency>
130
                </dependency>
130
                </dependency>
131
                <dependency>
131
                <dependency>
132
                    <code-name-base>org.netbeans.modules.projectapi</code-name-base>
132
                    <code-name-base>org.netbeans.modules.projectapi</code-name-base>
133
                    <build-prerequisite/>
133
                    <build-prerequisite/>
134
                    <compile-dependency/>
134
                    <compile-dependency/>
135
                    <run-dependency>
135
                    <run-dependency>
136
                        <release-version>1</release-version>
136
                        <release-version>1</release-version>
137
                        <specification-version>1.6</specification-version>
137
                        <specification-version>1.6</specification-version>
138
                    </run-dependency>
138
                    </run-dependency>
139
                </dependency>
139
                </dependency>
140
                <dependency>
140
                <dependency>
141
                    <code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
141
                    <code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
142
                    <build-prerequisite/>
142
                    <build-prerequisite/>
143
                    <compile-dependency/>
143
                    <compile-dependency/>
144
                    <run-dependency>
144
                    <run-dependency>
145
                        <release-version>1</release-version>
145
                        <release-version>1</release-version>
146
                        <specification-version>1.34</specification-version>
146
                        <specification-version>1.34</specification-version>
147
                    </run-dependency>
147
                    </run-dependency>
148
                </dependency>
148
                </dependency>
149
                <dependency>
149
                <dependency>
150
                    <code-name-base>org.netbeans.modules.queries</code-name-base>
150
                    <code-name-base>org.netbeans.modules.queries</code-name-base>
151
                    <build-prerequisite/>
151
                    <build-prerequisite/>
152
                    <compile-dependency/>
152
                    <compile-dependency/>
153
                    <run-dependency>
153
                    <run-dependency>
154
                        <release-version>1</release-version>
154
                        <release-version>1</release-version>
155
                        <specification-version>1.8</specification-version>
155
                        <specification-version>1.8</specification-version>
156
                    </run-dependency>
156
                    </run-dependency>
157
                </dependency>
157
                </dependency>
158
                <dependency>
158
                <dependency>
159
                    <code-name-base>org.netbeans.modules.refactoring.api</code-name-base>
159
                    <code-name-base>org.netbeans.modules.refactoring.api</code-name-base>
160
                    <build-prerequisite/>
160
                    <build-prerequisite/>
161
                    <compile-dependency/>
161
                    <compile-dependency/>
162
                    <run-dependency>
162
                    <run-dependency>
163
                        <specification-version>1.0</specification-version>
163
                        <specification-version>1.0</specification-version>
164
                    </run-dependency>
164
                    </run-dependency>
165
                </dependency>
165
                </dependency>
166
                <dependency>
166
                <dependency>
167
                    <code-name-base>org.netbeans.spi.editor.hints</code-name-base>
167
                    <code-name-base>org.netbeans.spi.editor.hints</code-name-base>
168
                    <build-prerequisite/>
168
                    <build-prerequisite/>
169
                    <compile-dependency/>
169
                    <compile-dependency/>
170
                    <run-dependency>
170
                    <run-dependency>
171
                        <release-version>0</release-version>
171
                        <release-version>0</release-version>
172
                        <specification-version>1.15</specification-version>
172
                        <specification-version>1.15</specification-version>
173
                    </run-dependency>
173
                    </run-dependency>
174
                </dependency>
174
                </dependency>
175
                <dependency>
175
                <dependency>
176
                    <code-name-base>org.netbeans.spi.java.hints</code-name-base>
176
                    <code-name-base>org.netbeans.spi.java.hints</code-name-base>
177
                    <build-prerequisite/>
177
                    <build-prerequisite/>
178
                    <compile-dependency/>
178
                    <compile-dependency/>
179
                    <run-dependency>
179
                    <run-dependency>
180
                        <specification-version>1.0</specification-version>
180
                        <specification-version>1.0</specification-version>
181
                    </run-dependency>
181
                    </run-dependency>
182
                </dependency>
182
                </dependency>
183
                <dependency>
183
                <dependency>
184
                    <code-name-base>org.openide.awt</code-name-base>
184
                    <code-name-base>org.openide.awt</code-name-base>
185
                    <build-prerequisite/>
185
                    <build-prerequisite/>
186
                    <compile-dependency/>
186
                    <compile-dependency/>
187
                    <run-dependency>
187
                    <run-dependency>
188
                        <specification-version>7.33</specification-version>
188
                        <specification-version>7.33</specification-version>
189
                    </run-dependency>
189
                    </run-dependency>
190
                </dependency>
190
                </dependency>
191
                <dependency>
191
                <dependency>
192
                    <code-name-base>org.openide.dialogs</code-name-base>
192
                    <code-name-base>org.openide.dialogs</code-name-base>
193
                    <build-prerequisite/>
193
                    <build-prerequisite/>
194
                    <compile-dependency/>
194
                    <compile-dependency/>
195
                    <run-dependency>
195
                    <run-dependency>
196
                        <specification-version>7.17</specification-version>
196
                        <specification-version>7.17</specification-version>
197
                    </run-dependency>
197
                    </run-dependency>
198
                </dependency>
198
                </dependency>
199
                <dependency>
199
                <dependency>
200
                    <code-name-base>org.openide.filesystems</code-name-base>
200
                    <code-name-base>org.openide.filesystems</code-name-base>
201
                    <build-prerequisite/>
201
                    <build-prerequisite/>
202
                    <compile-dependency/>
202
                    <compile-dependency/>
203
                    <run-dependency>
203
                    <run-dependency>
204
                        <specification-version>7.57</specification-version>
204
                        <specification-version>7.57</specification-version>
205
                    </run-dependency>
205
                    </run-dependency>
206
                </dependency>
206
                </dependency>
207
                <dependency>
207
                <dependency>
208
                    <code-name-base>org.openide.loaders</code-name-base>
208
                    <code-name-base>org.openide.loaders</code-name-base>
209
                    <build-prerequisite/>
209
                    <build-prerequisite/>
210
                    <compile-dependency/>
210
                    <compile-dependency/>
211
                    <run-dependency>
211
                    <run-dependency>
212
                        <specification-version>5.5</specification-version>
212
                        <specification-version>5.5</specification-version>
213
                    </run-dependency>
213
                    </run-dependency>
214
                </dependency>
214
                </dependency>
215
                <dependency>
215
                <dependency>
216
                    <code-name-base>org.openide.nodes</code-name-base>
216
                    <code-name-base>org.openide.nodes</code-name-base>
217
                    <build-prerequisite/>
217
                    <build-prerequisite/>
218
                    <compile-dependency/>
218
                    <compile-dependency/>
219
                    <run-dependency>
219
                    <run-dependency>
220
                        <specification-version>7.23</specification-version>
220
                        <specification-version>7.23</specification-version>
221
                    </run-dependency>
221
                    </run-dependency>
222
                </dependency>
222
                </dependency>
223
                <dependency>
223
                <dependency>
224
                    <code-name-base>org.openide.text</code-name-base>
224
                    <code-name-base>org.openide.text</code-name-base>
225
                    <build-prerequisite/>
225
                    <build-prerequisite/>
226
                    <compile-dependency/>
226
                    <compile-dependency/>
227
                    <run-dependency>
227
                    <run-dependency>
228
                        <specification-version>6.16</specification-version>
228
                        <specification-version>6.16</specification-version>
229
                    </run-dependency>
229
                    </run-dependency>
230
                </dependency>
230
                </dependency>
231
                <dependency>
231
                <dependency>
232
                    <code-name-base>org.openide.util</code-name-base>
232
                    <code-name-base>org.openide.util</code-name-base>
233
                    <build-prerequisite/>
233
                    <build-prerequisite/>
234
                    <compile-dependency/>
234
                    <compile-dependency/>
235
                    <run-dependency>
235
                    <run-dependency>
236
                        <specification-version>8.0</specification-version>
236
                        <specification-version>8.0</specification-version>
237
                    </run-dependency>
237
                    </run-dependency>
238
                </dependency>
238
                </dependency>
239
                <dependency>
239
                <dependency>
240
                    <code-name-base>org.openide.util.lookup</code-name-base>
240
                    <code-name-base>org.openide.util.lookup</code-name-base>
241
                    <build-prerequisite/>
241
                    <build-prerequisite/>
242
                    <compile-dependency/>
242
                    <compile-dependency/>
243
                    <run-dependency>
243
                    <run-dependency>
244
                        <specification-version>8.0</specification-version>
244
                        <specification-version>8.0</specification-version>
245
                    </run-dependency>
245
                    </run-dependency>
246
                </dependency>
246
                </dependency>
247
                <dependency>
247
                <dependency>
248
                    <code-name-base>org.openide.windows</code-name-base>
248
                    <code-name-base>org.openide.windows</code-name-base>
249
                    <build-prerequisite/>
249
                    <build-prerequisite/>
250
                    <compile-dependency/>
250
                    <compile-dependency/>
251
                    <run-dependency>
251
                    <run-dependency>
252
                        <specification-version>6.2</specification-version>
252
                        <specification-version>6.2</specification-version>
253
                    </run-dependency>
253
                    </run-dependency>
254
                </dependency>
254
                </dependency>
255
            </module-dependencies>
255
            </module-dependencies>
256
            <test-dependencies>
256
            <test-dependencies>
257
                <test-type>
257
                <test-type>
258
                    <name>qa-functional</name>
258
                    <name>qa-functional</name>
259
                    <test-dependency>
259
                    <test-dependency>
260
                        <code-name-base>org.netbeans.api.java</code-name-base>
260
                        <code-name-base>org.netbeans.api.java</code-name-base>
261
                        <compile-dependency/>
261
                        <compile-dependency/>
262
                    </test-dependency>
262
                    </test-dependency>
263
                    <test-dependency>
263
                    <test-dependency>
264
                        <code-name-base>org.netbeans.api.java.classpath</code-name-base>
264
                        <code-name-base>org.netbeans.api.java.classpath</code-name-base>
265
                        <compile-dependency/>
265
                        <compile-dependency/>
266
                    </test-dependency>
266
                    </test-dependency>
267
                    <test-dependency>
267
                    <test-dependency>
268
                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
268
                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
269
                        <compile-dependency/>
269
                        <compile-dependency/>
270
                    </test-dependency>
270
                    </test-dependency>
271
                    <test-dependency>
271
                    <test-dependency>
272
                        <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
272
                        <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
273
                        <recursive/>
273
                        <recursive/>
274
                        <compile-dependency/>
274
                        <compile-dependency/>
275
                    </test-dependency>
275
                    </test-dependency>
276
                    <test-dependency>
276
                    <test-dependency>
277
                        <code-name-base>org.openide.filesystems</code-name-base>
277
                        <code-name-base>org.openide.filesystems</code-name-base>
278
                        <compile-dependency/>
278
                        <compile-dependency/>
279
                    </test-dependency>
279
                    </test-dependency>
280
                    <test-dependency>
280
                    <test-dependency>
281
                        <code-name-base>org.openide.loaders</code-name-base>
281
                        <code-name-base>org.openide.loaders</code-name-base>
282
                        <compile-dependency/>
282
                        <compile-dependency/>
283
                    </test-dependency>
283
                    </test-dependency>
284
                    <test-dependency>
284
                    <test-dependency>
285
                        <code-name-base>org.openide.nodes</code-name-base>
285
                        <code-name-base>org.openide.nodes</code-name-base>
286
                        <compile-dependency/>
286
                        <compile-dependency/>
287
                    </test-dependency>
287
                    </test-dependency>
288
                    <test-dependency>
288
                    <test-dependency>
289
                        <code-name-base>org.openide.text</code-name-base>
289
                        <code-name-base>org.openide.text</code-name-base>
290
                        <compile-dependency/>
290
                        <compile-dependency/>
291
                    </test-dependency>
291
                    </test-dependency>
292
                    <test-dependency>
292
                    <test-dependency>
293
                        <code-name-base>org.openide.util</code-name-base>
293
                        <code-name-base>org.openide.util</code-name-base>
294
                        <compile-dependency/>
294
                        <compile-dependency/>
295
                    </test-dependency>
295
                    </test-dependency>
296
                    <test-dependency>
296
                    <test-dependency>
297
                        <code-name-base>org.openide.util.lookup</code-name-base>
297
                        <code-name-base>org.openide.util.lookup</code-name-base>
298
                        <compile-dependency/>
298
                        <compile-dependency/>
299
                    </test-dependency>
299
                    </test-dependency>
300
                </test-type>
300
                </test-type>
301
                <test-type>
301
                <test-type>
302
                    <name>unit</name>
302
                    <name>unit</name>
303
                    <test-dependency>
303
                    <test-dependency>
304
                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
304
                        <code-name-base>org.netbeans.insane</code-name-base>
305
                        <compile-dependency/>
305
                        <compile-dependency/>
306
                    </test-dependency>
306
                    </test-dependency>
307
                    <test-dependency>
307
                    <test-dependency>
308
                        <code-name-base>org.netbeans.modules.java.hints.test</code-name-base>
308
                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
309
                        <compile-dependency/>
309
                        <compile-dependency/>
310
                    </test-dependency>
310
                    </test-dependency>
311
                </test-type>
311
                    <test-dependency>
312
            </test-dependencies>
312
                        <code-name-base>org.netbeans.modules.java.hints.test</code-name-base>
313
            <public-packages/>
313
                        <compile-dependency/>
314
        </data>
314
                    </test-dependency>
315
    </configuration>
315
                    <test-dependency>
316
</project>
316
                        <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
317
                        <compile-dependency/>
318
                    </test-dependency>
319
                </test-type>
320
            </test-dependencies>
321
            <public-packages/>
322
        </data>
323
    </configuration>
324
</project>
(-)a/apisupport.refactoring/src/org/netbeans/modules/apisupport/hints/DataObjectRegistrationHinter.java (-21 / +29 lines)
Lines 73-78 Link Here
73
import com.sun.source.tree.ModifiersTree;
73
import com.sun.source.tree.ModifiersTree;
74
import com.sun.source.tree.NewArrayTree;
74
import com.sun.source.tree.NewArrayTree;
75
import com.sun.source.tree.Tree;
75
import com.sun.source.tree.Tree;
76
import org.openide.filesystems.FileStateInvalidException;
76
77
77
/**
78
/**
78
 * #207219: {@code DataObject.Registration} conversion.
79
 * #207219: {@code DataObject.Registration} conversion.
Lines 117-146 Link Here
117
            String actionsMime = Utility.getMimeTypeFromActionsPath(file.getPath());
118
            String actionsMime = Utility.getMimeTypeFromActionsPath(file.getPath());
118
            //
119
            //
119
            // try get DataObject / DataObject.Factory available in this project
120
            // try get DataObject / DataObject.Factory available in this project
120
            Map<String, List<String>> visibleLoaderFactories = new HashMap<String, List<String>>();
121
            Map<String, List<String>> visibleLoaderFactories = Utility.getVisibleLoader(ctx, file);
121
            FileObject startingPath = file.getFileSystem().findResource(LOADERS_FOLDER);
122
            FileObject startingPath = file.getFileSystem().findResource(LOADERS_FOLDER);
122
            if (startingPath != null) {
123
            if (startingPath != null) {
123
                for (FileObject aLoadersFileObject : NbCollections.iterable(startingPath.getChildren(true))) {
124
                    if (aLoadersFileObject.getPath().contains(FACTORIES_FOLDER)) { // its a factory
125
124
126
                        final Object instanceCreate = ctx.instanceAttribute(aLoadersFileObject);
127
                        if (instanceCreate != null) {
128
129
                            if (!METHOD_DOPOOL_FACTORY.equals(instanceCreate)) {
130
131
                                String ic = instanceCreate.toString();
132
133
                                if (visibleLoaderFactories.containsKey(ic)) {
134
                                    visibleLoaderFactories.get(ic).add(Utility.getMimeTypeFromFactoryPath(aLoadersFileObject.getPath()));
135
                                } else {
136
                                    List<String> mime = new LinkedList<String>();
137
                                    mime.add(Utility.getMimeTypeFromFactoryPath(aLoadersFileObject.getPath()));
138
                                    visibleLoaderFactories.put(ic, mime);
139
                                }
140
                            }
141
                        }
142
                    }
143
                }
144
                if (visibleLoaderFactories.isEmpty()) {
125
                if (visibleLoaderFactories.isEmpty()) {
145
                    ctx.addHint(Severity.VERIFIER, DataObjectRegistrationHinter_no_DataObject());
126
                    ctx.addHint(Severity.VERIFIER, DataObjectRegistrationHinter_no_DataObject());
146
                } else {
127
                } else {
Lines 490-494 Link Here
490
        private static String getMimeTypeFromActionsPath(String path) {
471
        private static String getMimeTypeFromActionsPath(String path) {
491
            return getMime(path, ACTIONS_FOLDER);
472
            return getMime(path, ACTIONS_FOLDER);
492
        }
473
        }
474
475
        protected static Map<String, List<String>> getVisibleLoader(final Context ctx, final FileObject file) throws FileStateInvalidException {
476
            Map<String, List<String>> visibleLoaderFactories = new HashMap<String, List<String>>();
477
            FileObject startingPath = file.getFileSystem().findResource(LOADERS_FOLDER);
478
            for (FileObject aLoadersFileObject : NbCollections.iterable(startingPath.getChildren(true))) {
479
                if (aLoadersFileObject.getPath().contains(FACTORIES_FOLDER)) { // its a factory
480
481
                    final Object instanceCreate = ctx.instanceAttribute(aLoadersFileObject);
482
                    if (instanceCreate != null) {
483
484
                        if (!METHOD_DOPOOL_FACTORY.equals(instanceCreate)) {
485
486
                            String ic = instanceCreate.toString();
487
488
                            if (visibleLoaderFactories.containsKey(ic)) {
489
                                visibleLoaderFactories.get(ic).add(Utility.getMimeTypeFromFactoryPath(aLoadersFileObject.getPath()));
490
                            } else {
491
                                List<String> mime = new LinkedList<String>();
492
                                mime.add(Utility.getMimeTypeFromFactoryPath(aLoadersFileObject.getPath()));
493
                                visibleLoaderFactories.put(ic, mime);
494
                            }
495
                        }
496
                    }
497
                }
498
            }
499
            return visibleLoaderFactories;
500
        }
493
    }
501
    }
494
}
502
}
(-)a/apisupport.refactoring/src/org/netbeans/modules/apisupport/hints/Hinter.java (+49 lines)
Lines 323-328 Link Here
323
            }
323
            }
324
        }
324
        }
325
325
326
        
327
        public void findAndModifyMultipleDeclaration(Map<Object,ModifyDeclarationTask> mappedDeclarations) throws IOException {
328
            for (Map.Entry<Object, ModifyDeclarationTask> aDeclaration : mappedDeclarations.entrySet()) {
329
                final Object instanceAttribute = aDeclaration.getKey();
330
                final ModifyDeclarationTask task = aDeclaration.getValue();
331
                
332
                FileObject java = findDeclaringSource(instanceAttribute);
333
                if (java == null) {
334
                    DialogDisplayer.getDefault().notify(new Message(Hinter_missing_instance_class(instanceAttribute), NotifyDescriptor.WARNING_MESSAGE));
335
                    return;
336
                }
337
                JavaSource js = JavaSource.forFileObject(java);
338
                if (js == null) {
339
                    throw new IOException("No source info for " + java);
340
                }
341
                js.runModificationTask(new Task<WorkingCopy>() {
342
343
                    public @Override
344
                    void run(WorkingCopy wc) throws Exception {
345
                        wc.toPhase(JavaSource.Phase.RESOLVED);
346
                        if (DataObject.find(layer.getLayerFile()).isModified()) { // #207077
347
                            DialogDisplayer.getDefault().notify(new Message(Hinter_do_not_edit_layer(), NotifyDescriptor.WARNING_MESSAGE));
348
                            return;
349
                        }
350
                        Element decl = findDeclaration(wc, instanceAttribute);
351
                        if (decl == null) {
352
                            DialogDisplayer.getDefault().notify(new Message(Hinter_missing_instance_class(instanceAttribute), NotifyDescriptor.WARNING_MESSAGE));
353
                            return;
354
                        }
355
                        ModifiersTree mods;
356
                        if (decl.getKind() == ElementKind.CLASS) {
357
                            mods = wc.getTrees().getTree((TypeElement) decl).getModifiers();
358
                        } else {
359
                            mods = wc.getTrees().getTree((ExecutableElement) decl).getModifiers();
360
                        }
361
                        task.run(wc, decl, mods);
362
                    }
363
                }).commit();
364
                SaveCookie sc = DataObject.find(java).getLookup().lookup(SaveCookie.class);
365
                if (sc != null) {
366
                    sc.save();
367
                }
368
            }
369
            this.delete(file());
370
            saveLayer();
371
                
372
        }
373
374
        
326
        /**
375
        /**
327
         * Tries to find the instance associated with a file.
376
         * Tries to find the instance associated with a file.
328
         * If it is a folder, or not a {@code *.instance} file, null is returned.
377
         * If it is a folder, or not a {@code *.instance} file, null is returned.
(-)a/apisupport.refactoring/src/org/netbeans/modules/apisupport/hints/MIMEResolverRegistrationHinter.java (+614 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.apisupport.hints;
43
44
import com.sun.source.tree.ModifiersTree;
45
import java.io.ByteArrayInputStream;
46
import java.io.IOException;
47
import java.net.URI;
48
import java.net.URL;
49
import java.util.ArrayList;
50
import java.util.HashMap;
51
import java.util.List;
52
import java.util.Map;
53
import javax.lang.model.element.Element;
54
import org.netbeans.api.java.classpath.ClassPath;
55
import org.netbeans.api.java.source.GeneratorUtilities;
56
import org.netbeans.api.java.source.WorkingCopy;
57
import static org.netbeans.modules.apisupport.hints.Bundle.*;
58
import org.netbeans.spi.editor.hints.ChangeInfo;
59
import org.netbeans.spi.editor.hints.Fix;
60
import org.netbeans.spi.editor.hints.Severity;
61
import org.openide.DialogDisplayer;
62
import org.openide.NotifyDescriptor;
63
import org.openide.filesystems.FileObject;
64
import org.openide.filesystems.MIMEResolver;
65
import org.openide.filesystems.URLMapper;
66
import org.openide.util.Exceptions;
67
import org.openide.util.NbBundle.Messages;
68
import org.openide.util.NbCollections;
69
import org.openide.util.lookup.ServiceProvider;
70
import org.openide.xml.EntityCatalog;
71
import org.openide.xml.XMLUtil;
72
import org.w3c.dom.Document;
73
import org.w3c.dom.Node;
74
import org.w3c.dom.NodeList;
75
import org.xml.sax.EntityResolver;
76
import org.xml.sax.InputSource;
77
import org.xml.sax.SAXException;
78
79
/**
80
 *
81
 * #207960: convert MimeResolver
82
 */
83
@ServiceProvider(service = Hinter.class)
84
public class MIMEResolverRegistrationHinter implements Hinter {
85
86
    public static final String ACTIONS_FOLDER = "Actions"; //NOI18N
87
    public static final String METHOD_DOPOOL_FACTORY = "method:org.openide.loaders.DataLoaderPool.factory"; //NOI18N
88
    private static final String LOADERS_FOLDER = "Loaders/"; //NOI18N
89
    private static final String FACTORIES_FOLDER = "Factories"; //NOI18N
90
    private static final String SERVICES_MIME_RESOLVER = "Services/MIMEResolver"; //NOI18N
91
92
    @Override
93
    @Messages({"MIMEResolverRegistrationHinter.noTarget=Cannot find a reasonable target for refactory",
94
        "MIMEResolverRegistrationHinter.urlInvalid=URL not valid", "MIMEResolverRegistrationHinter.allInOne=into respective loader"})
95
    public void process(final Context ctx) throws Exception {
96
        final FileObject file = ctx.file();
97
        final Object instanceCreate = ctx.instanceAttribute(file);
98
        // cannot be folder
99
        if (!file.isData()) {
100
            return;
101
        }
102
        // must start with Services/MimeResolver
103
        if (file.getPath().startsWith(SERVICES_MIME_RESOLVER)) {
104
            if (checkAttributes(file, ctx)) {
105
                if (annotationsMIMEResolverAvailable(ctx)) {
106
                    Map<String, List<String>> visibleTarget = DataObjectRegistrationHinter.Utility.getVisibleLoader(ctx, file);
107
                    if (visibleTarget.isEmpty()) {
108
                        ctx.addHint(Severity.ERROR, MIMEResolverRegistrationHinter_noTarget());
109
                    } else {
110
                        List<Fix> fixes = new ArrayList<Fix>(); // prepare list of fixes
111
// get information for strategy 
112
                        final String url = (String) file.getAttribute("WritableXMLFileSystem.url"); //NOI18N
113
                        if (url == null && file.getSize() > 0) {
114
                            // XXX cannot handle inline content
115
                            ctx.addHint(Severity.WARNING, MIMEResolverRegistrationHinter_urlInvalid());
116
                            return;
117
                        }
118
119
                        if (url != null) {
120
                            FileObject xmlMimeFile = null;
121
                            URI u = new URI(url);
122
                            if (!u.isAbsolute()) {
123
                                URL[] layers = (URL[]) file.getAttribute("layers"); //NOI18N
124
                                assert layers != null && layers.length == 1;
125
                                FileObject layer = URLMapper.findFileObject(layers[0]);
126
                                if (layer != null) {
127
                                    ClassPath src = ClassPath.getClassPath(layer, ClassPath.SOURCE);
128
                                    String path = src.getResourceName(layer);
129
                                    if (path != null) {
130
                                        u = new URI("nbres", "/" + path, null).resolve(u); //NOI18N //NOI18N
131
                                    }
132
                                    xmlMimeFile = src.findResource("/" + u.getPath()); //NOI18N
133
                                }
134
                            }
135
136
                            MIMEResolverStrategyManager sm = null;
137
                            if (xmlMimeFile != null) {
138
                                sm = new MIMEResolverStrategyManager(xmlMimeFile.toURL());
139
                            }
140
141
                            boolean allLoaderAccessible = false;
142
                            if (sm != null && !sm.isUseComplex()) {
143
                                // warn for use NameSpaceRegistration
144
                                // all mimetype at once
145
                                final Map<Object, Context.ModifyDeclarationTask> modifications = sm.checkLoaderAccessibility(visibleTarget, ctx);
146
                                allLoaderAccessible = !modifications.isEmpty();
147
148
                                if (allLoaderAccessible) {
149
                                    ctx.addHint(Severity.WARNING, ctx.standardAnnotationDescription(), new Fix() {
150
151
                                        @Override
152
                                        public String getText() {
153
                                            return ctx.standardAnnotationFixDescription() + " " + MIMEResolverRegistrationHinter_allInOne(); //NOI18N
154
                                        }
155
156
                                        @Override
157
                                        public ChangeInfo implement() throws Exception {
158
                                            ctx.findAndModifyMultipleDeclaration(modifications);
159
                                            return null;
160
                                        }
161
                                    });
162
                                }
163
164
                            }
165
                            if (sm == null || !allLoaderAccessible || sm.isUseComplex()) {
166
                                for (Map.Entry<String, List<String>> loader : visibleTarget.entrySet()) { // 
167
                                    StringBuilder sbMime = new StringBuilder();
168
                                    for (String aMime : loader.getValue()) {
169
                                        sbMime.append(aMime);
170
                                        sbMime.append(","); //NOI18N
171
                                    }
172
                                    sbMime.deleteCharAt(sbMime.length() - 1);
173
174
                                    String fname = loader.getKey().substring(loader.getKey().lastIndexOf(".") + 1) + ".java"; //NOI18N
175
                                    final String text = DataObjectRegistrationHinter_fix_special(fname, sbMime);
176
                                    final String fixParam = loader.getKey();
177
178
                                    fixes.add(new Fix() {
179
180
                                        @Override
181
                                        public String getText() {
182
                                            return ctx.standardAnnotationFixDescription() + " " + text; //NOI18N
183
                                        }
184
185
                                        @Override
186
                                        public ChangeInfo implement() throws Exception {
187
                                            ctx.findAndModifyDeclaration(fixParam, new RegisterMIMEGenericResolver(ctx, url));
188
                                            return null;
189
                                        }
190
                                    });
191
                                }
192
                                if (!fixes.isEmpty()) {
193
                                    ctx.addHint(Severity.WARNING, ctx.standardAnnotationDescription(), fixes.toArray(new Fix[fixes.size()]));
194
195
                                }
196
                            }
197
                        }
198
                    }
199
                }
200
            }
201
        }
202
    }
203
204
    @Messages("MIMEResolverRegistrationHinter.missing_dep=You must add a dependency on org.openide.filesystems (7.58+) before using this fix.")
205
    private boolean annotationsMIMEResolverAvailable(Context ctx) {
206
        if (ctx.canAccess(MIMEResolver.Registration.class.getName())
207
                && ctx.canAccess(MIMEResolver.ExtensionRegistration.class.getName())
208
                && ctx.canAccess(MIMEResolver.NamespaceRegistration.class.getName())) {
209
            return true;
210
        } else {
211
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(MIMEResolverRegistrationHinter_missing_dep(), NotifyDescriptor.WARNING_MESSAGE));
212
            return false;
213
        }
214
    }
215
216
    @Messages({
217
        "# {0} - file attribute name", "MIMEResolverRegistrationHinter_unrecognized_attr=Unrecognized MimeResolver attribute: {0}",
218
        "MIMEResolverRegistrationHinter.pleaseConvert=Please convert to displayName to be able to use MimeResolver hinter"})
219
    private boolean checkAttributes(FileObject file, Context ctx) {
220
        boolean attributesCompatible = true;
221
        for (String attr : NbCollections.iterable(file.getAttributes())) {
222
            if (!attr.matches("position|displayName|SystemFileSystem.localizingBundle")) { //NOI18N
223
224
                ctx.addHint(Severity.WARNING, MIMEResolverRegistrationHinter_unrecognized_attr(attr));
225
                attributesCompatible = false;
226
            }
227
        }
228
        if (file.getAttribute("literal:SystemFileSystem.localizingBundle") != null) { //NOI18N
229
            attributesCompatible = false;
230
            ctx.addHint(Severity.HINT, MIMEResolverRegistrationHinter_pleaseConvert());
231
        }
232
        return attributesCompatible;
233
    }
234
235
    private static class RegisterMIMEGenericResolver implements Context.ModifyDeclarationTask {
236
237
        private static final String MIMERESOLVER_REGISTRATION = "org.openide.filesystems.MIMEResolver.Registration"; //NOI18N
238
        private final Context ctx;
239
        private String url;
240
241
        public RegisterMIMEGenericResolver(Context ctx, String url) {
242
            this.ctx = ctx;
243
            this.url = url;
244
        }
245
246
        @Override
247
        public void run(WorkingCopy wc, Element declaration, ModifiersTree modifiers) throws Exception {
248
            Map<String, Object> params = new HashMap<String, Object>();
249
            FileObject file = ctx.file();
250
            String displayName = ctx.bundlevalue(file.getAttribute("literal:displayName"), declaration); //NOI18N
251
252
            if (displayName == null) {
253
                // checkAttributes method tries to warn user to avoid this fallback
254
                // unaware if fix can be chained
255
                displayName = "#TODO"; //NOI18N
256
            }
257
            params.put("position", file.getAttribute("position")); //NOI18N
258
            params.put("displayName", displayName); //NOI18N
259
            if (url != null) {
260
                URI u = new URI(url);
261
                if (!u.isAbsolute()) {
262
                    URL[] layers = (URL[]) file.getAttribute("layers"); //NOI18N
263
                    assert layers != null && layers.length == 1;
264
                    FileObject layer = URLMapper.findFileObject(layers[0]);
265
                    if (layer != null) {
266
                        ClassPath src = ClassPath.getClassPath(layer, ClassPath.SOURCE);
267
                        String path = src.getResourceName(layer);
268
                        if (path != null) {
269
                            u = new URI("nbres", "/" + path, null).resolve(u); //NOI18N //NOI18N
270
                        }
271
                    }
272
                }
273
                if (u.getScheme() != null && u.getScheme().matches("nbres(loc)?")) { //NOI18N
274
                    params.put("resource", u.getPath()); //NOI18N
275
                }
276
            }
277
            ModifiersTree mt = ctx.addAnnotation(wc, modifiers, MIMERESOLVER_REGISTRATION, null, params);
278
            wc.rewrite(modifiers, GeneratorUtilities.get(wc).importFQNs(mt));
279
            ctx.delete(file);
280
        }
281
    }
282
283
    private static abstract class AbstractMimeSpecificResolver implements Context.ModifyDeclarationTask {
284
285
        private final Context ctx;
286
        private final String annotation;
287
        final Registration registration;
288
289
        public AbstractMimeSpecificResolver(Context ctx, Registration registration, String annotation) {
290
            this.ctx = ctx;
291
            this.annotation = annotation;
292
            this.registration = registration;
293
        }
294
295
        @Override
296
        public void run(WorkingCopy wc, Element declaration, ModifiersTree modifiers) throws Exception {
297
            Map<String, Object> params = new HashMap<String, Object>();
298
            FileObject file = ctx.file();
299
            String displayName = ctx.bundlevalue(file.getAttribute("literal:displayName"), declaration); //NOI18N
300
301
            if (displayName == null) {
302
                // checkAttributes method tries to warn user to avoid this fallback
303
                // unaware if fix can be chained
304
                displayName = "#TODO"; //NOI18N
305
            }
306
            params.put("position", file.getAttribute("position")); //NOI18N
307
            params.put("displayName", displayName); //NOI18N
308
            specificRun(wc, declaration, modifiers, params);
309
310
            ModifiersTree mt = ctx.addAnnotation(wc, modifiers, annotation, null, params);
311
            wc.rewrite(modifiers, GeneratorUtilities.get(wc).importFQNs(mt));
312
        }
313
314
        public abstract void specificRun(WorkingCopy wc, Element declaration, ModifiersTree modifiers, Map<String, Object> params);
315
    }
316
317
    private static class RegisterMIMENamespaceResolver extends AbstractMimeSpecificResolver {
318
319
        private static final String MIMERESOLVER_NAMESPACEREGISTRATION = "org.openide.filesystems.MIMEResolver.NamespaceRegistration"; //NOI18N
320
321
        public RegisterMIMENamespaceResolver(Context ctx, NamespaceRegistration nr) {
322
            super(ctx, nr, MIMERESOLVER_NAMESPACEREGISTRATION);
323
        }
324
325
        @Override
326
        public void specificRun(WorkingCopy wc, Element declaration, ModifiersTree modifiers, Map<String, Object> params) {
327
            params.put("mimeType", registration.mime); //NOI18N
328
            if (!registration.getExt().isEmpty()) {
329
                params.put("acceptedExtension", registration.getExt().toArray()); //NOI18N
330
            }
331
            //params.put("checkedExtension", ((NamespaceRegistration)registration).getExt());
332
            if (!((NamespaceRegistration) registration).getRootElement().isEmpty()) {
333
                params.put("elementName", ((NamespaceRegistration) registration).getRootElement()); //NOI18N
334
            }
335
            if (!((NamespaceRegistration) registration).getElementNS().isEmpty()) {
336
                params.put("elementNS", ((NamespaceRegistration) registration).getElementNS().toArray()); //NOI18N
337
            }
338
            if (!((NamespaceRegistration) registration).getPublicID().isEmpty()) {
339
                params.put("doctypePublicId", ((NamespaceRegistration) registration).getPublicID().toArray()); //NOI18N
340
            }
341
342
        }
343
    }
344
345
    private static class RegisterMIMEExtensionResolver extends AbstractMimeSpecificResolver {
346
347
        private static final String MIMERESOLVER_EXTENSIONREGISTRATION = "org.openide.filesystems.MIMEResolver.ExtensionRegistration"; //NOI18N
348
349
        public RegisterMIMEExtensionResolver(Context ctx, ExtensionRegistration er) {
350
            super(ctx, er, MIMERESOLVER_EXTENSIONREGISTRATION);
351
        }
352
353
        @Override
354
        public void specificRun(WorkingCopy wc, Element declaration, ModifiersTree modifiers, Map<String, Object> params) {
355
            params.put("mimeType", registration.mime); //NOI18N
356
            if (!registration.getExt().isEmpty()) {
357
                params.put("extension", registration.getExt().toArray()); //NOI18N
358
            }
359
        }
360
    }
361
362
    protected abstract class Registration {
363
364
        List<String> ext = new ArrayList<String>();
365
        String mime;
366
367
        public Registration(String mime) {
368
            this.mime = mime;
369
        }
370
371
        public void addExt(String mimeType) {
372
            ext.add(mimeType);
373
        }
374
375
        public List<String> getExt() {
376
            return ext;
377
        }
378
    }
379
380
    protected class ExtensionRegistration extends Registration {
381
382
        public ExtensionRegistration(String mime) {
383
            super(mime);
384
        }
385
    }
386
387
    protected class NamespaceRegistration extends Registration {
388
389
        List<String> elementNS = new ArrayList<String>();
390
        List<String> doctype = new ArrayList<String>();
391
        String rootElement = ""; //NOI18N
392
393
        public NamespaceRegistration(String mime) {
394
            super(mime);
395
        }
396
397
        private void addPublicId(String publicid) {
398
            doctype.add(publicid);
399
        }
400
401
        public List<String> getPublicID() {
402
            return doctype;
403
        }
404
405
        public void setRootElement(String rootElement) {
406
            this.rootElement = rootElement;
407
        }
408
409
        public String getRootElement() {
410
            return this.rootElement;
411
        }
412
413
        private void addElementNS(String attribute) {
414
            elementNS.add(attribute);
415
        }
416
417
        public List<String> getElementNS() {
418
            return elementNS;
419
        }
420
    }
421
422
    class MIMEResolverStrategyManager {
423
424
        private URL file;
425
        protected Map<String, ExtensionRegistration> extensionsRegistrations = new HashMap<String, ExtensionRegistration>();
426
        protected Map<String, NamespaceRegistration> nameSpaceRegistrations = new HashMap<String, NamespaceRegistration>();
427
        private boolean useComplex;  //private List<>  ;
428
429
        MIMEResolverStrategyManager(URL mimeXmlUrl) {
430
            file = mimeXmlUrl;
431
            useComplex = false;
432
            // parse file
433
            try {
434
                Document doc = XMLUtil.parse(new InputSource(file.toString()), false, false, null, new EntityResolver() {
435
436
                    @Override
437
                    public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
438
                        if (publicId.contains("-//NetBeans//DTD MIME Resolver")) { //NOI18N
439
                            return new InputSource(new ByteArrayInputStream(new byte[0]));
440
                        } else {
441
                            return EntityCatalog.getDefault().resolveEntity(publicId, systemId);
442
443
                        }
444
                    }
445
                });
446
                NodeList nl = doc.getElementsByTagName("file"); //NOI18N
447
                for (int i = 0;
448
                        i < nl.getLength();
449
                        i++) {
450
                    useComplex = useComplex || filterAFile(nl.item(i));
451
                }
452
            } catch (SAXException ex) {
453
                Exceptions.printStackTrace(ex);
454
            } catch (IOException ex) {
455
                Exceptions.printStackTrace(ex);
456
            }
457
        }
458
459
        private boolean filterAFile(Node nl) {
460
            int invalidTags = 0; // according to dtd 1.1
461
//
462
            // ext is not invalid
463
            invalidTags += ((org.w3c.dom.Element) nl).getElementsByTagName("mime").getLength(); //NOI18N
464
            invalidTags += ((org.w3c.dom.Element) nl).getElementsByTagName("magic").getLength(); //NOI18N
465
            invalidTags += ((org.w3c.dom.Element) nl).getElementsByTagName("fattr").getLength(); //NOI18N
466
            invalidTags += ((org.w3c.dom.Element) nl).getElementsByTagName("pattern").getLength(); //NOI18N
467
            invalidTags += ((org.w3c.dom.Element) nl).getElementsByTagName("name").getLength(); //NOI18N
468
//
469
            // resolver is not invalid
470
            invalidTags += ((org.w3c.dom.Element) nl).getElementsByTagName("exit").getLength(); //NOI18N
471
472
            boolean registrationForcedToXML = invalidTags > 0;
473
            if (!registrationForcedToXML) {
474
                NodeList resolver = ((org.w3c.dom.Element) nl).getElementsByTagName("resolver"); //NOI18N
475
                assert (resolver.getLength() == 1);
476
                org.w3c.dom.Element resolverElement = (org.w3c.dom.Element) resolver.item(0);
477
                String mimeType = resolverElement.getAttribute("mime"); //NOI18N
478
                assert (!mimeType.isEmpty());
479
                if (((org.w3c.dom.Element) nl).getElementsByTagName("xml-rule").getLength() > 0) { //NOI18N
480
                    registrationForcedToXML = registrationForcedToXML || addNamespaceRegistration(mimeType, nl);
481
                } else {
482
                    addExtRegistration(mimeType, nl);
483
                }
484
            }
485
            return registrationForcedToXML;
486
        }
487
488
        private boolean addNamespaceRegistration(String mime, Node nl) {
489
            NamespaceRegistration namespaceRegistation = nameSpaceRegistrations.get(mime);
490
            if (namespaceRegistation == null) {
491
                namespaceRegistation = new NamespaceRegistration(mime);
492
                nameSpaceRegistrations.put(mime, namespaceRegistation);
493
            }
494
495
            addExtension(namespaceRegistation, nl);
496
            // pi not taken into account
497
            boolean registrationForcedToXML = ((org.w3c.dom.Element) nl).getElementsByTagName("pi").getLength() > 0; //NOI18N
498
            if (!registrationForcedToXML) { // no pi
499
                // check for doctype
500
                // DOCTYPE part
501
                NodeList doctype = ((org.w3c.dom.Element) nl).getElementsByTagName("doctype"); //NOI18N
502
                assert (doctype.getLength() <= 1);
503
                if (doctype.getLength() > 0) {
504
                    org.w3c.dom.Element docElement = (org.w3c.dom.Element) doctype.item(0);
505
                    if (docElement.getAttribute("public-id").isEmpty()) { //NOI18N
506
                        // getall publicidtag
507
                        NodeList publictype = ((org.w3c.dom.Element) docElement).getElementsByTagName("public-id"); //NOI18N
508
                        for (int i = 0; i < publictype.getLength(); i++) {
509
                            org.w3c.dom.Element publicElement = (org.w3c.dom.Element) publictype.item(i);
510
                            if (publicElement.getAttribute("id").isEmpty()) { //NOI18N
511
                                registrationForcedToXML = true;
512
                            } else {
513
                                namespaceRegistation.addPublicId(publicElement.getAttribute("id")); //NOI18N
514
                            }
515
                        }
516
                    } else {
517
                        namespaceRegistation.addPublicId(docElement.getAttribute("public-id")); //NOI18N
518
                    }
519
                }
520
521
                // ELEMENT part
522
                NodeList elementList = ((org.w3c.dom.Element) nl).getElementsByTagName("element"); //NOI18N
523
                assert (elementList.getLength() <= 1);
524
                if (elementList.getLength() > 0) {
525
                    org.w3c.dom.Element element = (org.w3c.dom.Element) elementList.item(0);
526
                    if (element.getAttribute("name").isEmpty()) { //NOI18N
527
                        registrationForcedToXML = true; // no name force
528
                    } else {
529
                        if (namespaceRegistation.getRootElement().isEmpty()) {
530
                            namespaceRegistation.setRootElement(element.getAttribute("name")); //NOI18N
531
                            registrationForcedToXML = ((org.w3c.dom.Element) nl).getElementsByTagName("attr").getLength() > 0; // attr attribute found => cannot handle //NOI18N
532
533
                            NodeList nsList = ((org.w3c.dom.Element) element).getElementsByTagName("ns"); //NOI18N
534
                            if (nsList.getLength() > 0) {
535
                                for (int i = 0; i < nsList.getLength(); i++) {
536
                                    org.w3c.dom.Element nsElement = (org.w3c.dom.Element) nsList.item(i);
537
                                    if (!nsElement.getAttribute("ns").isEmpty()) { //NOI18N
538
                                        namespaceRegistation.addElementNS(nsElement.getAttribute("ns")); //NOI18N
539
                                    } else {
540
                                        registrationForcedToXML = true;
541
                                    }
542
                                }
543
                            } else {
544
                                if (!element.getAttribute("ns").isEmpty()) { //NOI18N
545
                                    namespaceRegistation.addElementNS(element.getAttribute("ns")); //NOI18N
546
                                }
547
                            }
548
549
                        } else {
550
                            registrationForcedToXML = true; // allready an element => fail
551
                        }
552
                    }
553
                }
554
555
            }
556
            return registrationForcedToXML;
557
        }
558
559
        private void addExtRegistration(String mime, Node nl) {
560
            ExtensionRegistration extRegistration = extensionsRegistrations.get(mime);
561
            if (extRegistration == null) {
562
                extRegistration = new ExtensionRegistration(mime);
563
                extensionsRegistrations.put(mime, extRegistration);
564
            }
565
            addExtension(extRegistration, nl);
566
            // thats all for extension based
567
        }
568
569
        private void addExtension(Registration registration, Node nl) {
570
            NodeList ext = ((org.w3c.dom.Element) nl).getElementsByTagName("ext"); //NOI18N
571
            for (int i = 0; i < ext.getLength(); i++) {
572
                registration.addExt((((org.w3c.dom.Element) ext.item(i)).getAttribute("name"))); //NOI18N
573
            }
574
        }
575
576
        /**
577
         * @return the useComplex
578
         */
579
        public boolean isUseComplex() {
580
            return useComplex;
581
        }
582
583
        private Map<Object, Context.ModifyDeclarationTask> checkLoaderAccessibility(Map<String, List<String>> visibleTarget, Context ctx) {
584
            Map<Object, Context.ModifyDeclarationTask> tmp = new HashMap<Object, Context.ModifyDeclarationTask>();
585
            boolean loaderok = true;
586
            for (Map.Entry<String, ExtensionRegistration> extregistration : extensionsRegistrations.entrySet()) {
587
                boolean findforthis = false;
588
                String mime = extregistration.getKey();
589
                for (Map.Entry<String, List<String>> mime2 : visibleTarget.entrySet()) {
590
                    if (mime2.getValue().contains(mime)) {
591
                        tmp.put(mime2.getKey(), new RegisterMIMEExtensionResolver(ctx, extregistration.getValue()));
592
                        findforthis = true;
593
                    }
594
                }
595
                loaderok = loaderok && findforthis;
596
            }
597
            for (Map.Entry<String, NamespaceRegistration> namespaceregistration : nameSpaceRegistrations.entrySet()) {
598
                boolean findforthis = false;
599
                String mime = namespaceregistration.getKey();
600
                for (Map.Entry<String, List<String>> mime2 : visibleTarget.entrySet()) {
601
                    if (mime2.getValue().contains(mime)) {
602
                        tmp.put(mime2.getKey(), new RegisterMIMENamespaceResolver(ctx, namespaceregistration.getValue()));
603
                        findforthis = true;
604
                    }
605
                }
606
                loaderok = loaderok && findforthis;
607
            }
608
            if (!loaderok) { // one missing 
609
                tmp.clear();
610
            }
611
            return tmp;
612
        }
613
    }
614
}
(-)a/apisupport.refactoring/test/unit/src/org/netbeans/modules/apisupport/hints/MIMEResolverRegistrationHinterTest.java (+195 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.apisupport.hints;
43
44
import java.net.URL;
45
import org.netbeans.junit.NbTestCase;
46
47
/**
48
 *
49
 * @author Didier
50
 */
51
public class MIMEResolverRegistrationHinterTest extends NbTestCase {
52
53
    public MIMEResolverRegistrationHinterTest(String name) {
54
        super(name);
55
    }
56
57
    static {
58
        System.setProperty("java.awt.headless", "true");
59
    }
60
61
    @Override
62
    protected boolean runInEQ() {
63
        return true;
64
    }
65
66
    @Override
67
    protected void setUp() throws Exception {
68
        super.setUp();
69
    }
70
71
    // inspired by c mimeresolver but altered for testing purpose
72
    public void testExtBasedSimpleResolver() throws Exception {
73
        URL f = MIMEResolverRegistrationHinterTest.class.getResource("data/textExtBasedSimpleResolver.xml");
74
        MIMEResolverRegistrationHinter.MIMEResolverStrategyManager instance =
75
                new MIMEResolverRegistrationHinter().new MIMEResolverStrategyManager(f);
76
        assertFalse("Should not use complex", instance.isUseComplex());
77
        assertNotNull("should be extension registraion for text/x-c", instance.extensionsRegistrations.get("text/x-c"));
78
        assertEquals("must be 3 element for text/x-c", instance.extensionsRegistrations.get("text/x-c").getExt().size(), 3);
79
        assertTrue("must be .c element for text/x-c", instance.extensionsRegistrations.get("text/x-c").getExt().contains("c"));
80
        assertTrue("must be .i element for text/x-c", instance.extensionsRegistrations.get("text/x-c").getExt().contains("i"));
81
        assertTrue("must be .m element for text/x-c", instance.extensionsRegistrations.get("text/x-c").getExt().contains("m"));
82
83
    }
84
85
    public void testExtBasedSimpleResolver2() throws Exception {
86
        URL f = MIMEResolverRegistrationHinterTest.class.getResource("data/textExtBasedSimpleResolver2.xml");
87
        MIMEResolverRegistrationHinter.MIMEResolverStrategyManager instance = new MIMEResolverRegistrationHinter().new MIMEResolverStrategyManager(f);
88
89
        assertFalse("Should not use complex", instance.isUseComplex());
90
91
        assertNotNull("should be extension registraion for text/x-c", instance.extensionsRegistrations.get("text/x-c"));
92
        assertEquals("must be 3 element for text / x - c    {       }        ", instance.extensionsRegistrations.get("text/x-c").getExt().size(), 9);
93
        assertTrue("must be .c element for text/x-c", instance.extensionsRegistrations.get("text/x-c").getExt().contains("c"));
94
        assertTrue("must be .i element for text/x-c", instance.extensionsRegistrations.get("text/x-c").getExt().contains("i"));
95
        assertTrue("must be .m element for text/x-c", instance.extensionsRegistrations.get("text/x-c").getExt().contains("m"));
96
97
    }
98
99
    public void testExtBasedExitSimpleResolver() {
100
        URL f = MIMEResolverRegistrationHinterTest.class.getResource("data/testExtBasedExitSimpleResolver.xml");
101
        MIMEResolverRegistrationHinter.MIMEResolverStrategyManager instance = new MIMEResolverRegistrationHinter().new MIMEResolverStrategyManager(f);
102
103
        assertTrue("Should use complex", instance.isUseComplex());
104
    }
105
106
    public void testNamespaceRegistration() {
107
        URL f = MIMEResolverRegistrationHinterTest.class.getResource("data/testNamespaceRegistration.xml");
108
        MIMEResolverRegistrationHinter.MIMEResolverStrategyManager instance = new MIMEResolverRegistrationHinter().new MIMEResolverStrategyManager(f);
109
        assertFalse("Should not use complex", instance.isUseComplex());
110
        assertNull("should be no extension registraion for x-struts+xml", instance.extensionsRegistrations.get("text/x-struts+xml"));
111
        assertNotNull("should be namespace registraion for x-struts+xml", instance.nameSpaceRegistrations.get("text/x-struts+xml"));
112
        assertTrue("must be xml in the extension", instance.nameSpaceRegistrations.get("text/x-struts+xml").getExt().contains("xml"));
113
        assertEquals("must be 4 plucib id ", instance.nameSpaceRegistrations.get("text/x-struts+xml").getPublicID().size(), 4); //System.err.println("fddf" + instance.nameSpaceRegistrations.get("text/x-struts+xml").getPublicID());
114
        assertTrue("must be -//Apache Software Foundation//DTD Struts Configuration 1.3//EN in the publicid", instance.nameSpaceRegistrations.get("text/x-struts+xml").getPublicID().contains("-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"));
115
116
    }
117
118
    public void testNamespaceRegistration2() {
119
        URL f = MIMEResolverRegistrationHinterTest.class.getResource("data/testNamespaceRegistration2.xml");
120
        MIMEResolverRegistrationHinter.MIMEResolverStrategyManager instance = new MIMEResolverRegistrationHinter().new MIMEResolverStrategyManager(f);
121
122
        assertFalse("Should not use complex", instance.isUseComplex());
123
        assertNull("should be no extension registraion for x-struts+xml", instance.extensionsRegistrations.get("text/x-struts+xml"));
124
        assertNotNull("should be namespace registraion for x-struts+xml", instance.nameSpaceRegistrations.get("text/x-struts+xml"));
125
        assertTrue("must be xml in the extension", instance.nameSpaceRegistrations.get("text/x-struts+xml").getExt().contains("xml"));
126
        assertEquals("must be 4 public id ", instance.nameSpaceRegistrations.get("text/x-struts+xml").getPublicID().size(), 4);
127
128
        assertTrue("must be -//Apache Software Foundation//DTD Struts Configuration 1.3//EN in the publicid", instance.nameSpaceRegistrations.get("text/x-struts+xml").getPublicID().contains("-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"));
129
    }
130
131
    public void testNamespaceRegistration3() {
132
        URL f = MIMEResolverRegistrationHinterTest.class.getResource("data/testNamespaceRegistration3.xml");
133
        MIMEResolverRegistrationHinter.MIMEResolverStrategyManager instance = new MIMEResolverRegistrationHinter().new MIMEResolverStrategyManager(f);
134
        assertTrue("Should use complex", instance.isUseComplex());
135
    }
136
137
    public void testNamespaceRegistration4() {
138
        URL f = MIMEResolverRegistrationHinterTest.class.getResource("data/testNamespaceRegistration4.xml");
139
        MIMEResolverRegistrationHinter.MIMEResolverStrategyManager instance = new MIMEResolverRegistrationHinter().new MIMEResolverStrategyManager(f);
140
        assertFalse("Should not use complex", instance.isUseComplex());
141
        assertNull("should be no extension registraion for x-struts+xml", instance.extensionsRegistrations.get("text/x-struts+xml"));
142
        assertNotNull("should be namespace registraion for x-struts+xml", instance.nameSpaceRegistrations.get("text/x-struts+xml"));
143
        assertTrue("must be xml in the extension", instance.nameSpaceRegistrations.get("text/x-struts+xml").getExt().contains("xml"));
144
        assertEquals("must be r as root element", instance.nameSpaceRegistrations.get("text/x-struts+xml").getRootElement(), "r"); //System.err.println("fddf" +      instance.nameSpaceRegistrations.get("text/x-struts+xml").getPublicID());
145
    }
146
147
    public void testNamespaceRegistrationMorethanOneElementRoot() {
148
        URL f = MIMEResolverRegistrationHinterTest.class.getResource("data/testNamespaceRegistration5.xml");
149
        MIMEResolverRegistrationHinter.MIMEResolverStrategyManager instance = new MIMEResolverRegistrationHinter().new MIMEResolverStrategyManager(f);
150
        assertTrue("Should use complex", instance.isUseComplex());
151
152
        URL f2 = MIMEResolverRegistrationHinterTest.class.getResource("data/testNamespaceRegistration51.xml");
153
        MIMEResolverRegistrationHinter.MIMEResolverStrategyManager instance2 = new MIMEResolverRegistrationHinter().new MIMEResolverStrategyManager(f2);
154
        assertTrue("Should use complex", instance2.isUseComplex());
155
    }
156
157
    public void testNamespaceRegistration6() {
158
        URL f = MIMEResolverRegistrationHinterTest.class.getResource("data/testNamespaceRegistration6.xml");
159
        MIMEResolverRegistrationHinter.MIMEResolverStrategyManager instance = new MIMEResolverRegistrationHinter().new MIMEResolverStrategyManager(f);
160
        assertFalse("Should not use complex", instance.isUseComplex());
161
        assertNull("should be no extension registraion for x-struts+xml", instance.extensionsRegistrations.get("text/x-struts+xml"));
162
        assertNotNull("should be namespace registraion for x-struts+xml", instance.nameSpaceRegistrations.get("text/x-struts+xml"));
163
        assertTrue("must be xml in the extension", instance.nameSpaceRegistrations.get("text/x-struts+xml").getExt().contains("xml"));
164
        assertEquals("must be r as root element", instance.nameSpaceRegistrations.get("text/x-struts+xml").getRootElement(), "r");
165
        assertTrue("must be test as namespace element", instance.nameSpaceRegistrations.get("text/x-struts+xml").getElementNS().contains("test1"));
166
    }
167
168
    public void testNamespaceRegistrationNSinXmlResolver() {
169
170
        URL f = MIMEResolverRegistrationHinterTest.class.getResource("data/testNamespaceRegistration7.xml");
171
        MIMEResolverRegistrationHinter.MIMEResolverStrategyManager instance = new MIMEResolverRegistrationHinter().new MIMEResolverStrategyManager(f);
172
        assertFalse("Should not use complex", instance.isUseComplex());
173
        assertNull("should be no extension registraion for x-struts+xml", instance.extensionsRegistrations.get("text/x-struts+xml"));
174
        assertNotNull("should be namespace registraion for x-struts+xml", instance.nameSpaceRegistrations.get("text/x-struts+xml"));
175
        assertTrue("must be xml in the extension", instance.nameSpaceRegistrations.get("text/x-struts+xml").getExt().contains("xml"));
176
        assertEquals("must be r as root element", instance.nameSpaceRegistrations.get("text/x-struts+xml").getRootElement(),
177
                "r");
178
        assertFalse("must not be test as namespace element", instance.nameSpaceRegistrations.get("text/x-struts+xml").getElementNS().contains("test1"));
179
180
        assertTrue("must be test2 as namespace element", instance.nameSpaceRegistrations.get("text/x-struts+xml").getElementNS().contains("test2"));
181
        assertTrue("must be test3 as namespace element", instance.nameSpaceRegistrations.get("text/x-struts+xml").getElementNS().contains("test3"));
182
    }
183
184
    public void testNamespaceRegistrationNotSupportedAttr() {
185
        URL f = MIMEResolverRegistrationHinterTest.class.getResource("data/testNamespaceRegistration8.xml");
186
        MIMEResolverRegistrationHinter.MIMEResolverStrategyManager instance = new MIMEResolverRegistrationHinter().new MIMEResolverStrategyManager(f);
187
        assertTrue("Should use complex", instance.isUseComplex());
188
    }
189
    
190
     public void testNamespaceRegistrationJ2EE() {
191
        URL f = MIMEResolverRegistrationHinterTest.class.getResource("data/testNamespaceRegistrationJ2EE.xml");
192
        MIMEResolverRegistrationHinter.MIMEResolverStrategyManager instance = new MIMEResolverRegistrationHinter().new MIMEResolverStrategyManager(f);
193
        assertFalse("Should not use complex", instance.isUseComplex());
194
    }
195
}
(-)a/apisupport.refactoring/test/unit/src/org/netbeans/modules/apisupport/hints/data/testExtBasedExitSimpleResolver.xml (+42 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN"   "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd">
3
<MIME-resolver>
4
    <file>
5
        <ext name="h"/>
6
        <ext name="H"/>
7
        <ext name="hpp"/>
8
        <ext name="hxx"/>
9
        <ext name="SUNWCCh"/>
10
        <ext name="tcc"/>
11
        <exit/>
12
        <resolver mime="text/x-h"/>
13
    </file>
14
    <file>
15
        <ext name="c"/>
16
        <ext name="i"/>
17
        <ext name="m"/>
18
        <resolver mime="text/x-c"/>
19
    </file>
20
    <file>
21
        <ext name="cpp"/>
22
        <ext name="cc"/>
23
        <ext name="c++"/>
24
        <ext name="cxx"/>
25
        <ext name="C"/>
26
        <ext name="mm"/>
27
        <resolver mime="text/x-c++"/>
28
    </file>
29
    <file>
30
        <ext name="f"/>
31
        <ext name="F"/>
32
        <ext name="f90"/>
33
        <ext name="F90"/>
34
        <ext name="f95"/>
35
        <ext name="F95"/>
36
        <ext name="f03"/>
37
        <ext name="F03"/>
38
        <ext name="for"/>
39
        <ext name="mod"/>
40
        <resolver mime="text/x-fortran"/>
41
    </file>
42
</MIME-resolver>
(-)a/apisupport.refactoring/test/unit/src/org/netbeans/modules/apisupport/hints/data/testNamespaceRegistration.xml (+36 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN"   "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd">
3
<MIME-resolver><!-- Resolve according to root element: -->
4
    <file>
5
        <ext name='xml'/>
6
        <resolver mime='text/x-struts+xml'>
7
            <xml-rule>
8
                <doctype public-id='-//Apache Software Foundation//DTD Struts Configuration 1.0//EN'/>
9
            </xml-rule>
10
        </resolver>
11
    </file>
12
    <file>
13
        <ext name='xml'/>
14
        <resolver mime='text/x-struts+xml'>
15
            <xml-rule>
16
                <doctype public-id='-//Apache Software Foundation//DTD Struts Configuration 1.1//EN'/>
17
            </xml-rule>
18
        </resolver>
19
    </file>
20
    <file>
21
        <ext name='xml'/>
22
        <resolver mime='text/x-struts+xml'>
23
            <xml-rule>
24
                <doctype public-id='-//Apache Software Foundation//DTD Struts Configuration 1.2//EN'/>
25
            </xml-rule>
26
        </resolver>
27
    </file>
28
    <file>
29
        <ext name='xml'/>
30
        <resolver mime='text/x-struts+xml'>
31
            <xml-rule>
32
                <doctype public-id='-//Apache Software Foundation//DTD Struts Configuration 1.3//EN'/>
33
            </xml-rule>
34
        </resolver>
35
    </file>
36
</MIME-resolver>
(-)a/apisupport.refactoring/test/unit/src/org/netbeans/modules/apisupport/hints/data/testNamespaceRegistration2.xml (+18 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN"   "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd">
3
<MIME-resolver><!-- Resolve according to root element: -->
4
    <file>
5
        <ext name='xml'/>
6
        <resolver mime='text/x-struts+xml'>
7
            <xml-rule>
8
                <doctype>
9
                    <public-id id="-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"/>
10
                    <public-id id="-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"/>
11
                    <public-id id="-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"/>
12
                    <public-id id="-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"/>                
13
                </doctype> 
14
            </xml-rule>
15
        </resolver>
16
    </file>
17
    
18
</MIME-resolver>
(-)a/apisupport.refactoring/test/unit/src/org/netbeans/modules/apisupport/hints/data/testNamespaceRegistration3.xml (+19 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN"   "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd">
3
<MIME-resolver><!-- Resolve according to root element: -->
4
    <file>
5
        <ext name='xml'/>
6
        <resolver mime='text/x-struts+xml'>
7
            <xml-rule>
8
                <pi target="p"></pi>
9
                <doctype>
10
                    <public-id id="-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"/>
11
                    <public-id id="-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"/>
12
                    <public-id id="-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"/>
13
                    <public-id id="-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"/>                
14
                </doctype> 
15
            </xml-rule>
16
        </resolver>
17
    </file>
18
    
19
</MIME-resolver>
(-)a/apisupport.refactoring/test/unit/src/org/netbeans/modules/apisupport/hints/data/testNamespaceRegistration4.xml (+13 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN"   "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd">
3
<MIME-resolver><!-- Resolve according to root element: -->
4
    <file>
5
        <ext name='xml'/>
6
        <resolver mime='text/x-struts+xml'>
7
            <xml-rule>
8
                <element name='r'/>
9
            </xml-rule>
10
        </resolver>
11
    </file>
12
    
13
</MIME-resolver>
(-)a/apisupport.refactoring/test/unit/src/org/netbeans/modules/apisupport/hints/data/testNamespaceRegistration5.xml (+21 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN"   "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd">
3
<MIME-resolver><!-- Resolve according to root element: -->
4
    <file>
5
        <ext name='xml'/>
6
        <resolver mime='text/x-struts+xml'>
7
            <xml-rule>
8
                <element name='r'/>
9
            </xml-rule>
10
        </resolver>
11
    </file>
12
    <file>
13
        <ext name='xml'/>
14
        <resolver mime='text/x-struts+xml'>
15
            <xml-rule>
16
                <element name='r'/>
17
            </xml-rule>
18
        </resolver>
19
    </file>
20
    
21
</MIME-resolver>
(-)a/apisupport.refactoring/test/unit/src/org/netbeans/modules/apisupport/hints/data/testNamespaceRegistration51.xml (+21 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN"   "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd">
3
<MIME-resolver><!-- Resolve according to root element: -->
4
    <file>
5
        <ext name='xml'/>
6
        <resolver mime='text/x-struts+xml'>
7
            <xml-rule>
8
                <element name='r'/>
9
            </xml-rule>
10
        </resolver>
11
    </file>
12
    <file>
13
        <ext name='xml'/>
14
        <resolver mime='text/x-struts+xml'>
15
            <xml-rule>
16
                <element name='r1'/>
17
            </xml-rule>
18
        </resolver>
19
    </file>
20
    
21
</MIME-resolver>
(-)a/apisupport.refactoring/test/unit/src/org/netbeans/modules/apisupport/hints/data/testNamespaceRegistration6.xml (+13 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN"   "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd">
3
<MIME-resolver><!-- Resolve according to root element: -->
4
    <file>
5
        <ext name='xml'/>
6
        <resolver mime='text/x-struts+xml'>
7
            <xml-rule>
8
                <element name='r' ns='test1'/>
9
            </xml-rule>
10
        </resolver>
11
    </file>
12
    
13
</MIME-resolver>
(-)a/apisupport.refactoring/test/unit/src/org/netbeans/modules/apisupport/hints/data/testNamespaceRegistration7.xml (+16 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN"   "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd">
3
<MIME-resolver><!-- Resolve according to root element: -->
4
    <file>
5
        <ext name='xml'/>
6
        <resolver mime='text/x-struts+xml'>
7
            <xml-rule>
8
                <element name='r' ns='test1'>
9
                    <ns ns='test2'/>
10
                    <ns ns='test3'/>
11
                </element>
12
            </xml-rule>
13
        </resolver>
14
    </file>
15
    
16
</MIME-resolver>
(-)a/apisupport.refactoring/test/unit/src/org/netbeans/modules/apisupport/hints/data/testNamespaceRegistration8.xml (+17 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN"   "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd">
3
<MIME-resolver><!-- Resolve according to root element: -->
4
    <file>
5
        <ext name='xml'/>
6
        <resolver mime='text/x-struts+xml'>
7
            <xml-rule>
8
                <element name='r' ns='test1'>
9
                    <ns ns='test2'/>
10
                    <ns ns='test3'/>  
11
                    <attr name="bn"/>
12
                </element>
13
            </xml-rule>
14
        </resolver>
15
    </file>
16
    
17
</MIME-resolver>
(-)a/apisupport.refactoring/test/unit/src/org/netbeans/modules/apisupport/hints/data/testNamespaceRegistrationJ2EE.xml (+57 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN" "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd">
3
<!--
4
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5
6
Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
7
8
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
9
Other names may be trademarks of their respective owners.
10
11
12
The contents of this file are subject to the terms of either the GNU
13
General Public License Version 2 only ("GPL") or the Common
14
Development and Distribution License("CDDL") (collectively, the
15
"License"). You may not use this file except in compliance with the
16
License. You can obtain a copy of the License at
17
http://www.netbeans.org/cddl-gplv2.html
18
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
19
specific language governing permissions and limitations under the
20
License.  When distributing the software, include this License Header
21
Notice in each file and include the License file at
22
nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
23
particular file as subject to the "Classpath" exception as provided
24
by Sun in the GPL Version 2 section of the License file that
25
accompanied this code. If applicable, add the following below the
26
License Header, with the fields enclosed by brackets [] replaced by
27
your own identifying information:
28
"Portions Copyrighted [year] [name of copyright owner]"
29
30
Contributor(s):
31
32
  The Original Software is NetBeans. The Initial Developer of the Original
33
Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
34
  Microsystems, Inc. All Rights Reserved.
35
36
If you wish your version of this file to be governed by only the CDDL
37
or only the GPL Version 2, indicate your decision by adding
38
"[Contributor] elects to include this software in this distribution
39
under the [CDDL or GPL Version 2] license." If you do not indicate a
40
single choice of license, a recipient has the option to distribute
41
your version of this file under either the CDDL, the GPL Version 2 or
42
to extend the choice of license to its licensees as provided above.
43
However, if you add GPL Version 2 code and therefore, elected the GPL
44
Version 2 license, then the option applies only if the new code is
45
made subject to such option by the copyright holder.
46
-->
47
48
<MIME-resolver>
49
    <file>
50
        <ext name="xmi"/>
51
	<resolver mime="text/x-appbnd+xml">
52
            <xml-rule>
53
                <element name="ApplicationBinding"/>
54
            </xml-rule>
55
        </resolver>
56
    </file>
57
</MIME-resolver>
(-)a/apisupport.refactoring/test/unit/src/org/netbeans/modules/apisupport/hints/data/textExtBasedSimpleResolver.xml (+41 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN"   "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd">
3
<MIME-resolver>
4
    <file>
5
        <ext name="h"/>
6
        <ext name="H"/>
7
        <ext name="hpp"/>
8
        <ext name="hxx"/>
9
        <ext name="SUNWCCh"/>
10
        <ext name="tcc"/>
11
        <resolver mime="text/x-h"/>
12
    </file>
13
    <file>
14
        <ext name="c"/>
15
        <ext name="i"/>
16
        <ext name="m"/>
17
        <resolver mime="text/x-c"/>
18
    </file>
19
    <file>
20
        <ext name="cpp"/>
21
        <ext name="cc"/>
22
        <ext name="c++"/>
23
        <ext name="cxx"/>
24
        <ext name="C"/>
25
        <ext name="mm"/>
26
        <resolver mime="text/x-c++"/>
27
    </file>
28
    <file>
29
        <ext name="f"/>
30
        <ext name="F"/>
31
        <ext name="f90"/>
32
        <ext name="F90"/>
33
        <ext name="f95"/>
34
        <ext name="F95"/>
35
        <ext name="f03"/>
36
        <ext name="F03"/>
37
        <ext name="for"/>
38
        <ext name="mod"/>
39
        <resolver mime="text/x-fortran"/>
40
    </file>
41
</MIME-resolver>
(-)a/apisupport.refactoring/test/unit/src/org/netbeans/modules/apisupport/hints/data/textExtBasedSimpleResolver2.xml (+42 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN" "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd">
3
<MIME-resolver>
4
    <file>
5
        <ext name= "h" />
6
        <ext name= "H" />
7
        <ext name= "hpp" />
8
        <ext name= "hxx" />
9
        <ext name= "SUNWCCh" />
10
        <ext name= "tcc" />
11
        <resolver mime = "text/x-c" />
12
    </file >
13
    <file>
14
        <ext name = "c" />
15
        <ext name = "i" />
16
        <ext name = "m" />
17
        <resolver mime = "text/x-c" />
18
    </file >
19
    <file>
20
        <ext name = "cpp" />
21
        <ext name = "cc" />
22
        <ext name = "c++"/>
23
        <ext name = "cxx" />
24
        <ext name = "C" />
25
        <ext name = "mm" />
26
        <resolver mime = "text/x-c++" />
27
    </file >
28
29
    <file>
30
        <ext name="f"/>
31
        <ext name="F"/>
32
        <ext name="f90"/>
33
        <ext name = "F90"/>
34
        <ext name = "f95"/>
35
        <ext name = "F95"/>
36
        <ext name = "f03"/>
37
        <ext name = "F03"/>
38
        <ext name = "for" />
39
        <ext name = "mod" />
40
        <resolver mime = "text/x-fortran" />
41
    </file >
42
</MIME-resolver>

Return to bug 207960