mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
[javadoc] External snippet rendering basic support (no regions) (IDEA-314508)
GitOrigin-RevId: 0db03eff583478c16831e52db413e1e842050ec7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d3d9218a15
commit
702d6eedda
@@ -1825,6 +1825,30 @@ public class JavaDocInfoGenerator {
|
||||
}
|
||||
}
|
||||
buffer.append("</pre>");
|
||||
} else {
|
||||
PsiSnippetAttribute[] attributes = value.getAttributeList().getAttributes();
|
||||
for (PsiSnippetAttribute attribute : attributes) {
|
||||
PsiSnippetAttributeValue attrValue = attribute.getValue();
|
||||
if (attrValue != null) {
|
||||
PsiReference ref = attrValue.getReference();
|
||||
if (ref != null) {
|
||||
PsiElement resolved = ref.resolve();
|
||||
if (resolved instanceof PsiFile file) {
|
||||
buffer.append("<pre>");
|
||||
if (file instanceof PsiJavaFile) {
|
||||
generateJavaSnippetBody(buffer, file);
|
||||
}
|
||||
else {
|
||||
buffer.append(file.getText());
|
||||
}
|
||||
buffer.append("</pre>");
|
||||
} else {
|
||||
buffer.append(getSpanForUnresolvedItem()).append(JavaBundle.message("javadoc.snippet.not.found"))
|
||||
.append(attrValue.getValue()).append("</span>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<html><head><base href="placeholder"></head><body><div class='definition'><pre><span style="color:#000080;font-weight:bold;">class</span> <span style="color:#000000;">Main</span></pre></div><div class='content'>
|
||||
<pre><span style="color:#000080;font-weight:bold;">public</span> <span style="color:#000080;font-weight:bold;">class</span> Hello <span style="">{</span>
|
||||
<span style="color:#000080;font-weight:bold;">public</span> <span style="color:#000080;font-weight:bold;">static</span> <span style="color:#000080;font-weight:bold;">void</span> main(<a href="psi_element://java.lang.String"><code><span style="color:#000000;">String</span></code></a><span style="">[</span><span style="">]</span> <span style="">args</span>) <span style="">{</span>
|
||||
<a href="psi_element://java.lang.System"><code><span style="color:#000000;">System</span></code></a><span style="">.</span><a href="psi_element://java.lang.System#out"><code><span style="color:#660e7a;">out</span></code></a><span style="">.</span><a href="psi_element://java.io.PrintStream#println(java.lang.String)"><code><span style="color:#000000;">println</span></code></a>("Hello");
|
||||
<span style="">}</span>
|
||||
<span style="">}</span></pre>
|
||||
</div><table class='sections'><p></table>
|
||||
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* {@snippet class=Hello}
|
||||
*/
|
||||
class Main {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<html><head><base href="placeholder"></head><body><div class='definition'><pre><span style="color:#000080;font-weight:bold;">class</span> <span style="color:#000000;">TextFile</span></pre></div><div class='content'>
|
||||
<pre>This is a text file
|
||||
Another line</pre>
|
||||
</div><table class='sections'><p></table>
|
||||
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* {@snippet file="text.txt"}
|
||||
*/
|
||||
class TextFile {
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<html><head><base href="placeholder"></head><body><div class='definition'><pre><span style="color:#000080;font-weight:bold;">class</span> <span style="color:#000000;">Unresolved</span></pre></div><div class='content'>
|
||||
<span style="color:#ff0000">Snippet not found: Unresolved</span>
|
||||
</div><table class='sections'><p></table>
|
||||
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* {@snippet class=Unresolved}
|
||||
*/
|
||||
class Unresolved {
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
public class Hello {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
This is a text file
|
||||
Another line
|
||||
@@ -1,4 +1,4 @@
|
||||
<html><head><base href="placeholder"></head><body><div class='definition'><pre><span style="color:#000080;font-weight:bold;">class</span> <span style="color:#000000;">Main</span></pre></div><div class='content'>
|
||||
Attributes:
|
||||
|
||||
<span style="color:#ff0000">Snippet not found: ClassName</span>
|
||||
</div><table class='sections'><p></table>
|
||||
@@ -126,6 +126,12 @@ public class JavaDocInfoGeneratorTest extends JavaCodeInsightTestCase {
|
||||
public void testEscapeAngleBracketsInCode() { doTestClass(); }
|
||||
public void testInlineTagSnippet() { doTestClass(); }
|
||||
public void testInlineTagSnippetWithoutBody() { doTestClass(); }
|
||||
public void testExternalSnippet() {
|
||||
createProjectStructure(getTestDataPath() + TEST_DATA_FOLDER + "externalSnippet");
|
||||
verifyJavadocFor("Main");
|
||||
verifyJavadocFor("TextFile");
|
||||
verifyJavadocFor("Unresolved");
|
||||
}
|
||||
public void testUnknownInlineTag() { doTestClass(); }
|
||||
public void testUnknownInlineMultilineTag() { doTestClass(); }
|
||||
public void testUnknownTag() { doTestMethod(); }
|
||||
|
||||
@@ -1818,3 +1818,4 @@ intention.family.name.ignore.project=Do not show again in this project
|
||||
fix.move.to.source.root=Move to source root
|
||||
warning.java.file.outside.source.root=Java file is located outside of the module source root, so it won't be compiled
|
||||
inspection.message.snippet.file.not.found=Snippet file is not found
|
||||
javadoc.snippet.not.found=Snippet not found:
|
||||
|
||||
Reference in New Issue
Block a user