mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-20 07:20:22 +07:00
IDEA-111524 Javadoc code reformat generates <p> on JDK 8 instead <p/>, when generate <p/> on empty lines option is on [CR-IC-1950]
This commit is contained in:
1 parent
6178ef20e7
commit
8ad9c40d1e
3 files changed
+83
-7
No files matched your search
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,7 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.util.text.LineTokenizer;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
@@ -45,7 +46,7 @@ public class CommentFormatter {
|
||||
|
||||
public CommentFormatter(@NotNull Project project) {
|
||||
mySettings = CodeStyleSettingsManager.getSettings(project);
|
||||
myParser = new JDParser(mySettings);
|
||||
myParser = new JDParser(mySettings, LanguageLevelProjectExtension.getInstance(project).getLanguageLevel());
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,7 @@ package com.intellij.psi.impl.source.codeStyle.javadoc;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -39,9 +40,11 @@ public class JDParser {
|
||||
private static final String SELF_CLOSED_P_TAG = "<p/>";
|
||||
|
||||
private final CodeStyleSettings mySettings;
|
||||
private final LanguageLevel myLanguageLevel;
|
||||
|
||||
public JDParser(@NotNull CodeStyleSettings settings) {
|
||||
public JDParser(@NotNull CodeStyleSettings settings, @NotNull LanguageLevel languageLevel) {
|
||||
mySettings = settings;
|
||||
myLanguageLevel = languageLevel;
|
||||
}
|
||||
|
||||
private static final char lineSeparator = '\n';
|
||||
@@ -514,7 +517,13 @@ public class JDParser {
|
||||
if (line.length() == 0 && !mySettings.JD_KEEP_EMPTY_LINES) continue;
|
||||
if (i != 0) sb.append(prefix);
|
||||
if (line.length() == 0 && mySettings.JD_P_AT_EMPTY_LINES && !insidePreTag) {
|
||||
sb.append(SELF_CLOSED_P_TAG);
|
||||
if (myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
|
||||
//Self-closing elements are not allowed for javadoc tool from JDK8
|
||||
sb.append(P_START_TAG);
|
||||
}
|
||||
else {
|
||||
sb.append(SELF_CLOSED_P_TAG);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sb.append(line);
|
||||
|
||||
Reference in new issue
Block a user