You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by ma...@apache.org on 2020/02/26 20:29:03 UTC

[netbeans] branch master updated: [NETBEANS-2314] Truncated param descriptions should not yield exceptions

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

matthiasblaesing 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 3be55f4  [NETBEANS-2314] Truncated param descriptions should not yield exceptions
     new 60d3983  Merge pull request #1973 from matthiasblaesing/netbeans-2314-jsdoc
3be55f4 is described below

commit 3be55f44fb3ceba0273b2ec20b8a190fc8e854af
Author: Matthias Bläsing <mb...@doppel-helix.eu>
AuthorDate: Mon Feb 24 21:09:03 2020 +0100

    [NETBEANS-2314] Truncated param descriptions should not yield exceptions
---
 .../javascript2/jsdoc/model/JsDocElementUtils.java |  4 +--
 .../jsdoc/model/JsDocElementUtilsTest.java         | 38 ++++++++++++++++++++++
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/webcommon/javascript2.jsdoc/src/org/netbeans/modules/javascript2/jsdoc/model/JsDocElementUtils.java b/webcommon/javascript2.jsdoc/src/org/netbeans/modules/javascript2/jsdoc/model/JsDocElementUtils.java
index 303b48d..5b094d8 100644
--- a/webcommon/javascript2.jsdoc/src/org/netbeans/modules/javascript2/jsdoc/model/JsDocElementUtils.java
+++ b/webcommon/javascript2.jsdoc/src/org/netbeans/modules/javascript2/jsdoc/model/JsDocElementUtils.java
@@ -183,10 +183,10 @@ public class JsDocElementUtils {
 
             //if type at index=0, extract name and desc from the remaining text
             if ((curlyStart == 0) && (curlyEnd != -1)) {
-                parts = elementText.substring(curlyEnd + 1).trim().split("[\\s]+");
+                parts = elementText.substring(Math.min(curlyEnd + 1, elementText.length())).trim().split("[\\s]+");
             } else if (curlyStart > 0) {
                 //use entire text minus the types part to get name and desc 
-                String typesStr = elementText.substring(curlyStart, curlyEnd + 1);
+                String typesStr = elementText.substring(curlyStart, Math.min(curlyEnd + 1, elementText.length()));
                 StringBuilder buf = new StringBuilder(elementText);
                 elementText = buf.replace(curlyStart, curlyStart + typesStr.length(), "").toString();
                 parts = elementText.split("[\\s]+");
diff --git a/webcommon/javascript2.jsdoc/test/unit/src/org/netbeans/modules/javascript2/jsdoc/model/JsDocElementUtilsTest.java b/webcommon/javascript2.jsdoc/test/unit/src/org/netbeans/modules/javascript2/jsdoc/model/JsDocElementUtilsTest.java
new file mode 100644
index 0000000..f123bd9
--- /dev/null
+++ b/webcommon/javascript2.jsdoc/test/unit/src/org/netbeans/modules/javascript2/jsdoc/model/JsDocElementUtilsTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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.javascript2.jsdoc.model;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author matthias
+ */
+public class JsDocElementUtilsTest {
+
+    public JsDocElementUtilsTest() {
+    }
+
+    @Test
+    public void testTruncatedParam() {
+        JsDocElementUtils.createElementForType(JsDocElementType.PARAM, "Demo with {", 0);
+    }
+
+}


---------------------------------------------------------------------
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