JaroslavTulach commented on a change in pull request #3047: URL: https://github.com/apache/netbeans/pull/3047#discussion_r669443024
########## File path: ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/SourceInfo.java ########## @@ -0,0 +1,107 @@ +/* + * 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.nativeimage.api; + +/** + * A source file information in the debuggee program. + * + * @since 0.2 + */ +public final class SourceInfo { + + private final String fileName; + private final String fullName; + + private SourceInfo(String fileName, String fullName) { + this.fileName = fileName; + this.fullName = fullName; + } + + /** + * Get the file name, or <code>null</code> when unknown. May return a relative path. + * + * @since 0.2 + */ + public String getFileName() { + return fileName; + } + + /** + * Get the full file name, or <code>null</code> when unknown. Returns an absolute path, if any. + * + * @since 0.2 + */ + public String getFullName() { + return fullName; + } + + /** + * Creates a builder to build a new {@link SourceInfo}. + * + * @since 0.2 + */ + public static Builder newBuilder() { + return new Builder(); + } + + @Override + public String toString() { + return "SourceInfo{" + "fileName=" + fileName + ", fullName=" + fullName + '}'; + } + Review comment: If `SourceInfo` is used in `Map`, then it needs proper `equals` and `hashCode`. ########## File path: ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/NIDebugger.java ########## @@ -165,6 +170,49 @@ public String getVersion() { return provider.getVersion(); } + /** + * Get a list of locations for a given file path. + * + * @param filePath a file path + * @return list of locations, or <code>null</code> when there's no location + * information about such file. + * @since 0.2 + */ + @CheckForNull + public List<Location> listLocations(String filePath) { + return provider.listLocations(filePath); + } + + /** + * Get a list of functions of a given name. + * + * @param name a name pattern + * @param includeNondebug include also symbols from the symbol table + * @param maxResults maximum number of results + * @return list of source information and their symbols, or <code>null</code> + * when there are no matching symbols. + * @since 0.2 + */ + @CheckForNull + public List<Pair<SourceInfo, List<Symbol>>> listFunctions(String name, boolean includeNondebug, int maxResults) { + return provider.listFunctions(name, includeNondebug, maxResults); + } + + /** + * Get a list of variables of a given name. + * + * @param name a name pattern + * @param includeNondebug include also symbols from the symbol table + * @param maxResults maximum number of results + * @return list of source information and their symbols, or <code>null</code> + * when there are no matching symbols. + * @since 0.2 + */ + @CheckForNull + public List<Pair<SourceInfo, List<Symbol>>> listVariables(String name, boolean includeNondebug, int maxResults) { Review comment: `List<Pair<X,List<Y>>>` might rather be `Map<X,List<Y>>` - at least that's more traditional way to represent such structure. One can still use `map.entrySet()` and iterate the elements pair by pair (or rather `Entry` by `Entry`). ########## File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/NbCodeClientWrapper.java ########## @@ -144,4 +144,19 @@ public void semanticHighlighting(SemanticHighlightingParams params) { public void notifyProgress(ProgressParams params) { remote.notifyProgress(params); } + + @Override + public CompletableFuture<String> createTextEditorDecoration(DecorationRenderOptions params) { Review comment: I am not sure I understand the purpose of these new messages. They look standard (e.g. `window/createTextEditorDecoration`)... ########## File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/Server.java ########## @@ -824,6 +832,24 @@ public void showMessage(MessageParams messageParams) { return x; } + @Override + public CompletableFuture<String> createTextEditorDecoration(DecorationRenderOptions params) { + logWarning(params); Review comment: Shouldn't the methods be abstract? It is strange to see such dummy code in production. ########## File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/OverviewRulerLane.java ########## @@ -0,0 +1,57 @@ +/* + * 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.util.HashMap; +import java.util.Map; + +/** + * + * @author Martin Entlicher + */ +public enum OverviewRulerLane { + + Center(2), + Full(7), + Left(1), + Right(4); + + private final int intValue; + + OverviewRulerLane(int intValue) { + this.intValue = intValue; + } + + public int getIntValue() { + return intValue; + } + + private static final Map<Integer, OverviewRulerLane> lookup = new HashMap<>(); + + static { + for (OverviewRulerLane value : OverviewRulerLane.values()) { + lookup.put(value.getIntValue(), value); + } + } + + public static OverviewRulerLane get(Integer intValue) { Review comment: Use `int` instead of `Integer`. Simple `switch` would be more effective then a `lookup` hash map. ########## File path: java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/protocol/ServerTest.java ########## @@ -1604,6 +1604,21 @@ public void showMessage(MessageParams params) { public void logMessage(MessageParams arg0) { throw new UnsupportedOperationException("Not supported yet."); } + + @Override + public CompletableFuture<String> createTextEditorDecoration(DecorationRenderOptions params) { + throw new UnsupportedOperationException("Not supported yet."); Review comment: `TestProgressHandlerTest` is using `fail()` while the other tests are using `UnsupportedOperationException` - I guess I like `fail()` more. ########## File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java ########## @@ -235,7 +236,6 @@ /** * Documents actually opened by the client. */ - private final Map<String, Document> openedDocuments = new ConcurrentHashMap<>(); Review comment: `OpenDocuments` class is a refactored version of the map then, right? ########## File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/ni/NILocationVisualizer.java ########## @@ -0,0 +1,414 @@ +/* + * 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.debugging.ni; + +import com.sun.source.tree.ClassTree; +import com.sun.source.tree.CompilationUnitTree; +import com.sun.source.tree.LineMap; +import com.sun.source.tree.MethodTree; +import com.sun.source.tree.Tree; +import com.sun.source.tree.VariableTree; +import com.sun.source.util.SourcePositions; +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.CompletableFuture; +import java.util.function.Consumer; +import javax.lang.model.element.Element; +import javax.lang.model.element.Modifier; +import javax.lang.model.element.TypeElement; +import javax.swing.text.Document; +import javax.swing.text.StyledDocument; +import javax.tools.Diagnostic; +import org.eclipse.lsp4j.Position; +import org.eclipse.lsp4j.Range; +import org.eclipse.lsp4j.jsonrpc.messages.Either; +import org.netbeans.api.debugger.Session; +import org.netbeans.api.java.classpath.ClassPath; +import org.netbeans.api.java.source.CompilationController; +import org.netbeans.api.java.source.JavaSource; +import org.netbeans.api.java.source.Task; +import org.netbeans.api.java.source.TreeUtilities; +import org.netbeans.modules.java.lsp.server.files.OpenedDocuments; +import org.netbeans.modules.java.lsp.server.progress.OperationContext; +import org.netbeans.modules.java.lsp.server.protocol.DecorationRenderOptions; +import org.netbeans.modules.java.lsp.server.protocol.NbCodeLanguageClient; +import org.netbeans.modules.java.lsp.server.protocol.SetTextEditorDecorationParams; +import org.netbeans.modules.nativeimage.api.Location; +import org.netbeans.modules.nativeimage.api.SourceInfo; +import org.netbeans.modules.nativeimage.api.Symbol; +import org.netbeans.modules.nativeimage.api.debug.NIDebugger; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.URLMapper; +import org.openide.text.NbDocument; +import org.openide.util.Lookup; +import org.openide.util.Pair; + +/** + * + * @author Martin Entlicher + */ +public final class NILocationVisualizer implements Consumer<String> { + + private final File niFileSources; Review comment: Shouldn't the NetBeans code rather work with `FileObject`s? -- 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
