Skip to content

Commit

Permalink
Updates for 0.20.0-alpha.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gdotdesign committed Oct 18, 2024
1 parent b9fb707 commit be507ba
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 46 deletions.
38 changes: 23 additions & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
# Contributing Guideline
# Contributing to Mint

Read the general [Contributing guide][1], and then:
So you've decided to contribute to Mint. Excellent!

## Using the issue tracker

The [issue tracker](https://github.com/mint-lang/mint/issues) is the heart of Mint's work. Use it for bugs, questions, proposals and feature requests.

Please always **open a new issue before sending a pull request** if you want to add a new feature to Mint, unless it is a minor fix, and wait until someone from the core team approves it before you actually start working on it. Otherwise, you risk having the pull request rejected, and the effort implementing it goes to waste. And if you start working on an implementation for an issue, please **let everyone know in the comments** so someone else does not start working on the same thing.

Regardless of the kind of issue, please make sure to look for similar existing issues before posting; otherwise, your issue may be flagged as `duplicated` and closed in favour of the original one. Also, once you open a new issue, please make sure to honour the items listed in the issue template.

If you open a question, remember to close the issue once you are satisfied with the answer and you think
there's no more room for discussion. We'll anyway close the issue after some days.

If something is missing from the language it might be that it's not yet implemented or that it was purposely left out. If in doubt, just ask.

The best place to start an open discussion about potential changes is the [discussions](https://github.com/mint-lang/mint/discussions).

## Contributing Workflow

Read this guide then:

- Fork it (<https://github.com/mint-lang/mint/fork>)
- Create your feature branch (`git checkout -b my-new-feature`)
- Commit your changes (`git commit -am 'Add some feature'`)
- Push to the branch (`git push origin my-new-feature`)
- Create a new [Pull Request](https://github.com/mint-lang/mint/pulls)

[1]: https://github.com/crystal-lang/crystal/blob/master/CONTRIBUTING.md

## Development

### Installing Crystal

We need to install [Crystal](https://crystal-lang.org/) programming language
first. Before installing it, we should install its dependencies.

##### Ubuntu

```
$ sudo apt update
$ sudo apt install pkg-config ubuntu-dev-tools
```

Then, follow [this instruction][2].

[2]: https://crystal-lang.org/install/on_ubuntu/

### Installing Mint dependencies

Once you have Crystal installed install the dependencies needed for building Mint:

```
$ shards install
```
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# We are using crystal as image we are building the binary on
FROM crystallang/crystal:1.9.1-alpine AS build
FROM crystallang/crystal:1.14.0-alpine AS build

# Create a build directory and set it as default
RUN mkdir -p /opt/mint
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "2"
services:
app:
image: crystallang/crystal:1.8.2-alpine
image: crystallang/crystal:1.14.0-alpine
working_dir: /app
volumes:
- .:/app
37 changes: 37 additions & 0 deletions spec/language_server/completion/partial_function
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module Test {
fun otherFunction (name : String) : String {
name
}
}
------------------------------------------------------------------file test.mint
component Other {
fun
}
-----------------------------------------------------------------file other.mint
{
"id": 0,
"method": "textDocument/completion",
"params": {
"textDocument": {
"uri": "file://#{root_path}/other.mint"
},
"position": {
"line": 2,
"character": 5
}
}
}
-------------------------------------------------------------------------request
{
"label": "Test.otherFunction",
"kind": 3,
"detail": "Function",
"documentation": "",
"deprecated": false,
"preselect": false,
"sortText": "Test.otherFunction",
"filterText": "Test.otherFunction",
"insertText": "Test.otherFunction()",
"insertTextFormat": 2
}
--------------------------------------------------------------response 0 contain
4 changes: 2 additions & 2 deletions src/ls/completion.cr
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ module Mint

def initialize(
*,
@type_checker : TypeChecker,
@type_checker : TypeChecker | Nil,
@snippet_support : Bool,
@workspace : Workspace
)
end

def process(params : LSP::CompletionParams)
ast =
@type_checker.artifacts.ast
@workspace.unchecked_ast

global_completions =
(
Expand Down
2 changes: 1 addition & 1 deletion src/ls/completion_item/component.cr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Mint
.gsub("}", "\\}")

type =
@type_checker.cache[property]?
@type_checker.try(&.cache[property]?)

value =
case type.try(&.name)
Expand Down
21 changes: 12 additions & 9 deletions src/ls/completion_request.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ module Mint
workspace =
server.workspace(params.path)

case type_checker = workspace.result
in TypeChecker
Completion.new(
snippet_support: snippet_support,
type_checker: type_checker,
workspace: workspace
).process(params)
in Error
end
type_checker =
case item = workspace.result
in TypeChecker
item
in Error
end

Completion.new(
snippet_support: snippet_support,
type_checker: type_checker,
workspace: workspace
).process(params)
end
end
end
Expand Down
36 changes: 19 additions & 17 deletions src/workspace.cr
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ module Mint
map_error(artifacts, &.ast)
end

def unchecked_ast
@cache
.values
.select(Ast)
.reduce(Ast.new) { |memo, item| memo.merge item }
.tap do |item|
# Only merge the core if it's not the core (if it has `Maybe`
# defined then it's the core). This is so the language server
# works with the core files.
unless item.type_definitions.index(&.name.==("Maybe"))
item.merge(Core.ast)
end
end
.normalize
end

def nodes_at_cursor(
*,
column : Int64,
Expand Down Expand Up @@ -96,25 +112,10 @@ module Mint
if error = @cache.values.select(Error).first?
error
else
ast =
@cache
.values
.select(Ast)
.reduce(Ast.new) { |memo, item| memo.merge item }
.tap do |item|
# Only merge the core if it's not the core (if it has `Maybe`
# defined then it's the core). This is so the language server
# works with the core files.
unless item.type_definitions.index(&.name.==("Maybe"))
item.merge(Core.ast)
end
end
.normalize

TypeChecker.new(
check_everything: @check.unreachable?,
check_env: @check.environment?,
ast: ast
ast: unchecked_ast
).tap(&.check)
end
end
Expand Down Expand Up @@ -153,8 +154,9 @@ module Mint
# 1. packages could have changed
# 2. source directories could have changed
# 3. variables in the .env file cloud have changed
case File.basename(file)
case basename = File.basename(file)
when "mint.json", ".env"
Env.init(basename) { } if basename == ".env"
actions << :reset
end
end
Expand Down

0 comments on commit be507ba

Please sign in to comment.