dbalek commented on a change in pull request #3093: URL: https://github.com/apache/netbeans/pull/3093#discussion_r690113362
########## File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TestFinder.java ########## @@ -0,0 +1,240 @@ +/* + * 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.lsp.server.protocol; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; +import org.netbeans.api.editor.mimelookup.MimeLookup; +import org.netbeans.api.editor.mimelookup.MimeRegistration; +import org.netbeans.api.java.queries.UnitTestForSourceQuery; +import org.netbeans.modules.gsf.testrunner.ui.api.TestMethodController; +import org.netbeans.modules.gsf.testrunner.ui.spi.ComputeTestMethods; +import org.netbeans.modules.java.lsp.server.Utils; +import org.netbeans.modules.parsing.api.Snapshot; +import org.netbeans.modules.parsing.impl.indexing.CacheFolder; +import org.netbeans.modules.parsing.spi.Parser; +import org.netbeans.modules.parsing.spi.indexing.Context; +import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexer; +import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexerFactory; +import org.netbeans.modules.parsing.spi.indexing.Indexable; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.util.Exceptions; + +/** + * + * @author Dusan Balek + */ +public final class TestFinder extends EmbeddingIndexer { + + private static final String NAME = "tests"; // NOI18N + private static final int VERSION = 1; + private static TestFinder INSTANCE = null; + + private final Set<NbCodeLanguageClient> clients = new HashSet<>(); + + @MimeRegistration(mimeType="", service=EmbeddingIndexerFactory.class) //NOI18N Review comment: The only purpose of collecting these data is to implement the `java.load.workspace.tests` LSP command more effectively. The original implementation of the command collected all sources under test roots, parsed them and used `org.netbeans.modules.gsf.testrunner.ui.spi.ComputeTestMethods` to collect test methods from these sources. Each source under a test root was parsed at least twice (once on initial scan to index language features, once to collect test methods). This PR plugs the test method collection to the initial scan and saves the second parsing of each test source. If I put this functionality to GSF, an additional API of GSF module to access these data had to be designed for LSP as the only client. -- 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: notifications-unsubscr...@netbeans.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org For additional commands, e-mail: notifications-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists