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

(-)a/java.source/src/org/netbeans/modules/java/source/save/Reformatter.java (-3 / +8 lines)
Lines 390-395 Link Here
390
        private int lastBlankLinesTokenIndex;
390
        private int lastBlankLinesTokenIndex;
391
        private Diff lastBlankLinesDiff;
391
        private Diff lastBlankLinesDiff;
392
        private boolean afterAnnotation;
392
        private boolean afterAnnotation;
393
        private boolean lastAnnoWasOverride;
393
        private boolean wrapAnnotation;
394
        private boolean wrapAnnotation;
394
        private boolean checkWrap;
395
        private boolean checkWrap;
395
        private boolean fieldGroup;
396
        private boolean fieldGroup;
Lines 1027-1032 Link Here
1027
                if (afterAnnotation) {
1028
                if (afterAnnotation) {
1028
                    if (!isStandalone) {
1029
                    if (!isStandalone) {
1029
                        spaces(1, true);
1030
                        spaces(1, true);
1031
                    } else if (lastAnnoWasOverride) {
1032
                        spaces(1);
1030
                    } else {
1033
                    } else {
1031
                        switch (cs.wrapAnnotations()) {
1034
                        switch (cs.wrapAnnotations()) {
1032
                            case WRAP_ALWAYS:
1035
                            case WRAP_ALWAYS:
Lines 1062-1075 Link Here
1062
                        lastBlankLinesTokenIndex = lblti;
1065
                        lastBlankLinesTokenIndex = lblti;
1063
                        lastBlankLinesDiff = lbld;
1066
                        lastBlankLinesDiff = lbld;
1064
                        wrapAnnotation = cs.wrapAnnotations() == CodeStyle.WrapStyle.WRAP_ALWAYS;
1067
                        wrapAnnotation = cs.wrapAnnotations() == CodeStyle.WrapStyle.WRAP_ALWAYS;
1068
                        AnnotationTree nextAnno = annotations.next();
1065
                        if (!isStandalone || !afterAnnotation) {
1069
                        if (!isStandalone || !afterAnnotation) {
1066
                            scan(annotations.next(), p);
1070
                            scan(nextAnno, p);
1067
                        } else {
1071
                        } else {
1068
                            wrapTree(cs.wrapAnnotations(), -1, 0, annotations.next());
1072
                            wrapTree(cs.wrapAnnotations(), -1, 0, nextAnno);
1069
                        }
1073
                        }
1070
                        wrapAnnotation = false;
1074
                        wrapAnnotation = false;
1071
                        afterAnnotation = true;
1075
                        afterAnnotation = true;
1072
                        ret = false;
1076
                        lastAnnoWasOverride = nextAnno.getAnnotationType().toString().matches("(java[.]lang[.])?Override"); // NOI18N
1077
                        ret = lastAnnoWasOverride;
1073
                        continue;
1078
                        continue;
1074
                    }
1079
                    }
1075
                    afterAnnotation = false;
1080
                    afterAnnotation = false;
(-)a/java.source/test/unit/src/org/netbeans/modules/java/source/save/FormatingTest.java (+26 lines)
Lines 3379-3384 Link Here
3379
        reformat(doc, content, golden);
3379
        reformat(doc, content, golden);
3380
    }
3380
    }
3381
3381
3382
    public void testInlineOverride104757() throws Exception {
3383
        testFile = new File(getWorkDir(), "C.java");
3384
        Document doc = DataObject.find(FileUtil.toFileObject(testFile)).getCookie(EditorCookie.class).openDocument();
3385
        doc.putProperty(Language.class, JavaTokenId.language());
3386
        String content =
3387
                "package p;\n\n"
3388
                + "public class C {\n\n"
3389
                + "    @SuppressWarnings(\"whatever\")\n"
3390
                + "    @Override\n"
3391
                + "    public void m() {\n"
3392
                + "    }\n\n"
3393
                + "    public @Override void n() {\n"
3394
                + "    }\n"
3395
                + "}\n";
3396
        String golden =
3397
                "package p;\n\n"
3398
                + "public class C {\n\n"
3399
                + "    @SuppressWarnings(\"whatever\")\n"
3400
                + "    @Override public void m() {\n"
3401
                + "    }\n\n"
3402
                + "    public @Override void n() {\n"
3403
                + "    }\n"
3404
                + "}\n";
3405
        reformat(doc, content, golden);
3406
    }
3407
3382
    private void reformat(Document doc, String content, String golden) throws Exception {
3408
    private void reformat(Document doc, String content, String golden) throws Exception {
3383
        reformat(doc, content, golden, 0, content.length());
3409
        reformat(doc, content, golden, 0, content.length());
3384
    }
3410
    }

Return to bug 104757