You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by ak...@apache.org on 2022/05/12 09:53:41 UTC

[netbeans] branch master updated: Validate external snippet attributes like file, class, region to check for improper attribute values(JEP 413) (#3884)

This is an automated email from the ASF dual-hosted git repository.

akhileshsingh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 7add6a45fe Validate external snippet attributes like file, class, region to check for improper attribute values(JEP 413) (#3884)
7add6a45fe is described below

commit 7add6a45fe890a0b07de6ce1137976b7360f1f61
Author: Meghna Jayan <me...@oracle.com>
AuthorDate: Thu May 12 15:23:33 2022 +0530

    Validate external snippet attributes like file, class, region to check for improper attribute values(JEP 413) (#3884)
    
    * Validate external snippet attributes
    
    Co-authored-by: singhs-akhilesh <ak...@oracle.com>
    Co-authored-by: mishrasandeep <sa...@oracle.com>
---
 .../editor/completion/DocumentationScrollPane.java |   2 +-
 .../modules/editor/completion/HTMLDocView.java     |   2 +-
 ...adocsnippet_HighlightAndReplace_cornercase.pass |  20 +-
 .../GoToSupportTest/javadocsnippet_LinkTag.pass    |  24 +-
 ...adocsnippet_LinkTag_AlongWith_HighlightTag.pass |  23 +-
 ...avadocsnippet_LinkTag_AlongWith_ReplaceTag.pass |  23 +-
 ...t_LinkTag_AlongWith_SubStringAndReplaceTag.pass |  25 +-
 .../javadocsnippet_LinkTag_AppliesToNextLine.pass  |  25 +-
 ...vadocsnippet_LinkTag_EmptyReplacementValue.pass |  23 +-
 ...pet_LinkTag_FieldRef_ToThisClass_UsingHash.pass |  25 +-
 ...csnippet_LinkTag_Ref_ToThisClass_UsingHash.pass |  25 +-
 ...javadocsnippet_LinkTag_With_RegexAndRegion.pass |  24 +-
 ...avadocsnippet_LinkTag_With_RegionAttribute.pass |  24 +-
 ...javadocsnippet_Link_MultipleTag_OnSameLine.pass |  24 +-
 ...snippet_NestedRegion_Highlight_And_replace.pass |  18 ++
 ...ippet_NestedRegion_ReplaceAnnotation_Regex.pass |  18 ++
 ...t_NestedRegion_ReplaceAnnotation_Substring.pass |  18 ++
 ...adocsnippet_Region_ReplaceAnnotation_Regex.pass |  18 ++
 ...t_Region_ReplaceAnnotation_RegexInnComment.pass |  18 ++
 ...SingleLine_MultipleReplaceAnnotation_Regex.pass |  18 ++
 ...leLine_MultipleReplaceAnnotation_Substring.pass |  18 ++
 ...leLine_ReplaceAnnotation_Regex_DoubleQuote.pass |  18 ++
 .../javadocsnippet_SingleLine_Replace_Regex.pass   |  18 ++
 ...javadocsnippet_SingleLine_Replace_RegexDot.pass |  18 ++
 ...docsnippet_SingleLine_Replace_RegexDotStar.pass |  18 ++
 ...avadocsnippet_SingleLine_Replace_Substring.pass |  18 ++
 .../javadocsnippet_TestError_HighlightTag.pass     |  18 ++
 .../javadocsnippet_TestError_LinkTag.pass          | 101 ++++---
 .../javadocsnippet_TestError_NoRegionToEnd.pass    |  18 ++
 .../javadocsnippet_TestError_ReplaceTag.pass       |  18 ++
 .../javadocsnippet_TestError_UnpairedRegion.pass   |  18 ++
 .../javadocsnippet_external_file.pass              |  93 +++++++
 .../GoToSupportTest/javadocsnippet_file_empty.pass |  30 +++
 .../javadocsnippet_file_invalid.pass               |  30 +++
 .../javadocsnippet_highlightRecord.pass            |  18 ++
 ...et_highlightTagRegexWithAllCharacterChange.pass |  18 ++
 ...ightTagRegexWithAllCharacterChangeUsingDot.pass |  18 ++
 ...ippet_highlightTagSubstringApplyToNextLine.pass |  18 ++
 ...ngMultipleSnippetTagInOneJavaDocWithRegion.pass |  18 ++
 ...javadocsnippet_highlightUsingNestedRegions.pass |  18 ++
 .../javadocsnippet_highlightUsingRegex.pass        |  18 ++
 ..._highlightUsingRegionsEndedWithDoubleColon.pass |  18 ++
 .../javadocsnippet_highlightUsingSubstring.pass    |  18 ++
 ...docsnippet_highlightUsingSubstringAndRegex.pass |  18 ++
 ...nippet_highlightUsingSubstringRegexAndType.pass |  18 ++
 .../javadocsnippet_highlight_markuptag.pass        |  18 ++
 .../javadocsnippet_noMarkupTagPresent.pass         |  18 ++
 .../javadocsnippet_region_invalid.pass}            |  32 +--
 .../javadocsnippet_region_valid.pass               |  56 ++++
 .../java/editor/javadocsnippet/data/Errors.java    |  62 +++++
 .../editor/javadocsnippet/data/HighlightTag.java   |  18 ++
 .../java/editor/javadocsnippet/data/LinkTag.java   |  18 ++
 .../data/snippet-files/HelloWorld.java             |  13 +
 .../modules/editor/java/GoToSupportTest.java       | 290 ++++++++++++++++++---
 .../java/project/ui/JavaTargetChooserPanel.java    |   2 +
 .../java/project/ui/resources/Class.java.template  |   2 +-
 .../netbeans/modules/java/source/TreeShims.java    |   4 +-
 .../modules/java/source/save/CasualDiff.java       |   4 +-
 .../api/java/source/ui/ElementJavadoc.java         |  96 +++++--
 .../java/source/ui/snippet/HtmlStartEndTag.java    |   1 -
 .../api/java/source/ui/snippet/MarkupTag.java      |   2 -
 .../java/source/ui/snippet/MarkupTagAttribute.java |   1 -
 .../java/source/ui/snippet/MarkupTagProcessor.java |   1 -
 .../ui/snippet/SnippetMarkupTagExtractor.java      |   1 -
 .../source/ui/snippet/SnippetTagCommentParser.java |   1 -
 .../api/java/source/ui/snippet/SourceLineMeta.java |   1 -
 .../source/ui/snippet/MarkupTagProcessorTest.java  | 157 +++++++++++
 67 files changed, 1665 insertions(+), 162 deletions(-)

diff --git a/ide/editor.completion/src/org/netbeans/modules/editor/completion/DocumentationScrollPane.java b/ide/editor.completion/src/org/netbeans/modules/editor/completion/DocumentationScrollPane.java
index 33980b5003..881a2e2b16 100644
--- a/ide/editor.completion/src/org/netbeans/modules/editor/completion/DocumentationScrollPane.java
+++ b/ide/editor.completion/src/org/netbeans/modules/editor/completion/DocumentationScrollPane.java
@@ -572,4 +572,4 @@ public class DocumentationScrollPane extends JScrollPane {
             
         }
     }
-}
+}
\ No newline at end of file
diff --git a/ide/editor.completion/src/org/netbeans/modules/editor/completion/HTMLDocView.java b/ide/editor.completion/src/org/netbeans/modules/editor/completion/HTMLDocView.java
index 19e6dc2321..42798c2f68 100644
--- a/ide/editor.completion/src/org/netbeans/modules/editor/completion/HTMLDocView.java
+++ b/ide/editor.completion/src/org/netbeans/modules/editor/completion/HTMLDocView.java
@@ -126,7 +126,7 @@ public class HTMLDocView extends JEditorPane {
                     Document doc = getDocument();
                     doc.remove(0, doc.getLength());
                     getEditorKit().read(in, getDocument(), 0);  //!!! still too expensive to be called from AWT
-                    setCaretPosition(0);
+                    setCaretPosition(0); 
                     if (reference != null) {
                         SwingUtilities.invokeLater(new Runnable(){
                             public void run(){
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_HighlightAndReplace_cornercase.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_HighlightAndReplace_cornercase.pass
index 712977fa4f..3e68eb867a 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_HighlightAndReplace_cornercase.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_HighlightAndReplace_cornercase.pass
@@ -1,6 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testHighlightAndReplace_cornercase</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code>  public static void \bmain\b(String... args) {	
 		 S<b>y</b><b>s</b>replace<b>.</b><b>o</b><b>u</b><b>t</b>.println("tests"); 	
  }
  
-</code></pre></div><p>
\ No newline at end of file
+</code></pre></div><p>
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag.pass
index 32c5e7970b..b4a6635034 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag.pass
@@ -1,9 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testLinkTag</b>()</pre><p>A simple program
 
- <pre><code> class HelloWorld {
+ <div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
+<pre><code> class HelloWorld {
      public static void main(String... args) {
          System.out.println("Hello World!");  
  }
  }
  
-</code></pre><p>
\ No newline at end of file
+
+</code></pre></div><p>
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_AlongWith_HighlightTag.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_AlongWith_HighlightTag.pass
index 370f13cabe..dcd50f8fb2 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_AlongWith_HighlightTag.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_AlongWith_HighlightTag.pass
@@ -1,10 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testLinkTag_AlongWith_HighlightTag</b>()</pre><p>A simple program
 
- <pre><code> class HelloWorld {
+ <div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
+<pre><code> class HelloWorld {
      public static void main(String... args) {
          
          System.<span style="background-color:yellow;">o</span><span style="background-color:yellow;">u</span><span style="background-color:yellow;">t</span><span style="background-color:yellow;">.</span><span style="background-color:yellow;">p</span><span style="background-color:yellow;">r</span><span style="background-color:yellow;">i</span><span style="background-color:yellow;">n</span><span style="background-color:yellow;">t</span><span style="background-color:yellow;">l</span><span  [...]
  }
  }
  
-</code></pre><p>
\ No newline at end of file
+</code></pre></div><p>
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_AlongWith_ReplaceTag.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_AlongWith_ReplaceTag.pass
index d8ab36ed88..01f1f94715 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_AlongWith_ReplaceTag.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_AlongWith_ReplaceTag.pass
@@ -1,10 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testLinkTag_AlongWith_ReplaceTag</b>()</pre><p>A simple program
 
- <pre><code> class HelloWorld {
+ <div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
+<pre><code> class HelloWorld {
      public static void main(String... args) {
          
          Syserr.out.println("Hello World!");
  }
  }
  
-</code></pre><p>
\ No newline at end of file
+</code></pre></div><p>
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_AlongWith_SubStringAndReplaceTag.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_AlongWith_SubStringAndReplaceTag.pass
index e96e43717f..c1938055e9 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_AlongWith_SubStringAndReplaceTag.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_AlongWith_SubStringAndReplaceTag.pass
@@ -1,10 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testLinkTag_AlongWith_SubStringAndReplaceTag</b>()</pre><p>A simple program
 
- <pre><code> class HelloWorld {
+ <div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
+<pre><code> class HelloWorld {
      public static void main(String... args) {
          
          System.<span style="background-color:yellow;">r</span><span style="background-color:yellow;">e</span><span style="background-color:yellow;">p</span><span style="background-color:yellow;">l</span><span style="background-color:yellow;">a</span><span style="background-color:yellow;">c</span><span style="background-color:yellow;">e</span><span style="background-color:yellow;">d</span>out.println("Hello World!");
  }
  }
- 
-</code></pre><p>
\ No newline at end of file
+
+</code></pre></div><p>
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_AppliesToNextLine.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_AppliesToNextLine.pass
index 3494be36dc..1479d48a41 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_AppliesToNextLine.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_AppliesToNextLine.pass
@@ -1,10 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testLinkTag_AppliesToNextLine</b>()</pre><p>A simple program
 
- <pre><code> class HelloWorld {
+ <div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
+<pre><code> class HelloWorld {
      public static void main(String... args) {
          
          System.out.println("Hello World!");
  }
  }
- 
-</code></pre><p>
\ No newline at end of file
+
+</code></pre></div><p>
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_EmptyReplacementValue.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_EmptyReplacementValue.pass
index a412d7c1b0..6b6f5a5be3 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_EmptyReplacementValue.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_EmptyReplacementValue.pass
@@ -1,10 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testLinkTag_EmptyReplacementValue</b>()</pre><p>A simple program
 
+ <div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
  <pre><code> class HelloWorld {
      public static void main(String... args) {
          
          System.out.println("Hello World!");
  }
  }
- 
-</code></pre><p>
\ No newline at end of file
+
+</code></pre></div><p>
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_FieldRef_ToThisClass_UsingHash.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_FieldRef_ToThisClass_UsingHash.pass
index 2f2d4af035..6ffb5a5ecd 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_FieldRef_ToThisClass_UsingHash.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_FieldRef_ToThisClass_UsingHash.pass
@@ -1,9 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testLinkTag_FieldRef_ToThisClass_UsingHash</b>()</pre><p>A simple program
 
- <pre><code> class HelloWorld {
+ <div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
+<pre><code> class HelloWorld {
      public static void main(String... args) {
          System.out.println(args[0]); 
  }
  }
- 
-</code></pre><p>
\ No newline at end of file
+
+</code></pre></div><p>
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_Ref_ToThisClass_UsingHash.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_Ref_ToThisClass_UsingHash.pass
index 9b6521b9c2..51b4c28475 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_Ref_ToThisClass_UsingHash.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_Ref_ToThisClass_UsingHash.pass
@@ -1,9 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testLinkTag_Ref_ToThisClass_UsingHash</b>()</pre><p>A simple program
 
- <pre><code> class HelloWorld {
+ <div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
+<pre><code> class HelloWorld {
      public static void main(String... args) {
          System.out.println(addExact(1,20)); 
  }
  }
- 
-</code></pre><p>
\ No newline at end of file
+
+</code></pre></div><p>
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_With_RegexAndRegion.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_With_RegexAndRegion.pass
index 9c81742983..73897f5390 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_With_RegexAndRegion.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_With_RegexAndRegion.pass
@@ -1,11 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testLinkTag_With_RegexAndRegion</b>()</pre><p>A simple program
 
- <pre><code>   public static void main(String... args) {
+ <div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
+<pre><code>   public static void main(String... args) {
        for (var arg : args) {                 
            if (!arg.isBlank()) {
                System.out.println(arg);
            }
        }                                      
  }
- 
-</code></pre><p>
\ No newline at end of file
+</code></pre></div><p>
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_With_RegionAttribute.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_With_RegionAttribute.pass
index a32bd8bbbc..c616e44c23 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_With_RegionAttribute.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_LinkTag_With_RegionAttribute.pass
@@ -1,6 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testLinkTag_With_RegionAttribute</b>()</pre><p>A simple program
 
- <pre><code> class HelloWorld {
+ <div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
+<pre><code> class HelloWorld {
      public static void main(String... args) {
          System.out.println("Hello World!"); 
          System.out.println(ArrayList.class); 
@@ -9,5 +28,4 @@
          System.err.println(ArrayList.class);
  }
  }
- 
-</code></pre><p>
\ No newline at end of file
+</code></pre></div><p>
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_Link_MultipleTag_OnSameLine.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_Link_MultipleTag_OnSameLine.pass
index 457e9a8d90..cecb0a1f42 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_Link_MultipleTag_OnSameLine.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_Link_MultipleTag_OnSameLine.pass
@@ -1,9 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testLink_MultipleTag_OnSameLine</b>()</pre><p>A simple program
 
- <pre><code> class HelloWorld {
+ <div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
+<pre><code> class HelloWorld {
      public static void main(String... args) {
          System.out.println(ArrayList.class); 
  }
  }
- 
-</code></pre><p>
\ No newline at end of file
+</code></pre></div><p>
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_NestedRegion_Highlight_And_replace.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_NestedRegion_Highlight_And_replace.pass
index e746d689da..3269fdb57b 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_NestedRegion_Highlight_And_replace.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_NestedRegion_Highlight_And_replace.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testNestedRegion_Highlight_And_replace</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code>   public static void \bmain\b(String... args) {	
        for (var <i><b>a</b></i><i><b>r</b></i><i><b>g</b></i> : <i><b>a</b></i><i><b>r</b></i><i><b>g</b></i>s) {                         
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_NestedRegion_ReplaceAnnotation_Regex.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_NestedRegion_ReplaceAnnotation_Regex.pass
index c40df372f8..fa4010c81b 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_NestedRegion_ReplaceAnnotation_Regex.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_NestedRegion_ReplaceAnnotation_Regex.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testNestedRegion_ReplaceAnnotation_Regex</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code> class HelloWorld<span style="background-color:yellow;">1</span> {
      public static void main(String... args) {
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_NestedRegion_ReplaceAnnotation_Substring.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_NestedRegion_ReplaceAnnotation_Substring.pass
index 5e146608a3..3e45bebe6d 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_NestedRegion_ReplaceAnnotation_Substring.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_NestedRegion_ReplaceAnnotation_Substring.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testNestedRegion_ReplaceAnnotation_Substring</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code> class HelloWorld {
      public static void main(String... args) {
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_Region_ReplaceAnnotation_Regex.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_Region_ReplaceAnnotation_Regex.pass
index 406ecd1cce..00bda0f322 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_Region_ReplaceAnnotation_Regex.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_Region_ReplaceAnnotation_Regex.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testRegion_ReplaceAnnotation_Regex</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code> class HelloWorld {
      public static void main(String... args) {
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_Region_ReplaceAnnotation_RegexInnComment.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_Region_ReplaceAnnotation_RegexInnComment.pass
index 78df225937..1bcbcb07cb 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_Region_ReplaceAnnotation_RegexInnComment.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_Region_ReplaceAnnotation_RegexInnComment.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testRegion_ReplaceAnnotation_RegexInnComment</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code> class HelloWorld {
      public static void main(String... args) {
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_MultipleReplaceAnnotation_Regex.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_MultipleReplaceAnnotation_Regex.pass
index 21c971b351..cc66e6ddb0 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_MultipleReplaceAnnotation_Regex.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_MultipleReplaceAnnotation_Regex.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testSingleLine_MultipleReplaceAnnotation_Regex</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code> class HelloWorld {
      public static void main(String... args) {
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_MultipleReplaceAnnotation_Substring.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_MultipleReplaceAnnotation_Substring.pass
index ac9a23369e..1c7dba4fe6 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_MultipleReplaceAnnotation_Substring.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_MultipleReplaceAnnotation_Substring.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testSingleLine_MultipleReplaceAnnotation_Substring</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code> class HelloWorld {
      public static void main(String... args) {
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_ReplaceAnnotation_Regex_DoubleQuote.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_ReplaceAnnotation_Regex_DoubleQuote.pass
index 3f79d39d39..31c90f99d1 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_ReplaceAnnotation_Regex_DoubleQuote.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_ReplaceAnnotation_Regex_DoubleQuote.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testSingleLine_ReplaceAnnotation_Regex_DoubleQuote</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code> class HelloWorld {
      public static void main(String... args) {
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_Replace_Regex.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_Replace_Regex.pass
index a5dd54ba9f..071e094748 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_Replace_Regex.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_Replace_Regex.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testSingleLine_Replace_Regex</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code> class HelloWorld {
      public static void main(String... args) {
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_Replace_RegexDot.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_Replace_RegexDot.pass
index 84036ecce7..c59b5c523e 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_Replace_RegexDot.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_Replace_RegexDot.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testSingleLine_Replace_RegexDot</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code> class HelloWorld {
      public static void main(String... args) {
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_Replace_RegexDotStar.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_Replace_RegexDotStar.pass
index 1a57784635..7e319b5222 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_Replace_RegexDotStar.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_Replace_RegexDotStar.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testSingleLine_Replace_RegexDotStar</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code> class HelloWorld {
      public static void main(String... args) {
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_Replace_Substring.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_Replace_Substring.pass
index 79366b1266..4c4a4527bc 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_Replace_Substring.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_SingleLine_Replace_Substring.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testSingleLine_Replace_Substring</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code> class HelloWorld {
      public static void main(String... args) {
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_TestError_HighlightTag.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_TestError_HighlightTag.pass
index f8a0fa69d3..5076e5a5a0 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_TestError_HighlightTag.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_TestError_HighlightTag.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>errorsInHighlightTag</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code><span style="color:red;">error: snippet markup: Invalid value <sub>^</sub><b><i>Blank</b></i> for <sub>^</sub><b><i>highlight</b></i> tag mark up attribute <sub>^</sub><b><i>substring</b></i></span>
 </code></pre></div>
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_TestError_LinkTag.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_TestError_LinkTag.pass
index acc516a5f0..5c29e61a89 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_TestError_LinkTag.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_TestError_LinkTag.pass
@@ -1,46 +1,77 @@
-<html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>errorsInLinkTag</b>()</pre><p><pre><code><span style="color:red;">error: snippet markup: Invalid value <sub>^</sub><b><i>Blank</b></i> for <sub>^</sub><b><i>link</b></i> tag mark up attribute <sub>^</sub><b><i>substring</b></i></span>
-</code></pre>
- 
- <pre><code><span style="color:red;">error: snippet markup: Invalid value <sub>^</sub><b><i>Blank</b></i> for <sub>^</sub><b><i>link</b></i> tag mark up attribute <sub>^</sub><b><i>substring</b></i></span>
-</code></pre>
- 
- <pre><code><span style="color:red;">error: snippet markup: Invalid value <sub>^</sub><b><i>Blank</b></i> for <sub>^</sub><b><i>link</b></i> tag mark up attribute <sub>^</sub><b><i>substring</b></i></span>
-</code></pre>
- 
- <pre><code><span style="color:red;">error: snippet markup: Invalid value <sub>^</sub><b><i>Blank</b></i> for <sub>^</sub><b><i>link</b></i> tag mark up attribute <sub>^</sub><b><i>regex</b></i></span>
-</code></pre>
- 
- <pre><code><span style="color:red;">error: snippet markup: Invalid value <sub>^</sub><b><i>Blank</b></i> for <sub>^</sub><b><i>link</b></i> tag mark up attribute <sub>^</sub><b><i>regex</b></i></span>
-</code></pre>
- 
- <pre><code><span style="color:red;">error: snippet markup: Invalid value <sub>^</sub><b><i>Blank</b></i> for <sub>^</sub><b><i>link</b></i> tag mark up attribute <sub>^</sub><b><i>regex</b></i></span>
-</code></pre>
- 
- <pre><code><span style="color:red;">error: snippet markup: Missing <sub>^</sub><b><i>link</b></i> tag attribute : <sub>^</sub><b><i>target</b></i></span>
-</code></pre>
- 
- <pre><code><span style="color:red;">error: snippet markup: Missing <sub>^</sub><b><i>link</b></i> tag attribute : <sub>^</sub><b><i>target</b></i></span>
-</code></pre>
- 
- <pre><code><span style="color:red;">error: snippet markup: Invalid value <sub>^</sub><b><i>Blank</b></i> for <sub>^</sub><b><i>link</b></i> tag mark up attribute <sub>^</sub><b><i>substring</b></i></span>
-</code></pre>
- 
- <pre><code> class Helloclass {
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regardingcopyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+<html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>errorsInLinkTag</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
+<pre><code><span style="color:red;">error: snippet markup: Invalid value <sub>^</sub><b><i>Blank</b></i> for <sub>^</sub><b><i>link</b></i> tag mark up attribute <sub>^</sub><b><i>substring</b></i></span>
+</code></pre></div>
+ 
+ <div id="snippet2" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet2">Copy</a></div>
+<pre><code><span style="color:red;">error: snippet markup: Invalid value <sub>^</sub><b><i>Blank</b></i> for <sub>^</sub><b><i>link</b></i> tag mark up attribute <sub>^</sub><b><i>substring</b></i></span>
+</code></pre></div>
+ 
+ <div id="snippet3" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet3">Copy</a></div>
+<pre><code><span style="color:red;">error: snippet markup: Invalid value <sub>^</sub><b><i>Blank</b></i> for <sub>^</sub><b><i>link</b></i> tag mark up attribute <sub>^</sub><b><i>substring</b></i></span>
+</code></pre></div>
+ 
+ <div id="snippet4" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet4">Copy</a></div>
+<pre><code><span style="color:red;">error: snippet markup: Invalid value <sub>^</sub><b><i>Blank</b></i> for <sub>^</sub><b><i>link</b></i> tag mark up attribute <sub>^</sub><b><i>regex</b></i></span>
+</code></pre></div>
+ 
+ <div id="snippet5" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet5">Copy</a></div>
+<pre><code><span style="color:red;">error: snippet markup: Invalid value <sub>^</sub><b><i>Blank</b></i> for <sub>^</sub><b><i>link</b></i> tag mark up attribute <sub>^</sub><b><i>regex</b></i></span>
+</code></pre></div>
+ 
+ <div id="snippet6" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet6">Copy</a></div>
+<pre><code><span style="color:red;">error: snippet markup: Invalid value <sub>^</sub><b><i>Blank</b></i> for <sub>^</sub><b><i>link</b></i> tag mark up attribute <sub>^</sub><b><i>regex</b></i></span>
+</code></pre></div>
+ 
+ <div id="snippet7" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet7">Copy</a></div>
+<pre><code><span style="color:red;">error: snippet markup: Missing <sub>^</sub><b><i>link</b></i> tag attribute : <sub>^</sub><b><i>target</b></i></span>
+</code></pre></div>
+ 
+ <div id="snippet8" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet8">Copy</a></div>
+<pre><code><span style="color:red;">error: snippet markup: Missing <sub>^</sub><b><i>link</b></i> tag attribute : <sub>^</sub><b><i>target</b></i></span>
+</code></pre></div>
+ 
+ <div id="snippet9" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet9">Copy</a></div>
+<pre><code><span style="color:red;">error: snippet markup: Invalid value <sub>^</sub><b><i>Blank</b></i> for <sub>^</sub><b><i>link</b></i> tag mark up attribute <sub>^</sub><b><i>substring</b></i></span>
+</code></pre></div>
+ 
+ <div id="snippet10" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet10">Copy</a></div>
+<pre><code> class Helloclass {
  }
  
-</code></pre>
+</code></pre></div>
  
- <pre><code> class HelloClass {
+ <div id="snippet11" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet11">Copy</a></div>
+<pre><code> class HelloClass {
  }
  
-</code></pre>
+</code></pre></div>
  
- <pre><code> class Helloclass {
+ <div id="snippet12" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet12">Copy</a></div>
+<pre><code> class Helloclass {
  }
  
-</code></pre>
+</code></pre></div>
  
- <pre><code> class HelloClass {
+ <div id="snippet13" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet13">Copy</a></div>
+<pre><code> class HelloClass {
  }
  
-</code></pre><p>
\ No newline at end of file
+</code></pre></div><p>
\ No newline at end of file
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_TestError_NoRegionToEnd.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_TestError_NoRegionToEnd.pass
index 3874175b80..109e38bf17 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_TestError_NoRegionToEnd.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_TestError_NoRegionToEnd.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>errorsInNoRegionToEnd</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code><span style="color:red;">error: snippet markup: no region to end @end <sub>^</sub><b><i>anonymous</b></i></span>
 </code></pre></div><p>
\ No newline at end of file
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_TestError_ReplaceTag.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_TestError_ReplaceTag.pass
index 173fb2afd7..e0c29affd4 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_TestError_ReplaceTag.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_TestError_ReplaceTag.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>errorsInReplaceTag</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code><span style="color:red;">error: snippet markup: Invalid value <sub>^</sub><b><i>Blank</b></i> for <sub>^</sub><b><i>replace</b></i> tag mark up attribute <sub>^</sub><b><i>substring</b></i></span>
 </code></pre></div>
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_TestError_UnpairedRegion.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_TestError_UnpairedRegion.pass
index 59b3db609f..60afed3e2d 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_TestError_UnpairedRegion.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_TestError_UnpairedRegion.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>errorsInUnpairedRegion</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code><span style="color:red;">error: snippet markup: unpaired region <b><i>highlight anonymous</b></i></span>
 </code></pre></div>
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_external_file.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_external_file.pass
new file mode 100644
index 0000000000..ca11535648
--- /dev/null
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_external_file.pass
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+<html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>externalSnippetFile</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
+<pre><code>import java.util.Optional;
+
+public class HelloWorld {
+    void show(Optional&lt;String> v) {
+        
+        if (v.isPresent()) {
+            
+            System.out.println("v: " + v.get()); 
+            
+        }
+        
+    }
+}
+</code></pre></div>
+ <div id="snippet2" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet2">Copy</a></div>
+<pre><code>import java.util.Optional;
+
+public class HelloWorld {
+    void show(Optional&lt;String> v) {
+        
+        if (v.isPresent()) {
+            
+            System.out.println("v: " + v.get()); 
+            
+        }
+        
+    }
+}
+</code></pre></div>
+ <div id="snippet3" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet3">Copy</a></div>
+<pre><code>import java.util.Optional;
+
+public class HelloWorld {
+    void show(Optional&lt;String> v) {
+        
+        if (v.isPresent()) {
+            
+            System.out.println("v: " + v.get()); 
+            
+        }
+        
+    }
+}
+</code></pre></div>
+ <div id="snippet4" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet4">Copy</a></div>
+<pre><code>import java.util.Optional;
+
+public class HelloWorld {
+    void show(Optional&lt;String> v) {
+        
+        if (v.isPresent()) {
+            
+            System.out.println("v: " + v.get()); 
+            
+        }
+        
+    }
+}
+</code></pre></div>
+ <div id="snippet5" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet5">Copy</a></div>
+<pre><code>import java.util.Optional;
+
+public class HelloWorld {
+    void show(Optional&lt;String> v) {
+        
+        if (v.isPresent()) {
+            
+            System.out.println("v: " + v.get()); 
+            
+        }
+        
+    }
+}
+</code></pre></div><p>
\ No newline at end of file
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_file_empty.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_file_empty.pass
new file mode 100644
index 0000000000..73eb955da7
--- /dev/null
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_file_empty.pass
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+<html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>errorFileEmpty</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
+<pre><code><span style="color:red;">error: snippet markup: File invalid</span>
+
+ <div id="snippet2" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet2">Copy</a></div>
+<pre><code><span style="color:red;">error: snippet markup: File invalid</span>
+
+ <div id="snippet3" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet3">Copy</a></div>
+<pre><code><span style="color:red;">error: snippet markup: File invalid</span>
+
+ <div id="snippet4" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet4">Copy</a></div>
+<pre><code><span style="color:red;">error: snippet markup: File invalid</span>
+<p>
\ No newline at end of file
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_file_invalid.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_file_invalid.pass
new file mode 100644
index 0000000000..109dbbb4f1
--- /dev/null
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_file_invalid.pass
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+<html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>errorFileInvalid</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
+<pre><code><span style="color:red;">error: snippet markup: File invalid</span>
+
+ <div id="snippet2" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet2">Copy</a></div>
+<pre><code><span style="color:red;">error: snippet markup: File invalid</span>
+
+ <div id="snippet3" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet3">Copy</a></div>
+<pre><code><span style="color:red;">error: snippet markup: File invalid</span>
+
+ <div id="snippet4" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet4">Copy</a></div>
+<pre><code><span style="color:red;">error: snippet markup: File invalid</span>
+<p>
\ No newline at end of file
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightRecord.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightRecord.pass
index ebeb164087..d6cdb96dd1 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightRecord.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightRecord.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>private static void <b>method</b>(<a href='*1'>R</a> r)</pre><p>A simple program.
 
  <code><a href='*2'>System.out</a></code>
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightTagRegexWithAllCharacterChange.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightTagRegexWithAllCharacterChange.pass
index a42f299868..d2726f9510 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightTagRegexWithAllCharacterChange.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightTagRegexWithAllCharacterChange.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>highlightTagRegexWithAllCharacterChange</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code>   public static void main(String... args) {
       
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightTagRegexWithAllCharacterChangeUsingDot.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightTagRegexWithAllCharacterChangeUsingDot.pass
index 994db22393..e03c964bb0 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightTagRegexWithAllCharacterChangeUsingDot.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightTagRegexWithAllCharacterChangeUsingDot.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>highlightTagRegexWithAllCharacterChangeUsingDot</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code>   public static void main(String... args) {
       
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightTagSubstringApplyToNextLine.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightTagSubstringApplyToNextLine.pass
index 9b05d647a3..d2516b01de 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightTagSubstringApplyToNextLine.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightTagSubstringApplyToNextLine.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>highlightTagSubstringApplyToNextLine</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code>   public static void main(String... args) {
       
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingMultipleSnippetTagInOneJavaDocWithRegion.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingMultipleSnippetTagInOneJavaDocWithRegion.pass
index 83732f2b1f..4c0b96aa6d 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingMultipleSnippetTagInOneJavaDocWithRegion.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingMultipleSnippetTagInOneJavaDocWithRegion.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>highlightUsingSubstringRegexAndType</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code>   public static void main(String... substring) {
        for (var regex : substring) {
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingNestedRegions.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingNestedRegions.pass
index 0b642aa0f5..dbd0412fd0 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingNestedRegions.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingNestedRegions.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>highlightUsingNestedRegions</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code>   public static void \bmain\b(String... args) {
  
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingRegex.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingRegex.pass
index 7c96bd0913..1270464aa8 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingRegex.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingRegex.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>highlightUsingRegex</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code>   public static void main(String... args1) {
        for (var arg : args<b>1</b>) {                 
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingRegionsEndedWithDoubleColon.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingRegionsEndedWithDoubleColon.pass
index faac4e2c66..cc9c7542e2 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingRegionsEndedWithDoubleColon.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingRegionsEndedWithDoubleColon.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>highlightUsingRegionsEndedWithDoubleColon</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code>   public static void \bmain\b(String... args) {
        for (var arg : args) {                         
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingSubstring.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingSubstring.pass
index 7230e25d72..51453e8eee 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingSubstring.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingSubstring.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>highlightUsingSubstring</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code>   public static void main(String... args) {
        for (var arg : <b>a</b><b>r</b><b>g</b><b>s</b>) {                 
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingSubstringAndRegex.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingSubstringAndRegex.pass
index dea56f3efa..9461f5cbee 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingSubstringAndRegex.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingSubstringAndRegex.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>highlightUsingSubstringAndRegex</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code>   public static void main(String... args1) {
        for (<b>v</b><b>a</b><b>r</b> arg : args<b>1</b>) {                 
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingSubstringRegexAndType.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingSubstringRegexAndType.pass
index 83732f2b1f..4c0b96aa6d 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingSubstringRegexAndType.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlightUsingSubstringRegexAndType.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>highlightUsingSubstringRegexAndType</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code>   public static void main(String... substring) {
        for (var regex : substring) {
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlight_markuptag.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlight_markuptag.pass
index 2e5d769fb5..2ead38ec4c 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlight_markuptag.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_highlight_markuptag.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>private static void <b>method</b>(<a href='*1'>R</a> r)</pre><p>A simple program.
  <code><a href='*2'>System.out</a></code>
  <pre><code> class HelloWorld {
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_noMarkupTagPresent.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_noMarkupTagPresent.pass
index 82b3e07aea..dff623a51d 100644
--- a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_noMarkupTagPresent.pass
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_noMarkupTagPresent.pass
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 <html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>noMarkupTagPresent</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
 <pre><code>   public static void main(String... args) {
      System.out.println("args"); // highligh substring = "args"
diff --git a/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/HtmlStartEndTag.java b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_region_invalid.pass
similarity index 55%
copy from java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/HtmlStartEndTag.java
copy to java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_region_invalid.pass
index bd20cf4b43..8c73f61cab 100644
--- a/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/HtmlStartEndTag.java
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_region_invalid.pass
@@ -16,29 +16,9 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
-package org.netbeans.api.java.source.ui.snippet;
-
-/**
- *
- * @author aksinsin
- */
-public class HtmlStartEndTag {
-    
-    private final String startTag;
-    private final String endTag;
-
-    public HtmlStartEndTag(String startTag, String endTag) {
-        this.startTag = startTag;
-        this.endTag = endTag;
-    }
-
-    public String getStartTag() {
-        return startTag;
-    }
-
-    public String getEndTag() {
-        return endTag;
-    }
-    
-}
+<html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>errorRegionInvalid</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
+<pre><code><span style="color:red;">error: snippet markup: Region not found</span>
+</code></pre></div>
+ <div id="snippet2" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet2">Copy</a></div>
+<pre><code><span style="color:red;">error: snippet markup: Region not found</span>
+</code></pre></div><p>
\ No newline at end of file
diff --git a/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_region_valid.pass b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_region_valid.pass
new file mode 100644
index 0000000000..c2488bab0c
--- /dev/null
+++ b/java/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/editor/java/GoToSupportTest/javadocsnippet_region_valid.pass
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+<html><body><font size='+0'><b><a href='*0'>test.&#x200B;Test</a></b></font><pre>public void <b>testRegionValid</b>()</pre><p><div id="snippet1" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet1">Copy</a></div>
+<pre><code>        
+        if (v.isPresent()) {
+            
+            System.out.println("v: " + v.get()); 
+            
+        }
+        
+</code></pre></div>
+ <div id="snippet2" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet2">Copy</a></div>
+<pre><code>import java.util.Optional;
+
+public class HelloWorld {
+    void show(Optional&lt;String> v) {
+        
+        if (v.isPresent()) {
+            
+            System.out.println("v: " + v.get()); 
+            
+        }
+        
+    }
+}
+</code></pre></div>
+ <div id="snippet3" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet3">Copy</a></div>
+<pre><code>        
+        if (v.isPresent()) {
+            
+            System.out.println("v: " + v.get()); 
+            
+        }
+        
+</code></pre></div>
+ <div id="snippet4" style="font-size: 10px; border: 1px solid black; margin-top: 2px; margin-bottom: 2px"><div align=right><a href="copy.snippet4">Copy</a></div>
+<pre><code>            
+            System.out.println("v: " + v.get()); 
+            
+</code></pre></div><p>
\ No newline at end of file
diff --git a/java/java.editor/test/unit/data/org/netbeans/modules/java/editor/javadocsnippet/data/Errors.java b/java/java.editor/test/unit/data/org/netbeans/modules/java/editor/javadocsnippet/data/Errors.java
index c512324940..a8e4f4db6a 100644
--- a/java/java.editor/test/unit/data/org/netbeans/modules/java/editor/javadocsnippet/data/Errors.java
+++ b/java/java.editor/test/unit/data/org/netbeans/modules/java/editor/javadocsnippet/data/Errors.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package test;
 
 public class Test {
@@ -231,4 +249,48 @@ public class Test {
      */
     public void errorsInNoRegionToEnd(){}
     
+    /**
+    *
+    * {@snippet file=""}
+    * {@snippet class=""}
+    * {@snippet file="" class=""}
+    * {@snippet file="" file=""}
+    */
+    public void errorFileEmpty() {}
+
+    /**
+    *
+    * {@snippet file="HiWorld.java"}
+    * {@snippet class="HiWorld"}
+    * {@snippet file="HiWorld.java" class="HiWorld"}
+    * {@snippet file="HiWorld.java" file="HiWorld.java"}
+    */
+    public void errorFileInvalid() {}
+
+    /**
+    *
+    * {@snippet file="HelloWorld.java"}
+    * {@snippet class="HelloWorld"}
+    * {@snippet file="HiWorld.java" class="HelloWorld"}
+    * {@snippet file="HelloWorld.java" file="HiWorld.java"}
+    * {@snippet file="" file="HelloWorld.java"}
+    */
+    public void externalSnippetFile() {}
+
+    /**
+    *
+    * {@snippet file="HelloWorld.java" region="test"}
+    * {@snippet class="HelloWorld" region="test"}
+    */
+    public void errorRegionInvalid() {}
+
+    /**
+    *
+    * {@snippet file="HelloWorld.java" region="example"}
+    * {@snippet class="HelloWorld" region=""}
+    * {@snippet class="HelloWorld" region="example"}
+    * {@snippet class="HelloWorld" region="region1"}
+    * 
+    */
+    public void testRegionValid() {}
 }
diff --git a/java/java.editor/test/unit/data/org/netbeans/modules/java/editor/javadocsnippet/data/HighlightTag.java b/java/java.editor/test/unit/data/org/netbeans/modules/java/editor/javadocsnippet/data/HighlightTag.java
index 3e16e18f04..04e6e1a572 100644
--- a/java/java.editor/test/unit/data/org/netbeans/modules/java/editor/javadocsnippet/data/HighlightTag.java
+++ b/java/java.editor/test/unit/data/org/netbeans/modules/java/editor/javadocsnippet/data/HighlightTag.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package test;
 
 public class Test {
diff --git a/java/java.editor/test/unit/data/org/netbeans/modules/java/editor/javadocsnippet/data/LinkTag.java b/java/java.editor/test/unit/data/org/netbeans/modules/java/editor/javadocsnippet/data/LinkTag.java
index 0382eefead..c0a094f98c 100644
--- a/java/java.editor/test/unit/data/org/netbeans/modules/java/editor/javadocsnippet/data/LinkTag.java
+++ b/java/java.editor/test/unit/data/org/netbeans/modules/java/editor/javadocsnippet/data/LinkTag.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package test;
 
 import java.util.ArrayList;
diff --git a/java/java.editor/test/unit/data/org/netbeans/modules/java/editor/javadocsnippet/data/snippet-files/HelloWorld.java b/java/java.editor/test/unit/data/org/netbeans/modules/java/editor/javadocsnippet/data/snippet-files/HelloWorld.java
new file mode 100644
index 0000000000..f8b353a17c
--- /dev/null
+++ b/java/java.editor/test/unit/data/org/netbeans/modules/java/editor/javadocsnippet/data/snippet-files/HelloWorld.java
@@ -0,0 +1,13 @@
+import java.util.Optional;
+
+public class HelloWorld {
+    void show(Optional<String> v) {
+        //@start region="example"
+        if (v.isPresent()) {
+            //@start region="region1"
+            System.out.println("v: " + v.get()); 
+            // @end
+        }
+        //@end
+    }
+}
\ No newline at end of file
diff --git a/java/java.editor/test/unit/src/org/netbeans/modules/editor/java/GoToSupportTest.java b/java/java.editor/test/unit/src/org/netbeans/modules/editor/java/GoToSupportTest.java
index 8f66d208b1..7d4074dcd4 100644
--- a/java/java.editor/test/unit/src/org/netbeans/modules/editor/java/GoToSupportTest.java
+++ b/java/java.editor/test/unit/src/org/netbeans/modules/editor/java/GoToSupportTest.java
@@ -28,9 +28,14 @@ import java.util.List;
 import java.util.concurrent.CountDownLatch;
 import java.util.regex.Pattern;
 import javax.lang.model.SourceVersion;
+
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.stream.Stream;
+
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
 import javax.lang.model.element.ExecutableElement;
@@ -67,6 +72,7 @@ import org.openide.filesystems.Repository;
 import org.openide.loaders.DataObject;
 import org.openide.util.Exceptions;
 import org.openide.util.lookup.ServiceProvider;
+import static java.nio.file.StandardCopyOption.*;
 
 /**
  *
@@ -1242,8 +1248,7 @@ public class GoToSupportTest extends NbTestCase {
         return null;
     }
     
-    protected void performTest(String source, int caretPos, String textToInsert, String goldenFileName, String sourceLevel) throws Exception {
-        
+    protected void performTest(String source, int caretPos, String textToInsert, String goldenFileName, String sourceLevel, boolean external) throws Exception {
         clearWorkDir();
         FileUtil.refreshFor(getWorkDir());
 
@@ -1257,6 +1262,12 @@ public class GoToSupportTest extends NbTestCase {
         copyToWorkDir(new File(getDataDir(), "org/netbeans/modules/java/editor/javadocsnippet/data/" + source + ".java"), testSource);
         FileObject testSourceFO = FileUtil.toFileObject(testSource);
         
+        if(external) {
+            FileUtil.createFolder(sourceDir, "test");
+            copyFolder((new File(getDataDir(),"org/netbeans/modules/java/editor/javadocsnippet/data/snippet-files").toPath()),
+                    new File(getWorkDir(), "src/test/snippet-files").toPath());
+        }
+
         SourceUtilsTestUtil.setSourceLevel(testSourceFO, sourceLevel);
         SourceUtilsTestUtil.prepareTest(sourceDir, buildDir, cacheDir, new FileObject[0]);
         assertNotNull(testSourceFO);
@@ -1279,6 +1290,7 @@ public class GoToSupportTest extends NbTestCase {
         Writer out = new FileWriter(output);            
         out.write(docText);
         out.close();
+
         
         File goldenFile = getGoldenFile(goldenFileName);
         File diffFile = new File(getWorkDir(), getName() + ".diff");
@@ -1288,6 +1300,20 @@ public class GoToSupportTest extends NbTestCase {
         LifecycleManager.getDefault().saveAll();
     }
 
+    public  void copyFolder(Path src, Path dest) throws IOException {
+        try (Stream<Path> stream = Files.walk(src)) {
+            stream.forEach(source -> copy(source, dest.resolve(src.relativize(source))));
+        }
+    }
+
+    private void copy(Path source, Path dest) {
+        try {
+            Files.copy(source, dest, REPLACE_EXISTING);
+        } catch (Exception e) {
+            throw new RuntimeException(e.getMessage(), e);
+        }
+    }
+
     protected void copyToWorkDir(File resource, File toFile) throws IOException {
         InputStream is = new FileInputStream(resource);
         OutputStream outs = new FileOutputStream(toFile);
@@ -1568,7 +1594,7 @@ public class GoToSupportTest extends NbTestCase {
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
         
-        performTest("HighlightTag", 388, null, "javadocsnippet_highlightRecord.pass", this.sourceLevel);
+        performTest("HighlightTag", 388, null, "javadocsnippet_highlightRecord.pass", this.sourceLevel, false);
     }
     
     public void testHighlightUsingSubstring() throws Exception {
@@ -1580,7 +1606,7 @@ public class GoToSupportTest extends NbTestCase {
         EXTRA_OPTIONS.add("--enable-preview");      
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
         
-        performTest("HighlightTag", 858, null, "javadocsnippet_highlightUsingSubstring.pass", this.sourceLevel);
+        performTest("HighlightTag", 1667, null, "javadocsnippet_highlightUsingSubstring.pass", this.sourceLevel, false);
     }
     
     public void testHesthighlightUsingRegex() throws Exception {
@@ -1592,7 +1618,7 @@ public class GoToSupportTest extends NbTestCase {
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
         
-        performTest("HighlightTag",1280, null, "javadocsnippet_highlightUsingRegex.pass", this.sourceLevel);
+        performTest("HighlightTag",2092, null, "javadocsnippet_highlightUsingRegex.pass", this.sourceLevel, false);
     }
  
     public void testHighlightUsingSubstringAndRegex() throws Exception {
@@ -1604,7 +1630,7 @@ public class GoToSupportTest extends NbTestCase {
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
 
-        performTest("HighlightTag", 1788, null, "javadocsnippet_highlightUsingSubstringAndRegex.pass", this.sourceLevel);
+        performTest("HighlightTag", 2604, null, "javadocsnippet_highlightUsingSubstringAndRegex.pass", this.sourceLevel, false);
     }
     
     public void testHighlightUsingSubstringRegexAndType() throws Exception {
@@ -1616,7 +1642,7 @@ public class GoToSupportTest extends NbTestCase {
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
 
-        performTest("HighlightTag", 3734, null, "javadocsnippet_highlightUsingSubstringRegexAndType.pass", this.sourceLevel);
+        performTest("HighlightTag", 4551, null, "javadocsnippet_highlightUsingSubstringRegexAndType.pass", this.sourceLevel, false);
     }
         
     public void testHighlightUsingMultipleSnippetTagInOneJavaDocWithRegion() throws Exception {
@@ -1628,7 +1654,7 @@ public class GoToSupportTest extends NbTestCase {
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
 
-        performTest("HighlightTag", 3734, null, "javadocsnippet_highlightUsingMultipleSnippetTagInOneJavaDocWithRegion.pass", this.sourceLevel);
+        performTest("HighlightTag", 5333, null, "javadocsnippet_highlightUsingMultipleSnippetTagInOneJavaDocWithRegion.pass", this.sourceLevel, false);
     }
         
     public void testHighlightUsingNestedRegions() throws Exception {
@@ -1640,7 +1666,7 @@ public class GoToSupportTest extends NbTestCase {
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
 
-        performTest("HighlightTag", 5335, null, "javadocsnippet_highlightUsingNestedRegions.pass", this.sourceLevel);
+        performTest("HighlightTag", 6148, null, "javadocsnippet_highlightUsingNestedRegions.pass", this.sourceLevel, false);
     }
     
     public void testHighlightUsingRegionsEndedWithDoubleColon() throws Exception {
@@ -1652,7 +1678,7 @@ public class GoToSupportTest extends NbTestCase {
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
 
-        performTest("HighlightTag", 6028, null, "javadocsnippet_highlightUsingRegionsEndedWithDoubleColon.pass", this.sourceLevel);
+        performTest("HighlightTag", 6840, null, "javadocsnippet_highlightUsingRegionsEndedWithDoubleColon.pass", this.sourceLevel, false);
     }
     
     public void testNoMarkupTagPresent() throws Exception {
@@ -1664,7 +1690,7 @@ public class GoToSupportTest extends NbTestCase {
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
 
-        performTest("HighlightTag", 6271, null, "javadocsnippet_noMarkupTagPresent.pass", this.sourceLevel);
+        performTest("HighlightTag", 7083, null, "javadocsnippet_noMarkupTagPresent.pass", this.sourceLevel, false);
     }
  
     public void testHighlightTagSubstringApplyToNextLine() throws Exception {
@@ -1676,7 +1702,7 @@ public class GoToSupportTest extends NbTestCase {
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
 
-        performTest("HighlightTag", 6521, null, "javadocsnippet_highlightTagSubstringApplyToNextLine.pass", this.sourceLevel);
+        performTest("HighlightTag", 7333, null, "javadocsnippet_highlightTagSubstringApplyToNextLine.pass", this.sourceLevel, false);
     }
  
     public void testHighlightTagRegexWithAllCharacterChange() throws Exception {
@@ -1688,7 +1714,7 @@ public class GoToSupportTest extends NbTestCase {
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
 
-        performTest("HighlightTag", 6783, null, "javadocsnippet_highlightTagRegexWithAllCharacterChange.pass", this.sourceLevel);
+        performTest("HighlightTag", 7598, null, "javadocsnippet_highlightTagRegexWithAllCharacterChange.pass", this.sourceLevel, false);
     }
        
     public void testHighlightTagRegexWithAllCharacterChangeUsingDot() throws Exception {
@@ -1700,7 +1726,7 @@ public class GoToSupportTest extends NbTestCase {
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
 
-        performTest("HighlightTag", 7047, null, "javadocsnippet_highlightTagRegexWithAllCharacterChangeUsingDot.pass", this.sourceLevel);
+        performTest("HighlightTag", 7860, null, "javadocsnippet_highlightTagRegexWithAllCharacterChangeUsingDot.pass", this.sourceLevel, false);
     }
     
     public void testSingleLine_Replace_Regex() throws Exception {
@@ -1710,7 +1736,7 @@ public class GoToSupportTest extends NbTestCase {
         this.sourceLevel = getLatestSourceVersion();
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
-        performTest("ReplaceTag", 1127, null, "javadocsnippet_SingleLine_Replace_Regex.pass", this.sourceLevel);
+        performTest("ReplaceTag", 1127, null, "javadocsnippet_SingleLine_Replace_Regex.pass", this.sourceLevel, false);
     }
 
     public void testSingleLine_Replace_RegexDotStar() throws Exception {
@@ -1720,7 +1746,7 @@ public class GoToSupportTest extends NbTestCase {
         this.sourceLevel = getLatestSourceVersion();
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
-        performTest("ReplaceTag", 1417, null, "javadocsnippet_SingleLine_Replace_RegexDotStar.pass", this.sourceLevel);
+        performTest("ReplaceTag", 1417, null, "javadocsnippet_SingleLine_Replace_RegexDotStar.pass", this.sourceLevel, false);
     }
 
     public void testSingleLine_Replace_RegexDot() throws Exception {
@@ -1730,7 +1756,7 @@ public class GoToSupportTest extends NbTestCase {
         this.sourceLevel = getLatestSourceVersion();
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
-        performTest("ReplaceTag", 1713, null, "javadocsnippet_SingleLine_Replace_RegexDot.pass", this.sourceLevel);
+        performTest("ReplaceTag", 1713, null, "javadocsnippet_SingleLine_Replace_RegexDot.pass", this.sourceLevel, false);
     }
 
     public void testSingleLine_Replace_Substring() throws Exception {
@@ -1740,7 +1766,7 @@ public class GoToSupportTest extends NbTestCase {
         this.sourceLevel = getLatestSourceVersion();
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
-        performTest("ReplaceTag", 2021, null, "javadocsnippet_SingleLine_Replace_Substring.pass", this.sourceLevel);
+        performTest("ReplaceTag", 2021, null, "javadocsnippet_SingleLine_Replace_Substring.pass", this.sourceLevel, false);
     }
 
     public void testSingleLine_MultipleReplaceAnnotation_Regex() throws Exception {
@@ -1750,7 +1776,7 @@ public class GoToSupportTest extends NbTestCase {
         this.sourceLevel = getLatestSourceVersion();
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
-        performTest("ReplaceTag", 2383, null, "javadocsnippet_SingleLine_MultipleReplaceAnnotation_Regex.pass", this.sourceLevel);
+        performTest("ReplaceTag", 2383, null, "javadocsnippet_SingleLine_MultipleReplaceAnnotation_Regex.pass", this.sourceLevel, false);
     }
 
     public void testSingleLine_MultipleReplaceAnnotation_Substring() throws Exception {
@@ -1760,7 +1786,7 @@ public class GoToSupportTest extends NbTestCase {
         this.sourceLevel = getLatestSourceVersion();
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
-        performTest("ReplaceTag", 2878, null, "javadocsnippet_SingleLine_MultipleReplaceAnnotation_Substring.pass", this.sourceLevel);
+        performTest("ReplaceTag", 2878, null, "javadocsnippet_SingleLine_MultipleReplaceAnnotation_Substring.pass", this.sourceLevel, false);
     }
 
     public void testSingleLine_ReplaceAnnotation_Regex_DoubleQuote() throws Exception {
@@ -1770,7 +1796,7 @@ public class GoToSupportTest extends NbTestCase {
         this.sourceLevel = getLatestSourceVersion();
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
-        performTest("ReplaceTag", 3221, null, "javadocsnippet_SingleLine_ReplaceAnnotation_Regex_DoubleQuote.pass", this.sourceLevel);
+        performTest("ReplaceTag", 3221, null, "javadocsnippet_SingleLine_ReplaceAnnotation_Regex_DoubleQuote.pass", this.sourceLevel, false);
     }
 
     public void testRegion_ReplaceAnnotation_Regex() throws Exception {
@@ -1780,7 +1806,7 @@ public class GoToSupportTest extends NbTestCase {
         this.sourceLevel = getLatestSourceVersion();
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
-        performTest("ReplaceTag", 3732, null, "javadocsnippet_Region_ReplaceAnnotation_Regex.pass", this.sourceLevel);
+        performTest("ReplaceTag", 3732, null, "javadocsnippet_Region_ReplaceAnnotation_Regex.pass", this.sourceLevel, false);
     }
 
     public void testRegion_ReplaceAnnotation_RegexInnComment() throws Exception {
@@ -1790,7 +1816,7 @@ public class GoToSupportTest extends NbTestCase {
         this.sourceLevel = getLatestSourceVersion();
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
-        performTest("ReplaceTag", 4135, null, "javadocsnippet_Region_ReplaceAnnotation_RegexInnComment.pass", this.sourceLevel);
+        performTest("ReplaceTag", 4135, null, "javadocsnippet_Region_ReplaceAnnotation_RegexInnComment.pass", this.sourceLevel, false);
     }
 
     public void testNestedRegion_ReplaceAnnotation_Substring() throws Exception {
@@ -1800,7 +1826,7 @@ public class GoToSupportTest extends NbTestCase {
         this.sourceLevel = getLatestSourceVersion();
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
-        performTest("ReplaceTag", 4712, null, "javadocsnippet_NestedRegion_ReplaceAnnotation_Substring.pass", this.sourceLevel);
+        performTest("ReplaceTag", 4712, null, "javadocsnippet_NestedRegion_ReplaceAnnotation_Substring.pass", this.sourceLevel, false);
     }
 
     public void testNestedRegion_ReplaceAnnotation_Regex() throws Exception {
@@ -1810,7 +1836,7 @@ public class GoToSupportTest extends NbTestCase {
         this.sourceLevel = getLatestSourceVersion();
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
-        performTest("ReplaceTag", 5270, null, "javadocsnippet_NestedRegion_ReplaceAnnotation_Regex.pass", this.sourceLevel);
+        performTest("ReplaceTag", 5270, null, "javadocsnippet_NestedRegion_ReplaceAnnotation_Regex.pass", this.sourceLevel, false);
     }
 
     public void testNestedRegion_Highlight_And_replace() throws Exception {
@@ -1820,7 +1846,7 @@ public class GoToSupportTest extends NbTestCase {
         this.sourceLevel = getLatestSourceVersion();
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
-        performTest("ReplaceTag", 6597, null, "javadocsnippet_NestedRegion_Highlight_And_replace.pass", this.sourceLevel);
+        performTest("ReplaceTag", 6597, null, "javadocsnippet_NestedRegion_Highlight_And_replace.pass", this.sourceLevel, false);
     }
 
     public void testHighlightAndReplace_cornercase() throws Exception {
@@ -1830,7 +1856,120 @@ public class GoToSupportTest extends NbTestCase {
         this.sourceLevel = getLatestSourceVersion();
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
-        performTest("ReplaceTag", 6926, null, "javadocsnippet_HighlightAndReplace_cornercase.pass", this.sourceLevel);
+        performTest("ReplaceTag", 6926, null, "javadocsnippet_HighlightAndReplace_cornercase.pass", this.sourceLevel, false);
+    }
+
+    public void testLinkTag() throws Exception {
+        if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
+            return;
+        }
+        this.sourceLevel = getLatestSourceVersion();
+        EXTRA_OPTIONS.add("--enable-preview");
+        JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
+        performTest("LinkTag", 1368, null, "javadocsnippet_LinkTag.pass", this.sourceLevel, false);
+
+    }
+
+    public void testLinkTag_With_RegexAndRegion() throws Exception {
+        if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
+            return;
+        }
+        this.sourceLevel = getLatestSourceVersion();
+        EXTRA_OPTIONS.add("--enable-preview");
+        JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
+        performTest("LinkTag", 1809, null, "javadocsnippet_LinkTag_With_RegexAndRegion.pass", this.sourceLevel, false);
+
+    }
+
+    public void testLinkTag_AppliesToNextLine() throws Exception {
+        if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
+            return;
+        }
+        this.sourceLevel = getLatestSourceVersion();
+        EXTRA_OPTIONS.add("--enable-preview");
+        JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
+        performTest("LinkTag", 2160, null, "javadocsnippet_LinkTag_AppliesToNextLine.pass", this.sourceLevel, false);
+
+    }
+
+    public void testLink_MultipleTag_OnSameLine() throws Exception {
+        if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
+            return;
+        }
+        this.sourceLevel = getLatestSourceVersion();
+        EXTRA_OPTIONS.add("--enable-preview");
+        JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
+        performTest("LinkTag", 2547, null, "javadocsnippet_Link_MultipleTag_OnSameLine.pass", this.sourceLevel, false);
+    }
+
+    public void testLinkTag_With_RegionAttribute() throws Exception {
+        if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
+            return;
+        }
+        this.sourceLevel = getLatestSourceVersion();
+        EXTRA_OPTIONS.add("--enable-preview");
+        JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
+        performTest("LinkTag", 3230, null, "javadocsnippet_LinkTag_With_RegionAttribute.pass", this.sourceLevel, false);
+    }
+
+    public void testLinkTag_Ref_ToThisClass_UsingHash() throws Exception {
+        if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
+            return;
+        }
+        this.sourceLevel = getLatestSourceVersion();
+        EXTRA_OPTIONS.add("--enable-preview");
+        JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
+        performTest("LinkTag", 3562, null, "javadocsnippet_LinkTag_Ref_ToThisClass_UsingHash.pass", this.sourceLevel, false);
+    }
+
+    public void testLinkTag_FieldRef_ToThisClass_UsingHash() throws Exception {
+        if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
+            return;
+        }
+        this.sourceLevel = getLatestSourceVersion();
+        EXTRA_OPTIONS.add("--enable-preview");
+        JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
+        performTest("LinkTag", 3884, null, "javadocsnippet_LinkTag_FieldRef_ToThisClass_UsingHash.pass", this.sourceLevel, false);
+    }
+
+    public void testLinkTag_AlongWith_HighlightTag() throws Exception {
+        if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
+            return;
+        }
+        this.sourceLevel = getLatestSourceVersion();
+        EXTRA_OPTIONS.add("--enable-preview");
+        JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
+        performTest("LinkTag", 4302, null, "javadocsnippet_LinkTag_AlongWith_HighlightTag.pass", this.sourceLevel, false);
+    }
+
+    public void testLinkTag_AlongWith_ReplaceTag() throws Exception {
+        if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
+            return;
+        }
+        this.sourceLevel = getLatestSourceVersion();
+        EXTRA_OPTIONS.add("--enable-preview");
+        JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
+        performTest("LinkTag", 4705, null, "javadocsnippet_LinkTag_AlongWith_ReplaceTag.pass", this.sourceLevel, false);
+    }
+
+    public void testLinkTag_AlongWith_SubStringAndReplaceTag() throws Exception {
+        if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
+            return;
+        }
+        this.sourceLevel = getLatestSourceVersion();
+        EXTRA_OPTIONS.add("--enable-preview");
+        JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
+        performTest("LinkTag", 5163, null, "javadocsnippet_LinkTag_AlongWith_SubStringAndReplaceTag.pass", this.sourceLevel, false);
+    }
+
+    public void testLinkTag_EmptyReplacementValue() throws Exception {
+        if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
+            return;
+        }
+        this.sourceLevel = getLatestSourceVersion();
+        EXTRA_OPTIONS.add("--enable-preview");
+        JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
+        performTest("LinkTag", 5568, null, "javadocsnippet_LinkTag_EmptyReplacementValue.pass", this.sourceLevel, false);
     }
 
     public void testError_HighlightTag() throws Exception {
@@ -1840,7 +1979,7 @@ public class GoToSupportTest extends NbTestCase {
         this.sourceLevel = getLatestSourceVersion();
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
-        performTest("Errors", 1331, null, "javadocsnippet_TestError_HighlightTag.pass", this.sourceLevel);
+        performTest("Errors", 2140, null, "javadocsnippet_TestError_HighlightTag.pass", this.sourceLevel, false);
     }
     
     public void testError_ReplaceTag() throws Exception {
@@ -1850,7 +1989,17 @@ public class GoToSupportTest extends NbTestCase {
         this.sourceLevel = getLatestSourceVersion();
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
-        performTest("Errors", 2613, null, "javadocsnippet_TestError_ReplaceTag.pass", this.sourceLevel);
+        performTest("Errors", 3422, null, "javadocsnippet_TestError_ReplaceTag.pass", this.sourceLevel, false);
+    }
+    
+    public void testError_LinkTag() throws Exception {
+        if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
+            return;
+        }
+        this.sourceLevel = getLatestSourceVersion();
+        EXTRA_OPTIONS.add("--enable-preview");
+        JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
+        performTest("Errors", 4877, null, "javadocsnippet_TestError_LinkTag.pass", this.sourceLevel, false);
     }
     
     public void testError_UnpairedRegion() throws Exception {
@@ -1860,7 +2009,7 @@ public class GoToSupportTest extends NbTestCase {
         this.sourceLevel = getLatestSourceVersion();
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
-        performTest("Errors", 4740, null, "javadocsnippet_TestError_UnpairedRegion.pass", this.sourceLevel);
+        performTest("Errors", 5548, null, "javadocsnippet_TestError_UnpairedRegion.pass", this.sourceLevel, false);
     }
     
     public void testError_NoRegionToEnd() throws Exception {
@@ -1870,9 +2019,84 @@ public class GoToSupportTest extends NbTestCase {
         this.sourceLevel = getLatestSourceVersion();
         EXTRA_OPTIONS.add("--enable-preview");
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
-        performTest("Errors", 4906, null, "javadocsnippet_TestError_NoRegionToEnd.pass", this.sourceLevel);
+        performTest("Errors", 5715, null, "javadocsnippet_TestError_NoRegionToEnd.pass", this.sourceLevel, false);
     }
-    
+
+    public void testErrorFileEmpty() throws Exception {
+        if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
+            return;
+        }
+
+        if (!hasRecords()) {
+            return;
+        }
+        this.sourceLevel = getLatestSourceVersion();
+        EXTRA_OPTIONS.add("--enable-preview");
+        JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
+
+        performTest("Errors", 5901, null, "javadocsnippet_file_empty.pass", this.sourceLevel, true);
+    }
+
+    public void testErrorFileInvalid() throws Exception {
+        if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
+            return;
+        }
+
+        if (!hasRecords()) {
+            return;
+        }
+        this.sourceLevel = getLatestSourceVersion();
+        EXTRA_OPTIONS.add("--enable-preview");
+        JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
+
+        performTest("Errors", 6140, null, "javadocsnippet_file_invalid.pass", this.sourceLevel, true);
+    }
+
+    public void testExternalSnippetFile() throws Exception {
+        if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
+            return;
+        }
+
+        if (!hasRecords()) {
+            return;
+        }
+        this.sourceLevel = getLatestSourceVersion();
+        EXTRA_OPTIONS.add("--enable-preview");
+        JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
+
+        performTest("Errors", 6440, null, "javadocsnippet_external_file.pass", this.sourceLevel, true);
+    }
+
+    public void testErrorRegionInvalid() throws Exception {
+        if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
+            return;
+        }
+
+        if (!hasRecords()) {
+            return;
+        }
+        this.sourceLevel = getLatestSourceVersion();
+        EXTRA_OPTIONS.add("--enable-preview");
+        JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
+
+        performTest("Errors", 6608, null, "javadocsnippet_region_invalid.pass", this.sourceLevel, true);
+    }
+
+    public void testExternalRegionValid() throws Exception {
+        if (!TreeShims.isJDKVersionRelease18_Or_Above()) {
+            return;
+        }
+
+        if (!hasRecords()) {
+            return;
+        }
+        this.sourceLevel = getLatestSourceVersion();
+        EXTRA_OPTIONS.add("--enable-preview");
+        JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
+
+        performTest("Errors", 6888, null, "javadocsnippet_region_valid.pass", this.sourceLevel, true);
+    }
+
     private static final List<String> EXTRA_OPTIONS = new ArrayList<>();
     @ServiceProvider(service = CompilerOptionsQueryImplementation.class, position = 100)
     public static class TestCompilerOptionsQueryImplementation implements CompilerOptionsQueryImplementation {
@@ -1899,4 +2123,4 @@ public class GoToSupportTest extends NbTestCase {
     private static String getLatestSourceVersion() {
         return SourceVersion.latest().name().split("_")[1];
     }
-}
\ No newline at end of file
+}
diff --git a/java/java.project.ui/src/org/netbeans/modules/java/project/ui/JavaTargetChooserPanel.java b/java/java.project.ui/src/org/netbeans/modules/java/project/ui/JavaTargetChooserPanel.java
index 8606c088cb..1a164b8f01 100644
--- a/java/java.project.ui/src/org/netbeans/modules/java/project/ui/JavaTargetChooserPanel.java
+++ b/java/java.project.ui/src/org/netbeans/modules/java/project/ui/JavaTargetChooserPanel.java
@@ -353,6 +353,8 @@ public final class JavaTargetChooserPanel implements WizardDescriptor.Panel<Wiza
             String token = tukac.nextToken();
             if ("".equals(token))
                 return false;
+            if("snippet-files".equals(token) && !tukac.hasMoreTokens())
+                return true;
             if (!Utilities.isJavaIdentifier(token))
                 return false;
         }
diff --git a/java/java.project.ui/src/org/netbeans/modules/java/project/ui/resources/Class.java.template b/java/java.project.ui/src/org/netbeans/modules/java/project/ui/resources/Class.java.template
index 2cd83a4bd1..8107aa5bb0 100644
--- a/java/java.project.ui/src/org/netbeans/modules/java/project/ui/resources/Class.java.template
+++ b/java/java.project.ui/src/org/netbeans/modules/java/project/ui/resources/Class.java.template
@@ -3,7 +3,7 @@
 <#assign licenseLast = " */">
 <#include "${project.licensePath}">
 
-<#if package?? && package != "">
+<#if package?? && package != "" && !package?ends_with("snippet-files")>
 package ${package};
 
 </#if>
diff --git a/java/java.source.base/src/org/netbeans/modules/java/source/TreeShims.java b/java/java.source.base/src/org/netbeans/modules/java/source/TreeShims.java
index f4858ab86f..176d9070f1 100644
--- a/java/java.source.base/src/org/netbeans/modules/java/source/TreeShims.java
+++ b/java/java.source.base/src/org/netbeans/modules/java/source/TreeShims.java
@@ -371,7 +371,7 @@ public class TreeShims {
             Class gpt = Class.forName("com.sun.source.doctree.SnippetTree"); //NOI18N
             return isJDKVersionRelease18_Or_Above()
                     ? (List<DocTree>) gpt.getDeclaredMethod("getAttributes").invoke(node) //NOI18N
-                    : null;
+                    : Collections.emptyList();
         } catch (NoSuchMethodException | ClassNotFoundException ex) {
             return null;
         } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
@@ -431,4 +431,4 @@ public class TreeShims {
     public static <T extends Throwable> RuntimeException throwAny(Throwable t) throws T {
         throw (T) t;
     }
-}
\ No newline at end of file
+}
diff --git a/java/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java b/java/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
index 37ba99a010..7dbfd249de 100644
--- a/java/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
+++ b/java/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
@@ -425,7 +425,7 @@ public class CasualDiff {
         return td.checkDiffs(DiffUtilities.diff(originalText, resultSrc, start, 
                 td.readSections(originalText.length(), resultSrc.length(), lineStart, start), lineStart));
     }
-    
+
     private static class SectKey {
         private int off;
         SectKey(int off) { this.off = off; }
@@ -5004,7 +5004,7 @@ public class CasualDiff {
         }
         return elementBounds[1];
     }
-    
+
     private int diffStartElement(DCDocComment doc, DCStartElement oldT, DCStartElement newT, int[] elementBounds) {
         int localpointer = oldT.attrs.isEmpty()? elementBounds[1] - 1 : getOldPos(oldT.attrs.get(0), doc);
         if(oldT.name.equals(newT.name)) {
diff --git a/java/java.sourceui/src/org/netbeans/api/java/source/ui/ElementJavadoc.java b/java/java.sourceui/src/org/netbeans/api/java/source/ui/ElementJavadoc.java
index d79aba7e38..7728b743d1 100644
--- a/java/java.sourceui/src/org/netbeans/api/java/source/ui/ElementJavadoc.java
+++ b/java/java.sourceui/src/org/netbeans/api/java/source/ui/ElementJavadoc.java
@@ -1337,39 +1337,54 @@ public class ElementJavadoc {
                 + "</div>\n"); //NOI18N
         sb.append("<pre>"); //NOI18N
         sb.append("<code>"); //NOI18N
+  
 
-        ClassPath classPath = this.cpInfo.getClassPath(ClasspathInfo.PathKind.SOURCE);
-        String pckgName = docPath.getCompilationUnit().getPackageName().toString();
-        
         List<DocTree> attributes = (List<DocTree>) TreeShims.getSnippetDocTreeAttributes(tag);
         
         String fileName = null;
         String regionName = null;
         String lang = null;
-  
+        Set<String> errorList = new HashSet<>();
+        String error = "";
+
         boolean isExternalSnippet = false;
+        String text = null;
         
         for(DocTree att : attributes){
             switch (((AttributeTree)att).getName().toString()) {
                 case "file":
-                    fileName = ((AttributeTree)att).getValue().get(0).toString();
+                    if(isAttrPresent(att) && text==null) {
+                        fileName = ((AttributeTree)att).getValue().get(0).toString();
+                        text = extractContent(docPath, att, errorList, fileName);
+                    } else {
+                        error = "error: snippet markup: File invalid";
+                    }
                     isExternalSnippet = true;
                     break;
                 case "class":
-                    fileName = ((AttributeTree)att).getValue().get(0).toString() + ".java";
+                    if(isAttrPresent(att) && text==null) {
+                        fileName = ((AttributeTree)att).getValue().get(0).toString() + ".java";
+                        text = extractContent(docPath, att, errorList, fileName);
+                        lang="java";
+                    } else {
+                        error = "error: snippet markup: File invalid";
+                    }
                     isExternalSnippet = true;
-                    lang="java";
                     break;
                 case "region":
-                    regionName = ((AttributeTree)att).getValue().get(0).toString();
+                    if(isAttrPresent(att)) {
+                        regionName = ((AttributeTree)att).getValue().get(0).toString();
+                    } else {
+                        error = "error: snippet markup:region not specified";
+                    }
                     break;
                 case "lang":
                     lang = ((AttributeTree)att).getValue().get(0).toString();
                     break;
             }
+            if(!error.isEmpty())errorList.add(error);
         }
         
-        
         if(lang == null && fileName!=null){
             if(fileName.endsWith(".java")){
                 lang="java";
@@ -1378,19 +1393,16 @@ public class ElementJavadoc {
             }
         }
         
-        String text = null;
-        if (isExternalSnippet) {
-            pckgName = pckgName.replaceAll("\\.", "\\\\");
-            FileObject snippetFile = classPath.findResource(pckgName + "\\snippet-files\\" + fileName);
-            try {
-                text = snippetFile.asText();
-            } catch (IOException ex) {
-                Exceptions.printStackTrace(ex);
+        if (!isExternalSnippet) {
+            if(TreeShims.getSnippetDocTreeText(tag)!=null) {
+                text = TreeShims.getSnippetDocTreeText(tag).toString();
             }
-        } else {
-            text = TreeShims.getSnippetDocTreeText(tag).toString();
         }
-        
+
+        if(!errorList.isEmpty() && text==null) {
+            reportError(new ArrayList(errorList), sb);
+            return;
+        }
         String langCommentPattern;
         if(lang != null && lang.equals("properties")){
             langCommentPattern = "#";
@@ -1410,14 +1422,40 @@ public class ElementJavadoc {
         sb.append("</div>"); //NOI18N
     }
     
-    private void applyTags(List<SourceLineMeta> parseResult, MarkupTagProcessor.ProcessedTags tags, StringBuilder sb, String regionName) {
+    private boolean isAttrPresent(DocTree att) {
+        return !((AttributeTree)att).getValue().isEmpty() && (!((AttributeTree)att).getValue().get(0).toString().isEmpty());
+    }
+
+    private String extractContent(TreePath docPath, DocTree attr, Set<String> errorList, String fileName) {
+        String pckgName = docPath.getCompilationUnit().getPackageName().toString();
+
+        ClassPath classPath = this.cpInfo.getClassPath(ClasspathInfo.PathKind.SOURCE);
+        String error = null;
+        String text = null;
+
+        pckgName = pckgName.replaceAll("\\.", "\\\\");
+        FileObject snippetFile = classPath.findResource(pckgName + "\\snippet-files\\" + fileName);
+        if (snippetFile == null || fileName.isEmpty()) {
+            error = "error: snippet markup: File invalid";
+            errorList.add(error);
+        } else {
+            try {
+                text = snippetFile.asText();
+            } catch (IOException ex) {
+                Exceptions.printStackTrace(ex);
+            }
+        }
+        return text;
+    }
 
+    private void applyTags(List<SourceLineMeta> parseResult, MarkupTagProcessor.ProcessedTags tags, StringBuilder sb, String regionName) {
         if(!tags.getErrorList().isEmpty()){
             reportError(tags.getErrorList(), sb);
             return;
         }
 
         int lineCounter = 0;
+        List<List<MarkupTagProcessor.Region>> regionList = new ArrayList<>();
         for (SourceLineMeta fullLineInfo : parseResult) {
             lineCounter++;
 
@@ -1435,6 +1473,7 @@ public class ElementJavadoc {
             boolean toAddCurrent = true;
             if (regionName != null && regions != null) {
                 toAddCurrent = regions.stream().anyMatch(p -> p.getValue().equals(regionName));
+                regionList.add(regions);
             } else if (regionName != null) {
                 toAddCurrent = false;
             }
@@ -1442,7 +1481,7 @@ public class ElementJavadoc {
                 if (attributes != null) {
                     for (MarkupTagProcessor.ApplicableMarkupTag attrib : attributes) {
                         codeLine = applyTagsToHTML(codeLine, attrib.getAttributes(), attrib.getMarkupTagName(), sb, eachCharList);
-                        if (codeLine == null) {//its error
+                        if(codeLine == null){//its error
                             return;
                         }
                     }
@@ -1461,6 +1500,16 @@ public class ElementJavadoc {
                 sb.append("\n");
             }
         }
+        if(regionName!=null && !regionList.isEmpty()) {
+            boolean noneMatch = regionList.stream().flatMap(List::stream)
+                    .noneMatch(p -> p.getValue().equals(regionName));
+            if(noneMatch) {
+                List<String> errorList = new ArrayList<>();
+                String error = "error: snippet markup: Region not found";
+                errorList.add(error);
+                reportError(errorList, sb);
+            }
+        }
     }
 
      private String applyTagsToHTML(String codeLine, Map<String, String> tagAttributes, String markupTagName, StringBuilder sb, List<SourceLineCharterMapperToHtmlTag> eachCharList) {
@@ -1521,6 +1570,7 @@ public class ElementJavadoc {
         }
         return true;
     }
+
     private void reportError(List<String> errorList, StringBuilder sb){
         errorList.iterator().forEachRemaining(error -> sb.append("<span style=\"color:red;\">"+error +"</span>").append("\n"));
     }
@@ -1588,7 +1638,7 @@ public class ElementJavadoc {
                     }
                     formattedLine.replace(fromIndex, fromIndex + tagActionValue.length(), replacement);
                     
-                        fromIndex += replacement.length();
+                    fromIndex += replacement.length();
                     codeLine = formattedLine.toString();
                 }
             }
diff --git a/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/HtmlStartEndTag.java b/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/HtmlStartEndTag.java
index bd20cf4b43..d24ec06651 100644
--- a/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/HtmlStartEndTag.java
+++ b/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/HtmlStartEndTag.java
@@ -16,7 +16,6 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.netbeans.api.java.source.ui.snippet;
 
 /**
diff --git a/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/MarkupTag.java b/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/MarkupTag.java
index d33af89a57..20200bfff8 100644
--- a/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/MarkupTag.java
+++ b/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/MarkupTag.java
@@ -16,7 +16,6 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.netbeans.api.java.source.ui.snippet;
 
 import java.util.List;
@@ -75,5 +74,4 @@ public class MarkupTag {
         }
         return Objects.equals(this.markUpTagAttributes, other.markUpTagAttributes);
     }
-
 }
diff --git a/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/MarkupTagAttribute.java b/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/MarkupTagAttribute.java
index 71966c88d7..f35c5e82a5 100644
--- a/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/MarkupTagAttribute.java
+++ b/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/MarkupTagAttribute.java
@@ -16,7 +16,6 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.netbeans.api.java.source.ui.snippet;
 
 import java.util.Objects;
diff --git a/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/MarkupTagProcessor.java b/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/MarkupTagProcessor.java
index 2efe5a10c7..2f505935c7 100644
--- a/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/MarkupTagProcessor.java
+++ b/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/MarkupTagProcessor.java
@@ -16,7 +16,6 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.netbeans.api.java.source.ui.snippet;
 
 import java.util.ArrayList;
diff --git a/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/SnippetMarkupTagExtractor.java b/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/SnippetMarkupTagExtractor.java
index ea4d7dc7fa..137c344127 100644
--- a/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/SnippetMarkupTagExtractor.java
+++ b/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/SnippetMarkupTagExtractor.java
@@ -16,7 +16,6 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.netbeans.api.java.source.ui.snippet;
 
 import java.util.ArrayList;
diff --git a/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/SnippetTagCommentParser.java b/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/SnippetTagCommentParser.java
index 905fb0e4f8..1e05ac2b54 100644
--- a/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/SnippetTagCommentParser.java
+++ b/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/SnippetTagCommentParser.java
@@ -16,7 +16,6 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.netbeans.api.java.source.ui.snippet;
 
 
diff --git a/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/SourceLineMeta.java b/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/SourceLineMeta.java
index cdc41806ca..71de27fcc8 100644
--- a/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/SourceLineMeta.java
+++ b/java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/SourceLineMeta.java
@@ -16,7 +16,6 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.netbeans.api.java.source.ui.snippet;
 
 
diff --git a/java/java.sourceui/test/unit/src/org/netbeans/api/java/source/ui/snippet/MarkupTagProcessorTest.java b/java/java.sourceui/test/unit/src/org/netbeans/api/java/source/ui/snippet/MarkupTagProcessorTest.java
new file mode 100644
index 0000000000..85259d885f
--- /dev/null
+++ b/java/java.sourceui/test/unit/src/org/netbeans/api/java/source/ui/snippet/MarkupTagProcessorTest.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.api.java.source.ui.snippet;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import junit.framework.TestCase;
+import org.netbeans.api.java.source.ui.snippet.MarkupTagProcessor.ApplicableMarkupTag;
+import org.netbeans.api.java.source.ui.snippet.MarkupTagProcessor.Region;
+
+/**
+ *
+ * @author mjayan
+ */
+public class MarkupTagProcessorTest extends TestCase {
+    public MarkupTagProcessorTest(String testName) {
+        super(testName);
+    }
+    
+    public void testNoMarkupTag() {
+        String testData = "class HelloWorld {}// This is test class";
+        String langCommentPattern = "\\Q//\\E";
+        List<SourceLineMeta> parseResult = new SnippetTagCommentParser(langCommentPattern).parse(testData);
+        MarkupTagProcessor.ProcessedTags tags = new MarkupTagProcessor().process(parseResult);
+        assertEquals(Collections.emptyList(),tags.getErrorList());
+        assertEquals(Collections.emptyMap(),tags.getMarkUpTagLineMapper());
+        assertEquals(Collections.emptyMap(),tags.getRegionTagLineMapper());
+    }
+    
+    public void testMarkupTag() {
+        String testData = "        System.out.println(\"Hello println\"); //@highlight substring  =  \"println\"    type=\"italic\" ";
+        String langCommentPattern = "\\Q//\\E";
+        List<SourceLineMeta> parseResult = new SnippetTagCommentParser(langCommentPattern).parse(testData);
+        
+        MarkupTagProcessor tagProcessor = new MarkupTagProcessor();
+        MarkupTagProcessor.ProcessedTags tags = tagProcessor.process(parseResult);
+        
+        List<ApplicableMarkupTag> actual = tags.getMarkUpTagLineMapper().get(1);
+        
+        List<ApplicableMarkupTag> expected = new ArrayList<>();
+        Map<String, String> attributes = new HashMap<>();
+        attributes.put("substring", "println");
+        attributes.put("type", "italic");
+        MarkupTagProcessor.ApplicableMarkupTag ap = new MarkupTagProcessor().new ApplicableMarkupTag(attributes, "highlight");
+        expected.add(ap);
+        assertEquals(actual, expected);
+    }
+    
+    public void testMultipleMarkupTag() {
+        String langCommentPattern = "\\Q//\\E";
+        String testData = "System.out.println(\"Hello println\");"
+                + "//@highlight substring=\"println\" "
+                + "@link substring=\"System.out\" target=\"java.lang.System#out\""
+                + "@replace regex=\\bHello\\b replacement=\"Hi\"";
+        List<SourceLineMeta> parseResult = new SnippetTagCommentParser(langCommentPattern).parse(testData);
+        MarkupTagProcessor tagProcessor = new MarkupTagProcessor();
+        MarkupTagProcessor.ProcessedTags tags = tagProcessor.process(parseResult);
+        List<ApplicableMarkupTag> actual = tags.getMarkUpTagLineMapper().get(1);
+        
+        Map<String, String> attributes1 = new HashMap<>();
+        attributes1.put("substring", "println");
+        MarkupTagProcessor.ApplicableMarkupTag highlightTag = new MarkupTagProcessor().new ApplicableMarkupTag(attributes1, "highlight");
+        
+        Map<String, String> attributes2 = new HashMap<>();
+        attributes2.put("substring", "System.out");
+        attributes2.put("target", "java.lang.System#out");
+        MarkupTagProcessor.ApplicableMarkupTag linkTag = new MarkupTagProcessor().new ApplicableMarkupTag(attributes2, "link");
+        
+        Map<String, String> attributes3 = new HashMap<>();
+        attributes3.put("regex", "\\bHello\\b");
+        attributes3.put("replacement", "Hi");
+        MarkupTagProcessor.ApplicableMarkupTag replaceTag = new MarkupTagProcessor().new ApplicableMarkupTag(attributes3, "replace");
+        
+        List<ApplicableMarkupTag> expected = new ArrayList<>();
+        expected.add(highlightTag);
+        expected.add(linkTag);
+        expected.add(replaceTag);
+        
+        assertEquals(actual, expected);
+    }
+    
+    public void testMarkupTagRegion(){
+        String testData = "System.out.println(\"Hello println\");"
+                + "// @highlight region substring=\"println\" \n"
+                + "System.out.println(\"Hi println\");\n"
+                + "System.out.println(\"How are you println\");\\@end";
+        String langCommentPattern = "\\Q//\\E";
+        
+        List<SourceLineMeta> parseResult = new SnippetTagCommentParser(langCommentPattern).parse(testData);
+        MarkupTagProcessor tagProcessor = new MarkupTagProcessor();
+        MarkupTagProcessor.ProcessedTags tags = tagProcessor.process(parseResult);
+        
+        Map<Integer, List<MarkupTagProcessor.Region>> actual = tags.getRegionTagLineMapper();
+        
+        Map<Integer, List<MarkupTagProcessor.Region>> expected = new HashMap<>();
+        Map<String, String> attributes = new HashMap<>();
+        attributes.put("substring", "println");
+        List<MarkupTagProcessor.Region> line1 = new ArrayList<>();
+        MarkupTagProcessor.Region region = new MarkupTagProcessor().new Region("anonymous",attributes, "highlight");
+        line1.add(region);
+        expected.put(1,line1);
+        expected.put(2,line1);
+        expected.put(3,line1);
+        assertEquals(actual, expected);
+    }
+    
+    public void testMarkupTagAppliesToNextLine(){
+
+        String testData = "System.out.println(\"Hello println\");"
+                + "// @highlight substring=\"println\" :"
+                + "@link substring=\"System.out\" target = \"java.lang.System#out\"\n"
+                + "System.out.println(\"Hi println\");";
+        String langCommentPattern = "\\Q//\\E";
+        List<SourceLineMeta> parseResult = new SnippetTagCommentParser(langCommentPattern).parse(testData);
+        
+        MarkupTagProcessor.ProcessedTags tags = new MarkupTagProcessor().process(parseResult);
+        Map<Integer,List<ApplicableMarkupTag>> actual = tags.getMarkUpTagLineMapper();
+        
+        Map<String, String> attributes1 = new HashMap<>();
+        attributes1.put("substring", "System.out");
+        attributes1.put("target", "java.lang.System#out");
+        MarkupTagProcessor.ApplicableMarkupTag linkTag = new MarkupTagProcessor().new ApplicableMarkupTag(attributes1, "link");
+        
+        Map<String, String> attributes2 = new HashMap<>();
+        attributes2.put("substring", "println");
+        MarkupTagProcessor.ApplicableMarkupTag highlightTag = new MarkupTagProcessor().new ApplicableMarkupTag(attributes2, "highlight");
+        
+        List<ApplicableMarkupTag> list1 = new ArrayList<>();
+        list1.add(linkTag);
+        List<ApplicableMarkupTag> list2 = new ArrayList<>();
+        list2.add(highlightTag);
+        
+        Map<Integer,List<ApplicableMarkupTag>> expected = new HashMap<>();
+        expected.put(1,list1);
+        expected.put(2,list2);
+        assertEquals(actual,expected);
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists