You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2020/12/29 20:02:41 UTC

[GitHub] [netbeans] matthiasblaesing opened a new pull request #2616: [NETBEANS-4739] CSS Go to Declaration , does not work

matthiasblaesing opened a new pull request #2616:
URL: https://github.com/apache/netbeans/pull/2616


   When the index storage of CSS grammar elements was modified to store values individually (74a5e17), not all use-sites were updated. This PR fixes this and adds unit tests for the CSS index functions.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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

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


[GitHub] [netbeans] matthiasblaesing merged pull request #2616: [NETBEANS-4739] CSS Go to Declaration , does not work

Posted by GitBox <gi...@apache.org>.
matthiasblaesing merged pull request #2616:
URL: https://github.com/apache/netbeans/pull/2616


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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

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


[GitHub] [netbeans] junichi11 edited a comment on pull request #2616: [NETBEANS-4739] CSS Go to Declaration , does not work

Posted by GitBox <gi...@apache.org>.
junichi11 edited a comment on pull request #2616:
URL: https://github.com/apache/netbeans/pull/2616#issuecomment-752340019


   I've added unit tests for GotoDeclaration. Please feel free to use  them if needed :)
   Only a few simple cases. 
   <details>
   <summary>unit test patch</summary>
   
   ```patch
   diff --git a/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/nbproject/project.properties b/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/nbproject/project.properties
   new file mode 100644
   index 0000000000..765047da38
   --- /dev/null
   +++ b/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/nbproject/project.properties
   @@ -0,0 +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.
   +
   +config.folder=${file.reference.HTML5Application-config}
   +file.reference.HTML5Application-config=config
   +file.reference.HTML5Application-public_html=public_html
   +file.reference.HTML5Application-test=test
   +files.encoding=UTF-8
   +site.root.folder=${file.reference.HTML5Application-public_html}
   +test.folder=${file.reference.HTML5Application-test}
   diff --git a/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/nbproject/project.xml b/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/nbproject/project.xml
   new file mode 100644
   index 0000000000..ea0901bce4
   --- /dev/null
   +++ b/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/nbproject/project.xml
   @@ -0,0 +1,29 @@
   +<?xml version="1.0" encoding="UTF-8"?>
   +<!--
   +
   +    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.
   +
   +-->
   +<project xmlns="http://www.netbeans.org/ns/project/1">
   +    <type>org.netbeans.modules.web.clientproject</type>
   +    <configuration>
   +        <data xmlns="http://www.netbeans.org/ns/clientside-project/1">
   +            <name>CSS Editor Test Project</name>
   +        </data>
   +    </configuration>
   +</project>
   diff --git a/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/public_html/test.html b/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/public_html/test.html
   new file mode 100644
   index 0000000000..4c5da0816f
   --- /dev/null
   +++ b/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/public_html/test.html
   @@ -0,0 +1,34 @@
   +<!DOCTYPE html>
   +<!--
   +
   +    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>
   +    <head>
   +        <meta charset="UTF-8">
   +        <title>GotoDeclaration Test</title>
   +        <link rel="stylesheet" type="text/css" href="test1.css">
   +        <link rel="stylesheet" type="text/css" href="test2.css">
   +    </head>
   +    <body>
   +        <p class="classSelector1">test class</p>
   +        <p class="classSelector3">test class</p>
   +        <p id="yetAnotherId">test id</p>
   +    </body>
   +</html>
   diff --git a/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/public_html/test1.css b/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/public_html/test1.css
   new file mode 100644
   index 0000000000..e38a5f14f8
   --- /dev/null
   +++ b/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/public_html/test1.css
   @@ -0,0 +1,34 @@
   +/*
   +    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.
   +*/
   +
   +.classSelector1 {
   +
   +}
   +
   +.classSelector2 {
   +
   +}
   +
   +#dummyId {
   +
   +}
   +
   +#anotherId {
   +
   +}
   \ No newline at end of file
   diff --git a/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/public_html/test2.css b/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/public_html/test2.css
   new file mode 100644
   index 0000000000..6071c4ce60
   --- /dev/null
   +++ b/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/public_html/test2.css
   @@ -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.
   +*/
   +
   +.classSelector3 {
   +
   +}
   +
   +#dummyId2 {
   +
   +}
   +
   +#dummyId3 {
   +    color: #F1F1F1;
   +}
   +
   +.anotherClassSelector {
   +
   +}
   +
   +h1 {
   +
   +}
   +
   +#yetAnotherId {
   +
   +}
   \ No newline at end of file
   diff --git a/ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/csl/CssGotoDeclarationTest.java b/ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/csl/CssGotoDeclarationTest.java
   new file mode 100644
   index 0000000000..70c695a8df
   --- /dev/null
   +++ b/ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/csl/CssGotoDeclarationTest.java
   @@ -0,0 +1,46 @@
   +/*
   + * 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.css.editor.csl;
   +
   +import org.netbeans.modules.csl.spi.DefaultLanguageConfig;
   +import org.netbeans.modules.html.editor.gsf.HtmlLanguage;
   +
   +public class CssGotoDeclarationTest extends CssGotoDeclarationTestBase {
   +
   +    public CssGotoDeclarationTest(String testName) {
   +        super(testName, "simple");
   +    }
   +
   +    @Override
   +    protected DefaultLanguageConfig getPreferredLanguage() {
   +        return new HtmlLanguage();
   +    }
   +
   +    public void testClass_01() throws Exception {
   +        checkDeclaration(getSourcesFolderName() + "/test.html", "<p class=\"classSelec^tor1\">test class</p>", ".^classSelector1 {");
   +    }
   +
   +    public void testClass_02() throws Exception {
   +        checkDeclaration(getSourcesFolderName() + "/test.html", "<p class=\"classSelec^tor3\">test class</p>", ".^classSelector3 {");
   +    }
   +
   +    public void testId_01() throws Exception {
   +        checkDeclaration(getSourcesFolderName() + "/test.html", "<p id=\"yetAnoth^erId\">test id</p>", "#^yetAnotherId {");
   +    }
   +}
   diff --git a/ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/csl/CssGotoDeclarationTestBase.java b/ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/csl/CssGotoDeclarationTestBase.java
   new file mode 100644
   index 0000000000..f2f631846d
   --- /dev/null
   +++ b/ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/csl/CssGotoDeclarationTestBase.java
   @@ -0,0 +1,49 @@
   +/*
   + * 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.css.editor.csl;
   +
   +import java.util.Collections;
   +import java.util.Map;
   +import org.netbeans.api.java.classpath.ClassPath;
   +import org.netbeans.modules.css.editor.ProjectTestBase;
   +import org.netbeans.spi.java.classpath.support.ClassPathSupport;
   +import org.openide.filesystems.FileObject;
   +
   +public class CssGotoDeclarationTestBase extends ProjectTestBase {
   +
   +    protected static final String BASE_TEST_FOLDER_PATH = "testfiles/gotodeclaration/";
   +
   +    public CssGotoDeclarationTestBase(String testName, String projectName) {
   +        super(testName, BASE_TEST_FOLDER_PATH + projectName);
   +    }
   +
   +    @Override
   +    protected Map<String, ClassPath> createClassPathsForTest() {
   +        FileObject[] srcFolders = createSourceClassPathsForTest();
   +        return srcFolders != null ? Collections.singletonMap(
   +                ClassPath.SOURCE,
   +                ClassPathSupport.createClassPath(srcFolders)
   +        ) : null;
   +    }
   +
   +    protected FileObject[] createSourceClassPathsForTest() {
   +        return new FileObject[]{getTestFile(getSourcesFolderName())};
   +    }
   +
   +}
   ```
   </details>


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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

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


[GitHub] [netbeans] matthiasblaesing commented on pull request #2616: [NETBEANS-4739] CSS Go to Declaration , does not work

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on pull request #2616:
URL: https://github.com/apache/netbeans/pull/2616#issuecomment-752705028


   Thank you @junichi11 - merging with the comment removed.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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

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


[GitHub] [netbeans] matthiasblaesing commented on pull request #2616: [NETBEANS-4739] CSS Go to Declaration , does not work

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on pull request #2616:
URL: https://github.com/apache/netbeans/pull/2616#issuecomment-752223962


   @junichi11 it would be great if you could have a look at this.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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

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


[GitHub] [netbeans] matthiasblaesing commented on pull request #2616: [NETBEANS-4739] CSS Go to Declaration , does not work

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on pull request #2616:
URL: https://github.com/apache/netbeans/pull/2616#issuecomment-752468753


   @junichi11 thank you - I updated the PR with your comments and also incorporated your test in a slightly modified version. Please have another look.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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

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


[GitHub] [netbeans] junichi11 commented on a change in pull request #2616: [NETBEANS-4739] CSS Go to Declaration , does not work

Posted by GitBox <gi...@apache.org>.
junichi11 commented on a change in pull request #2616:
URL: https://github.com/apache/netbeans/pull/2616#discussion_r549943176



##########
File path: ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/ProjectTestBase.java
##########
@@ -0,0 +1,381 @@
+/*
+ * 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.css.editor;
+
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.swing.Icon;
+import javax.swing.event.ChangeListener;
+import org.netbeans.api.java.classpath.ClassPath;
+import org.netbeans.api.java.classpath.GlobalPathRegistry;
+import org.netbeans.api.project.Project;
+import org.netbeans.api.project.SourceGroup;
+import org.netbeans.api.project.Sources;
+import org.netbeans.junit.MockServices;
+import org.netbeans.lib.lexer.test.TestLanguageProvider;
+import org.netbeans.modules.css.lib.CssTestBase;
+import org.netbeans.modules.parsing.api.indexing.IndexingManager;
+import org.netbeans.modules.parsing.spi.indexing.PathRecognizer;
+import org.netbeans.modules.projectapi.SimpleFileOwnerQueryImplementation;
+import org.netbeans.spi.java.classpath.ClassPathProvider;
+import org.netbeans.spi.java.classpath.support.ClassPathSupport;
+import org.netbeans.spi.project.ProjectFactory;
+import org.netbeans.spi.project.ProjectState;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.Lookup;
+import org.openide.util.Utilities;
+import org.openide.util.lookup.AbstractLookup;
+import org.openide.util.lookup.InstanceContent;
+import org.openide.util.lookup.ServiceProvider;
+import org.openide.util.test.MockLookup;
+
+/**
+ * Base class for all tests which needs a working static html project.
+ *
+ * Copied from org.netbeans.modules.css.prep.editor.ProjectTestBase
+ *
+ * @author marekfukala
+ */
+public class ProjectTestBase extends CssTestBase {
+
+    private String projectFolder;
+    
+    private FileObject srcFo, projectFo;
+//    private FileObject javaLibSrc, javaLibProjectFo;
+
+    public ProjectTestBase(String name, String projectFolder) {
+        super(name);
+        this.projectFolder = projectFolder;
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        assertNotNull("the netbeans.dirs property must be specified!", System.getProperty("netbeans.dirs"));
+
+        this.projectFo = getTestFile(projectFolder);
+        assertNotNull(projectFo);
+        this.srcFo = getTestFile(getSourcesFolderName());
+        assertNotNull(srcFo);
+
+        Map<FileObject, ProjectInfo> projects = new HashMap<>();
+
+        //create classpath for web project
+        Map<String, ClassPath> cps = new HashMap<>();
+
+        ClassPath sourceClassPath = ClassPathSupport.createClassPath(new FileObject[]{srcFo});
+        
+        cps.put(ClassPath.SOURCE, sourceClassPath);
+        cps.put(ClassPath.COMPILE, ClassPathSupport.createClassPath(new FileObject[]{srcFo}));
+        cps.put(ClassPath.BOOT, createBootClassPath());
+        ClassPathProvider classpathProvider = new TestMultiClassPathProvider(projectFo, cps);
+        Sources sources = new TestSources(srcFo);
+
+        projects.put(projectFo, new ProjectInfo(classpathProvider, sources));
+
+        MockLookup.setInstances(
+                new TestMultiProjectFactory(projects),
+                new SimpleFileOwnerQueryImplementation(),
+                classpathProvider,
+                new TestLanguageProvider());
+
+        //provides the ClassPath.SOURCE as source path id so it is returned by
+        //PathRecognizerRegistry.getDefault().getSourceIds()
+        MockServices.setServices(TestPathRecognizer.class);
+
+        //register the source classpath so PathRegistry.getDefault().getRootsMarkedAs(classpathId) in QuerySupport works
+        GlobalPathRegistry.getDefault().register(ClassPath.SOURCE, new ClassPath[]{sourceClassPath});
+        
+        IndexingManager.getDefault().refreshIndexAndWait(srcFo.toURL(), null);
+    }
+    
+    protected String getTestProjectFolderName() {
+        return projectFolder;
+    }
+    
+    protected String getSourcesFolderName() {
+        return projectFolder + "/public_html";
+    }
+    
+    @ServiceProvider(service = PathRecognizer.class)
+    public static class TestPathRecognizer extends  PathRecognizer {

Review comment:
       Nitpick: Let's format the whole file.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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

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


[GitHub] [netbeans] junichi11 commented on pull request #2616: [NETBEANS-4739] CSS Go to Declaration , does not work

Posted by GitBox <gi...@apache.org>.
junichi11 commented on pull request #2616:
URL: https://github.com/apache/netbeans/pull/2616#issuecomment-752340019


   I've added unit tests for GotoDeclaration. Please feel free to use  them if needed :)
   <details>
   <summary>unit test patch</summary>
   
   ```patch
   diff --git a/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/nbproject/project.properties b/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/nbproject/project.properties
   new file mode 100644
   index 0000000000..765047da38
   --- /dev/null
   +++ b/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/nbproject/project.properties
   @@ -0,0 +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.
   +
   +config.folder=${file.reference.HTML5Application-config}
   +file.reference.HTML5Application-config=config
   +file.reference.HTML5Application-public_html=public_html
   +file.reference.HTML5Application-test=test
   +files.encoding=UTF-8
   +site.root.folder=${file.reference.HTML5Application-public_html}
   +test.folder=${file.reference.HTML5Application-test}
   diff --git a/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/nbproject/project.xml b/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/nbproject/project.xml
   new file mode 100644
   index 0000000000..ea0901bce4
   --- /dev/null
   +++ b/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/nbproject/project.xml
   @@ -0,0 +1,29 @@
   +<?xml version="1.0" encoding="UTF-8"?>
   +<!--
   +
   +    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.
   +
   +-->
   +<project xmlns="http://www.netbeans.org/ns/project/1">
   +    <type>org.netbeans.modules.web.clientproject</type>
   +    <configuration>
   +        <data xmlns="http://www.netbeans.org/ns/clientside-project/1">
   +            <name>CSS Editor Test Project</name>
   +        </data>
   +    </configuration>
   +</project>
   diff --git a/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/public_html/test.html b/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/public_html/test.html
   new file mode 100644
   index 0000000000..4c5da0816f
   --- /dev/null
   +++ b/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/public_html/test.html
   @@ -0,0 +1,34 @@
   +<!DOCTYPE html>
   +<!--
   +
   +    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>
   +    <head>
   +        <meta charset="UTF-8">
   +        <title>GotoDeclaration Test</title>
   +        <link rel="stylesheet" type="text/css" href="test1.css">
   +        <link rel="stylesheet" type="text/css" href="test2.css">
   +    </head>
   +    <body>
   +        <p class="classSelector1">test class</p>
   +        <p class="classSelector3">test class</p>
   +        <p id="yetAnotherId">test id</p>
   +    </body>
   +</html>
   diff --git a/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/public_html/test1.css b/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/public_html/test1.css
   new file mode 100644
   index 0000000000..e38a5f14f8
   --- /dev/null
   +++ b/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/public_html/test1.css
   @@ -0,0 +1,34 @@
   +/*
   +    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.
   +*/
   +
   +.classSelector1 {
   +
   +}
   +
   +.classSelector2 {
   +
   +}
   +
   +#dummyId {
   +
   +}
   +
   +#anotherId {
   +
   +}
   \ No newline at end of file
   diff --git a/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/public_html/test2.css b/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/public_html/test2.css
   new file mode 100644
   index 0000000000..6071c4ce60
   --- /dev/null
   +++ b/ide/css.editor/test/unit/data/testfiles/gotodeclaration/simple/public_html/test2.css
   @@ -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.
   +*/
   +
   +.classSelector3 {
   +
   +}
   +
   +#dummyId2 {
   +
   +}
   +
   +#dummyId3 {
   +    color: #F1F1F1;
   +}
   +
   +.anotherClassSelector {
   +
   +}
   +
   +h1 {
   +
   +}
   +
   +#yetAnotherId {
   +
   +}
   \ No newline at end of file
   diff --git a/ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/csl/CssGotoDeclarationTest.java b/ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/csl/CssGotoDeclarationTest.java
   new file mode 100644
   index 0000000000..70c695a8df
   --- /dev/null
   +++ b/ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/csl/CssGotoDeclarationTest.java
   @@ -0,0 +1,46 @@
   +/*
   + * 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.css.editor.csl;
   +
   +import org.netbeans.modules.csl.spi.DefaultLanguageConfig;
   +import org.netbeans.modules.html.editor.gsf.HtmlLanguage;
   +
   +public class CssGotoDeclarationTest extends CssGotoDeclarationTestBase {
   +
   +    public CssGotoDeclarationTest(String testName) {
   +        super(testName, "simple");
   +    }
   +
   +    @Override
   +    protected DefaultLanguageConfig getPreferredLanguage() {
   +        return new HtmlLanguage();
   +    }
   +
   +    public void testClass_01() throws Exception {
   +        checkDeclaration(getSourcesFolderName() + "/test.html", "<p class=\"classSelec^tor1\">test class</p>", ".^classSelector1 {");
   +    }
   +
   +    public void testClass_02() throws Exception {
   +        checkDeclaration(getSourcesFolderName() + "/test.html", "<p class=\"classSelec^tor3\">test class</p>", ".^classSelector3 {");
   +    }
   +
   +    public void testId_01() throws Exception {
   +        checkDeclaration(getSourcesFolderName() + "/test.html", "<p id=\"yetAnoth^erId\">test id</p>", "#^yetAnotherId {");
   +    }
   +}
   diff --git a/ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/csl/CssGotoDeclarationTestBase.java b/ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/csl/CssGotoDeclarationTestBase.java
   new file mode 100644
   index 0000000000..f2f631846d
   --- /dev/null
   +++ b/ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/csl/CssGotoDeclarationTestBase.java
   @@ -0,0 +1,49 @@
   +/*
   + * 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.css.editor.csl;
   +
   +import java.util.Collections;
   +import java.util.Map;
   +import org.netbeans.api.java.classpath.ClassPath;
   +import org.netbeans.modules.css.editor.ProjectTestBase;
   +import org.netbeans.spi.java.classpath.support.ClassPathSupport;
   +import org.openide.filesystems.FileObject;
   +
   +public class CssGotoDeclarationTestBase extends ProjectTestBase {
   +
   +    protected static final String BASE_TEST_FOLDER_PATH = "testfiles/gotodeclaration/";
   +
   +    public CssGotoDeclarationTestBase(String testName, String projectName) {
   +        super(testName, BASE_TEST_FOLDER_PATH + projectName);
   +    }
   +
   +    @Override
   +    protected Map<String, ClassPath> createClassPathsForTest() {
   +        FileObject[] srcFolders = createSourceClassPathsForTest();
   +        return srcFolders != null ? Collections.singletonMap(
   +                ClassPath.SOURCE,
   +                ClassPathSupport.createClassPath(srcFolders)
   +        ) : null;
   +    }
   +
   +    protected FileObject[] createSourceClassPathsForTest() {
   +        return new FileObject[]{getTestFile(getSourcesFolderName())};
   +    }
   +
   +}
   ```
   </details>


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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

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


[GitHub] [netbeans] junichi11 commented on a change in pull request #2616: [NETBEANS-4739] CSS Go to Declaration , does not work

Posted by GitBox <gi...@apache.org>.
junichi11 commented on a change in pull request #2616:
URL: https://github.com/apache/netbeans/pull/2616#discussion_r549943390



##########
File path: ide/parsing.lucene/src/org/netbeans/modules/parsing/lucene/support/Queries.java
##########
@@ -518,6 +525,12 @@ private static String getStartText(final String regexp) {
             boolean quoted = false;
             for (int i = 0; i < regexp.length(); i++) {
                 char c = regexp.charAt(i);
+                if((! quoted) && i < (regexp.length() - 1)) {
+                    char lookAhead = regexp.charAt(i + 1);
+                    if(QUANTIFIER_CHARS.get(lookAhead)) {
+                        break;
+                    }
+                }

Review comment:
       Nitpick: formatting




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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

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


[GitHub] [netbeans] junichi11 commented on a change in pull request #2616: [NETBEANS-4739] CSS Go to Declaration , does not work

Posted by GitBox <gi...@apache.org>.
junichi11 commented on a change in pull request #2616:
URL: https://github.com/apache/netbeans/pull/2616#discussion_r550201598



##########
File path: ide/css.editor/test/unit/src/org/netbeans/modules/css/editor/ProjectTestBase.java
##########
@@ -59,14 +56,16 @@
 import org.openide.util.test.MockLookup;
 
 /**
- * Base class for all CP preprocessor tests which needs a working static html project.
+ * Base class for all tests which needs a working static html project.
+ *
+ * Copied from org.netbeans.modules.css.prep.editor.ProjectTestBase

Review comment:
       Moved? or Remove this line?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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

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


[GitHub] [netbeans] junichi11 commented on pull request #2616: [NETBEANS-4739] CSS Go to Declaration , does not work

Posted by GitBox <gi...@apache.org>.
junichi11 commented on pull request #2616:
URL: https://github.com/apache/netbeans/pull/2616#issuecomment-752775488


   @matthiasblaesing No problem. Thank you for your great work.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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

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