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

feat: exclude modules by wildcard name #363

Conversation

zetaron
Copy link
Contributor

@zetaron zetaron commented Sep 9, 2020

With this PR I'd like to introduce the possibility for modules to be excluded without knowing their full name.

Example:

{
            "type": "mix_task",
            "name": "mix phx.server",
            "request": "launch",
            "task": "phx.server",
            "projectDir": "${workspaceRoot}",
            "excludeModules": [
                ":phoenix",
                "Phoenix",
                "Phoenix.*"
            ]
}

This helped me to use the debugging feature of the vscode-elixir-ls extension which kept failing for our team. Without this feature I was unable/unwilling to collect all the modules names that need to be excluded. The only approach, to gather the required module names, seemed to be trial and error based, which combined with the debuggers starting times felt disproportionate.

With this PR I'd like to introduce the possibility for modules to be excluded without knowing their full name.

Example:

```
{
            "type": "mix_task",
            "name": "mix phx.server",
            "request": "launch",
            "task": "phx.server",
            "projectDir": "${workspaceRoot}",
            "excludeModules": [
                ":phoenix",
                "Phoenix",
                "Phoenix.*"
            ]
}
```

This helped me to use the debugging feature of the vscode-elixir-ls extension. Without this feature I was unable to collect all the modules names that need to be excluded.
regex_pattern =
wildcard_pattern
|> prefix_module_name()
|> String.replace(".", ~s(\.))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use Regex.excape/1

:int.interpretable(module) == true and !:code.is_sticky(module) and module != __MODULE__ and
module not in exclude_modules
module_name not in exclude_module_names and
not Enum.any?(exclude_module_names, &module_matches_wildcard(module_name, &1))
Copy link
Collaborator

@lukaszsamson lukaszsamson Sep 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compute wildcards patterns once before instead of once for every module

@zetaron
Copy link
Contributor Author

zetaron commented Sep 9, 2020

@lukaszsamson I've integrated your suggestions, maybe take another look if this is good to go?

@zetaron
Copy link
Contributor Author

zetaron commented Sep 21, 2020

@lukaszsamson Hey, did you have the chance to take another look?

@lukaszsamson
Copy link
Collaborator

Sorry, I missed the notification earlier. Looks good now, thanks

@lukaszsamson lukaszsamson merged commit 0b5dd33 into elixir-lsp:master Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants