Skip to content

Commit

Permalink
Merge branch 'master' into highprecision
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbattle committed Nov 7, 2024
2 parents bf03d60 + 09bfad3 commit 8aec033
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 22 deletions.
18 changes: 12 additions & 6 deletions lsp/src/main/java/lsp/LSPServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,23 @@ public void run() throws IOException
for (JSONObject response: responses)
{
writeMessage(response);

if (response.get("method") != null && response.get("id") != null) // A request
{
RPCRequest req = RPCRequest.create(response);
responseHandlers.put(response.get("id"), dispatcher.getHandler(req));
}
}
}
}
}
}

@Override
public synchronized void writeMessage(JSONObject response) throws IOException
{
if (response.get("method") != null && response.get("id") != null) // A request
{
RPCRequest req = RPCRequest.create(response);
responseHandlers.put(response.get("id"), dispatcher.getHandler(req));
}

super.writeMessage(response);
}

public boolean isInitialized()
{
Expand Down
41 changes: 41 additions & 0 deletions lsp/src/main/java/lsp/workspace/CodeLensRefreshHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*******************************************************************************
*
* Copyright (c) 2024 Nick Battle.
*
* Author: Nick Battle
*
* This file is part of VDMJ.
*
* VDMJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VDMJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VDMJ. If not, see <http://www.gnu.org/licenses/>.
* SPDX-License-Identifier: GPL-3.0-or-later
*
******************************************************************************/
package lsp.workspace;

import lsp.LSPHandler;
import rpc.RPCErrors;
import rpc.RPCMessageList;
import rpc.RPCRequest;

/**
* A handler for the "workspace/codeLens/refresh" method response, which is ignored.
*/
public class CodeLensRefreshHandler extends LSPHandler
{
@Override
public RPCMessageList request(RPCRequest request)
{
return new RPCMessageList(request, RPCErrors.InternalError);
}
}
2 changes: 1 addition & 1 deletion lsp/src/main/java/workspace/plugins/ASTPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ protected void preCheck(CheckPrepareEvent ev)
* We register the launch/debug code lens here, if the tree is dirty. Else it
* is registered by the TCPlugin.
*/
protected List<ASTCodeLens> getASTCodeLenses(boolean dirty)
protected List<ASTCodeLens> getASTCodeLenses()
{
List<ASTCodeLens> lenses = new Vector<ASTCodeLens>();

Expand Down
3 changes: 1 addition & 2 deletions lsp/src/main/java/workspace/plugins/ASTPluginPR.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,10 @@ public String[] getFilenameFilters()
public JSONArray getCodeLenses(File file)
{
JSONArray results = new JSONArray();
ASTPlugin ast = registry.getPlugin("AST");

if (dirtyClassList != null && !dirtyClassList.isEmpty()) // May be syntax errors
{
List<ASTCodeLens> lenses = getASTCodeLenses(ast.isDirty());
List<ASTCodeLens> lenses = getASTCodeLenses();

for (ASTClassDefinition clazz: dirtyClassList)
{
Expand Down
3 changes: 1 addition & 2 deletions lsp/src/main/java/workspace/plugins/ASTPluginSL.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,10 @@ public String[] getFilenameFilters()
public JSONArray getCodeLenses(File file)
{
JSONArray results = new JSONArray();
ASTPlugin ast = registry.getPlugin("AST");

if (dirtyModuleList != null && !dirtyModuleList.isEmpty())
{
List<ASTCodeLens> lenses = getASTCodeLenses(ast.isDirty());
List<ASTCodeLens> lenses = getASTCodeLenses();

for (ASTModule module: dirtyModuleList)
{
Expand Down
2 changes: 2 additions & 0 deletions lsp/src/main/java/workspace/plugins/LSPPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
import lsp.textdocument.ReferencesHandler;
import lsp.textdocument.TypeHierarchyHandler;
import lsp.textdocument.WatchKind;
import lsp.workspace.CodeLensRefreshHandler;
import lsp.workspace.DidChangeWSHandler;
import rpc.RPCErrors;
import rpc.RPCMessageList;
Expand Down Expand Up @@ -226,6 +227,7 @@ public void init()
lspDispatcher.register(new TypeHierarchyHandler(), "textDocument/prepareTypeHierarchy", "typeHierarchy/supertypes", "typeHierarchy/subtypes");

lspDispatcher.register(new DidChangeWSHandler(), "workspace/didChangeWatchedFiles");
lspDispatcher.register(new CodeLensRefreshHandler(), "workspace/codeLens/refresh");

lspDispatcher.register(new UnknownHandler()); // Called for unknown methods
}
Expand Down
13 changes: 2 additions & 11 deletions vdmj/src/main/java/com/fujitsu/vdmj/tc/types/TCUnionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -827,19 +827,10 @@ public boolean equals(Object other)
if (other instanceof TCUnionType)
{
TCUnionType uother = (TCUnionType)other;

for (TCType t: uother.types)
{
if (!types.contains(t))
{
return false;
}
}

return true;
return uother.types.equals(types);
}

return types.contains(other);
return false;
}

@Override
Expand Down

0 comments on commit 8aec033

Please sign in to comment.