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 236435
Collapse All | Expand All

(-)a/cnd.modelimpl/src/org/netbeans/modules/cnd/modelimpl/csm/core/FilePreprocessorConditionState.java (-9 / +27 lines)
Lines 63-68 Link Here
63
 */
63
 */
64
public final class FilePreprocessorConditionState {
64
public final class FilePreprocessorConditionState {
65
    public static final FilePreprocessorConditionState PARSING = new FilePreprocessorConditionState("PARSING", new int[]{0, Integer.MAX_VALUE}); // NOI18N
65
    public static final FilePreprocessorConditionState PARSING = new FilePreprocessorConditionState("PARSING", new int[]{0, Integer.MAX_VALUE}); // NOI18N
66
    private static final int ERROR_DIRECTIVE_MARKER = Integer.MAX_VALUE;
67
    private static final int PRAGMA_ONCE_DIRECTIVE_MARKER = Integer.MAX_VALUE - 1;
66
68
67
    /** a SORTED array of blocks [start-end] for which conditionals were evaluated to false */
69
    /** a SORTED array of blocks [start-end] for which conditionals were evaluated to false */
68
    private final int[] offsets;
70
    private final int[] offsets;
Lines 138-146 Link Here
138
            if (i > 0) {
140
            if (i > 0) {
139
                sb.append("][");//NOI18N
141
                sb.append("][");//NOI18N
140
            }
142
            }
141
            if (state.offsets[i+1] == Integer.MAX_VALUE) {
143
            if (state.offsets[i+1] == ERROR_DIRECTIVE_MARKER) {
142
                sb.append(Integer.MAX_VALUE-state.offsets[i]);
144
                sb.append(ERROR_DIRECTIVE_MARKER-state.offsets[i]);
143
                sb.append("#error");//NOI18N
145
                sb.append("#error");//NOI18N
146
            } else if (state.offsets[i + 1] == PRAGMA_ONCE_DIRECTIVE_MARKER) {
147
                sb.append(state.offsets[i]);
148
                sb.append("#pragma once");//NOI18N
144
            } else {
149
            } else {
145
                sb.append(state.offsets[i]);
150
                sb.append(state.offsets[i]);
146
                sb.append("-");//NOI18N
151
                sb.append("-");//NOI18N
Lines 226-232 Link Here
226
        if (this.offsets.length == 0 || this == PARSING) {
231
        if (this.offsets.length == 0 || this == PARSING) {
227
            return false;
232
            return false;
228
        }
233
        }
229
        return offsets[offsets.length-1] == Integer.MAX_VALUE;
234
        return offsets[offsets.length-1] == ERROR_DIRECTIVE_MARKER;
230
    }
235
    }
231
236
232
    public static final class Builder implements APTParseFileWalker.EvalCallback {
237
    public static final class Builder implements APTParseFileWalker.EvalCallback {
Lines 258-266 Link Here
258
         * adds offset of dead branch to offsets array
263
         * adds offset of dead branch to offsets array
259
         */        
264
         */        
260
        @Override
265
        @Override
261
        public void onStoppedDirective(APT apt) {
266
        public void onErrorDirective(APT apt) {
262
            // on error directive we add special dead block
267
            // on error directive we add special dead block
263
            addBlockImpl(Integer.MAX_VALUE-apt.getToken().getOffset(), Integer.MAX_VALUE);
268
            addBlockImpl(ERROR_DIRECTIVE_MARKER-apt.getToken().getOffset(), ERROR_DIRECTIVE_MARKER);
269
        }
270
271
        /**
272
         * Implements APTParseFileWalker.EvalCallback - adds offset of dead
273
         * branch to offsets array
274
         */
275
        @Override
276
        public void onPragmaOnceDirective(APT apt) {
277
            // on pragma once directive we add dead block from pragma till the end
278
            addBlockImpl(apt.getToken().getOffset(), PRAGMA_ONCE_DIRECTIVE_MARKER);
264
        }
279
        }
265
280
266
        /**
281
        /**
Lines 316-322 Link Here
316
            int size = 0;
331
            int size = 0;
317
            for (int[] deadInterval : blocks) {
332
            for (int[] deadInterval : blocks) {
318
                size++;
333
                size++;
319
                if (deadInterval[1] == Integer.MAX_VALUE) {
334
                if (deadInterval[1] == ERROR_DIRECTIVE_MARKER) {
320
                    break;
335
                    break;
321
                }
336
                }
322
            }
337
            }
Lines 325-331 Link Here
325
            for (int[] deadInterval : blocks) {
340
            for (int[] deadInterval : blocks) {
326
                offsets[index++] = deadInterval[0];
341
                offsets[index++] = deadInterval[0];
327
                offsets[index++] = deadInterval[1];
342
                offsets[index++] = deadInterval[1];
328
                if (deadInterval[1] == Integer.MAX_VALUE) {
343
                if (deadInterval[1] == ERROR_DIRECTIVE_MARKER) {
329
                    break;
344
                    break;
330
                }
345
                }
331
            }
346
            }
Lines 355-363 Link Here
355
                if (i++ > 0) {
370
                if (i++ > 0) {
356
                    sb.append("][");//NOI18N
371
                    sb.append("][");//NOI18N
357
                }
372
                }
358
                if (deadInterval[1] == Integer.MAX_VALUE) {
373
                if (deadInterval[1] == ERROR_DIRECTIVE_MARKER) {
359
                    sb.append(Integer.MAX_VALUE-deadInterval[0]);
374
                    sb.append(ERROR_DIRECTIVE_MARKER-deadInterval[0]);
360
                    sb.append("#error");//NOI18N
375
                    sb.append("#error");//NOI18N
376
                } else if (deadInterval[1] == PRAGMA_ONCE_DIRECTIVE_MARKER) {
377
                    sb.append(deadInterval[0]);
378
                    sb.append("#pragma once");//NOI18N    
361
                } else {
379
                } else {
362
                    sb.append(deadInterval[0]);
380
                    sb.append(deadInterval[0]);
363
                    sb.append("-");//NOI18N
381
                    sb.append("-");//NOI18N
(-)a/cnd.modelimpl/src/org/netbeans/modules/cnd/modelimpl/parser/apt/APTParseFileWalker.java (-4 / +7 lines)
Lines 101-107 Link Here
101
101
102
        void onEval(APT apt, boolean result);
102
        void onEval(APT apt, boolean result);
103
103
104
        void onStoppedDirective(APT apt);
104
        void onErrorDirective(APT apt);
105
        
106
        void onPragmaOnceDirective(APT apt);
105
    }
107
    }
106
    private FileContent fileContent;
108
    private FileContent fileContent;
107
    private final boolean triggerParsingActivity;
109
    private final boolean triggerParsingActivity;
Lines 110-116 Link Here
110
        @Override
112
        @Override
111
        public void onEval(APT apt, boolean result) { }
113
        public void onEval(APT apt, boolean result) { }
112
        @Override
114
        @Override
113
        public void onStoppedDirective(APT apt) { }
115
        public void onErrorDirective(APT apt) { }
116
        public void onPragmaOnceDirective(APT apt) { }
114
    };
117
    };
115
    private final CsmCorePackageAccessor csmCorePackageAccessor;
118
    private final CsmCorePackageAccessor csmCorePackageAccessor;
116
119
Lines 182-188 Link Here
182
    @Override
185
    @Override
183
    protected void onErrorNode(APT apt) {
186
    protected void onErrorNode(APT apt) {
184
        super.onErrorNode(apt);
187
        super.onErrorNode(apt);
185
        evalCallback.onStoppedDirective(apt);
188
        evalCallback.onErrorDirective(apt);
186
        if (needMacroAndIncludes()) {
189
        if (needMacroAndIncludes()) {
187
            this.fileContent.addError(createError((APTError)apt));
190
            this.fileContent.addError(createError((APTError)apt));
188
        }
191
        }
Lines 192-198 Link Here
192
    protected void onPragmaNode(APT apt) {
195
    protected void onPragmaNode(APT apt) {
193
        super.onPragmaNode(apt);
196
        super.onPragmaNode(apt);
194
        if (isStopped()) {
197
        if (isStopped()) {
195
            evalCallback.onStoppedDirective(apt);
198
            evalCallback.onPragmaOnceDirective(apt);
196
        } else {
199
        } else {
197
            APTPragma pragma = (APTPragma) apt;
200
            APTPragma pragma = (APTPragma) apt;
198
            APTToken name = pragma.getName();
201
            APTToken name = pragma.getName();

Return to bug 236435