lahodaj commented on a change in pull request #3266:
URL: https://github.com/apache/netbeans/pull/3266#discussion_r821504069
##########
File path:
java/java.editor/src/org/netbeans/modules/java/editor/javadoc/TagRegistery.java
##########
@@ -100,6 +100,7 @@ private TagRegistery() {
addTag("@uses", false, EnumSet.of(ElementKind.MODULE));
addTag("@code", true, ALL_KINDS);
+ addTag("@snippet", true, ALL_KINDS);
Review comment:
Nit: formatting odd?
##########
File path:
java/java.hints/src/org/netbeans/modules/java/hints/jdk/JavaDocSnippet.java
##########
@@ -0,0 +1,254 @@
+/*
+ * 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.modules.java.hints.jdk;
+
+import com.sun.source.tree.BlockTree;
+import com.sun.source.tree.CaseTree;
+import com.sun.source.tree.ExpressionStatementTree;
+import com.sun.source.tree.IdentifierTree;
+import com.sun.source.tree.IfTree;
+import com.sun.source.tree.InstanceOfTree;
+import com.sun.source.tree.ParenthesizedTree;
+import com.sun.source.tree.StatementTree;
+import com.sun.source.tree.SwitchTree;
+import com.sun.source.tree.ThrowTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.util.TreePath;
+import com.sun.tools.javac.tree.JCTree;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.Name;
+import javax.lang.model.type.TypeMirror;
+import org.netbeans.api.java.source.CompilationInfo;
+import org.netbeans.api.java.source.TreeMaker;
+import org.netbeans.api.java.source.WorkingCopy;
+import org.netbeans.modules.java.source.TreeShims;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.JavaFix;
+import org.netbeans.spi.java.hints.MatcherUtilities;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.netbeans.spi.java.hints.TriggerTreeKind;
+import org.openide.util.Exceptions;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author aksinsin
+ */
[email protected]({
+ "DN_SnippetError=SnippetError",
+ "DESC_SnippetError=SnippetError",
+ "ERR_SnippetError=SnippetError",
+ "FIX_SnippetError=SnippetError"
+})
+@Hint(displayName = "#DN_SnippetError", description = "#DESC_SnippetError",
category = "rules15",
+ minSourceVersion = "17")
+public class JavaDocSnippet {
+
+ @TriggerPatterns({
+ @TriggerPattern(value = "@snippet"),
Review comment:
Do these triggers really work? I'd expect that something like
`@TriggerTreeKind(COMPILATION_UNIT)` would be needed.
##########
File path:
java/java.hints/src/org/netbeans/modules/java/hints/jdk/SnippetDoc.java
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.modules.java.hints.jdk;
+
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.java.hints.ConstraintVariableType;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.openide.util.NbBundle.Messages;
+
+@Hint(displayName = "#DN_SnippetDoc", description = "#DESC_SnippetDoc",
category = "general")
+@Messages({
+ "DN_SnippetDoc=snippet",
+ "DESC_SnippetDoc=snippet"
+})
+public class SnippetDoc {
Review comment:
This class is also a bit suspicious, as is the adjacent test.
##########
File path:
java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/MarkupTag.java
##########
@@ -0,0 +1,28 @@
+package org.netbeans.api.java.source.ui.snippet;
Review comment:
Note that there are no license headers - this can't pass through Apache
RAT. Similarly many other files which are missing the headers (some test files
are excluded - please run RAT and check: `ant rat`).
##########
File path:
java/java.source.base/src/org/netbeans/modules/java/source/TreeShims.java
##########
@@ -364,6 +366,31 @@
// }
// return null;
// }
+ public static List<DocTree> getSnippetDocTreeAttributes(DocTree node) {
+ try {
+ Class gpt = Class.forName("com.sun.source.doctree.SnippetTree");
//NOI18N
+ return isJDKVersionRelease18_Or_Above()
+ ? (List<DocTree>)
gpt.getDeclaredMethod("getAttributes").invoke(node) //NOI18N
+ : null;
Review comment:
+1. I also hope we'll be able to get rid of this test sometime soon
(when we move the baseline to JDK 18).
##########
File path:
java/java.sourceui/src/org/netbeans/api/java/source/ui/snippet/MarkupTagProcessor.java
##########
@@ -0,0 +1,232 @@
+/*
Review comment:
Even though there are tests for the `GoToSupport`, it would be nice to
have a set of tests verifying the behavior of the parser/processor/extractor
and ElementJavadoc inside java.sourceui, where it is processed.
##########
File path:
java/java.hints/src/org/netbeans/modules/java/hints/jdk/JavaDocSnippet.java
##########
@@ -0,0 +1,254 @@
+/*
+ * 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.modules.java.hints.jdk;
+
+import com.sun.source.tree.BlockTree;
+import com.sun.source.tree.CaseTree;
+import com.sun.source.tree.ExpressionStatementTree;
+import com.sun.source.tree.IdentifierTree;
+import com.sun.source.tree.IfTree;
+import com.sun.source.tree.InstanceOfTree;
+import com.sun.source.tree.ParenthesizedTree;
+import com.sun.source.tree.StatementTree;
+import com.sun.source.tree.SwitchTree;
+import com.sun.source.tree.ThrowTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.util.TreePath;
+import com.sun.tools.javac.tree.JCTree;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.Name;
+import javax.lang.model.type.TypeMirror;
+import org.netbeans.api.java.source.CompilationInfo;
+import org.netbeans.api.java.source.TreeMaker;
+import org.netbeans.api.java.source.WorkingCopy;
+import org.netbeans.modules.java.source.TreeShims;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.JavaFix;
+import org.netbeans.spi.java.hints.MatcherUtilities;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.netbeans.spi.java.hints.TriggerTreeKind;
+import org.openide.util.Exceptions;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author aksinsin
+ */
[email protected]({
+ "DN_SnippetError=SnippetError",
+ "DESC_SnippetError=SnippetError",
+ "ERR_SnippetError=SnippetError",
+ "FIX_SnippetError=SnippetError"
+})
+@Hint(displayName = "#DN_SnippetError", description = "#DESC_SnippetError",
category = "rules15",
+ minSourceVersion = "17")
+public class JavaDocSnippet {
Review comment:
It would be good to have a test for this. Overall, this class seems
somewhat suspicious, so any more information on what it strives to do would be
welcome!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists