Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to public release #24

Merged
merged 52 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
64e618d
use get_global_offset_from_line and fix returned locations
Mar 22, 2023
8b18efd
Merge pull request #1 from crytic/fix-lsp-hooks
broccolirob Mar 22, 2023
f17722f
Add go to implementation function
Apr 26, 2023
755580e
Merge pull request #2 from crytic/go-to-impl
broccolirob Apr 27, 2023
6525001
Raise polling interval so workspace isn't constantly refreshing
May 1, 2023
d5df277
Merge pull request #6 from crytic/polling-increase
broccolirob May 1, 2023
d69959c
Use `pyproject.toml` instead of `setup.py`
frabert Mar 14, 2024
a509f63
Merge pull request #9 from crytic/frabert/migrate-to-pyproject
frabert Mar 20, 2024
8d7e188
Migrate to `pygls`
frabert Mar 19, 2024
16b17bf
Improve some request handlers
frabert Mar 20, 2024
ded0352
Update `semantic-version`
frabert Mar 21, 2024
91c7335
Refactor refresh logic
frabert Mar 21, 2024
550346d
Remove unused variables
frabert Mar 22, 2024
ab5d5b6
Allow requests to be served before compilation is complete
frabert Mar 22, 2024
548f856
Factor out loading detector classes
frabert Mar 22, 2024
7e35647
Factor out code that doesn't depend on loop variables
frabert Mar 25, 2024
de95d1e
Extract common functionality
frabert Mar 25, 2024
dd31bd7
Fix that sometimes the ending character would be `-1`
frabert Mar 25, 2024
8c78e5d
Add util to get `Range` from `Source`
frabert Mar 26, 2024
ed6596d
Add utility method to get the name of functions
frabert Mar 26, 2024
d2cd166
Add utility typedefs
frabert Mar 27, 2024
93117d4
Implement "prepare call hierarchy"
frabert Mar 27, 2024
8f51571
Implement "get incoming calls"
frabert Mar 27, 2024
22d8ccd
Implement "get outgoing calls"
frabert Mar 27, 2024
7e50217
Factor out common functionality
frabert Mar 29, 2024
cae9607
Implement type hierarchy
frabert Mar 29, 2024
deeb067
Extract common functionality to separate module
frabert Apr 1, 2024
a552820
Extract goto-def/impl/ref to separate module
frabert Apr 1, 2024
f5234c5
Extract call hierarchy to separate module
frabert Apr 1, 2024
5e15787
Extract type hierarchy to separate module
frabert Apr 1, 2024
6b6fc93
Forward log messages to clients
frabert Apr 2, 2024
687b4d4
Use a single Slither object for each workspace
frabert Apr 2, 2024
c914576
Making an intermediate copy of the analyses is not necessary anymore
frabert Apr 2, 2024
5f336ed
Now we can remove this hack
frabert Apr 3, 2024
605e026
Add command to refresh folders
frabert Apr 4, 2024
b6f265c
Remove unused commands and types
frabert Apr 4, 2024
135472c
Update README
frabert Apr 4, 2024
3bca8d5
Add brief guide on how to add features
frabert Apr 4, 2024
7147072
Bump `slither-analyzer` dependency version
frabert Apr 8, 2024
4f66e4d
Show function ids as inlays next to definitions
frabert Apr 4, 2024
cfcfef0
Allow navigation using VSCode breadcrumbs
frabert Apr 4, 2024
8af2e2c
Add CodeLens to show SlithIR of functions
frabert Apr 8, 2024
05c97e8
Populate pyproject fields
frabert Apr 9, 2024
89aec95
Set up linting CI checks
frabert Apr 9, 2024
1ae4b4e
Add pip-audit CI
frabert Apr 9, 2024
1d92eed
Add black CI
frabert Apr 9, 2024
89a7a60
Fix typo
frabert Apr 9, 2024
0c91850
Fix Python version parsing issue
frabert Apr 9, 2024
28ece24
Remove old tests
frabert Apr 9, 2024
b972041
Format
frabert Apr 9, 2024
b53791e
Fix pylint
frabert Apr 9, 2024
bccb1e4
Add publish CI
frabert Apr 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add command to refresh folders
  • Loading branch information
frabert committed Apr 8, 2024
commit 605e02645adb56272a2af39aaa9ddf1070c1a92b
23 changes: 19 additions & 4 deletions slither_lsp/app/slither_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from functools import lru_cache
from threading import Lock
from typing import Dict, List, Optional, Tuple, Type
from os.path import split

import lsprotocol.types as lsp
from crytic_compile.crytic_compile import CryticCompile
Expand Down Expand Up @@ -40,6 +41,8 @@
COMPILATION_SET_COMPILATION_TARGETS,
METHOD_TO_TYPES,
SLITHER_SET_DETECTOR_SETTINGS,
SLITHER_ANALYZE,
AnalysisRequestParams,
)
from slither_lsp.app.utils.file_paths import normalize_uri, uri_to_fs_path

Expand Down Expand Up @@ -111,9 +114,9 @@ def on_set_detector_settings(ls: SlitherServer, params):
ls._on_set_detector_settings(params)

@self.thread()
@self.feature(COMPILATION_SET_COMPILATION_TARGETS)
def on_set_compilation_targets(ls: SlitherServer, params):
pass
@self.feature(SLITHER_ANALYZE)
def on_analyze(ls: SlitherServer, params):
ls._on_analyze(params)

register_on_goto_definition(self)
register_on_goto_implementation(self)
Expand Down Expand Up @@ -148,11 +151,23 @@ def _on_initialize(self, params: lsp.InitializeParams) -> None:
for workspace in params.workspace_folders or []:
self.queue_compile_workspace(normalize_uri(workspace.uri))

def _on_analyze(self, params: AnalysisRequestParams):
uris = [normalize_uri(uri) for uri in params.uris or self.workspaces.keys()]
for uri in uris:
path = uri_to_fs_path(uri)
workspace_name = split(path)[1]
if self.workspace_in_progress[uri].locked():
self.show_message(
f"Analysis for {workspace_name} is already in progress",
lsp.MessageType.Warning,
)
continue
self.queue_compile_workspace(uri)

def queue_compile_workspace(self, uri: str):
"""
Queues a workspace for compilation. `uri` should be normalized
"""
from os.path import split
path = uri_to_fs_path(uri)
workspace_name = split(path)[1]

Expand Down
6 changes: 6 additions & 0 deletions slither_lsp/app/types/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
)


@attrs.define
class AnalysisRequestParams:
uris: Optional[List[str]] = attrs.field()


@attrs.define
class SetCompilationTargetsParams:
"""
Expand Down Expand Up @@ -43,6 +48,7 @@ class AnalysisProgressParams:
""" A list of analysis results, one for each compilation target. """


SLITHER_ANALYZE = "$/slither/analyze"
SLITHER_GET_DETECTOR_LIST = "$/slither/getDetectorList"
SLITHER_GET_VERSION = "$/slither/getVersion"
SLITHER_SET_DETECTOR_SETTINGS = "$/slither/setDetectorSettings"
Expand Down