Skip to content

Adds support for workspace built-in variables #232

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

Closed
wants to merge 1 commit into from

Conversation

gnikit
Copy link
Member

@gnikit gnikit commented Jun 1, 2021

Now VSCode variables ${workspaceFolder} and ${workspaceRoot} can be
used in the settings.json file to set up include paths and
output directories for the .mod linter files

Fixes #176.
Closes #231
Possible closure #187

Now VSCode variables `${workspaceFolder} and `${workspaceRoot}` can be
used in the `settings.json` file to set up include paths and
output directories for the .mod linter files

Fixes fortran-lang#176.
@gnikit gnikit requested a review from krvajal June 1, 2021 17:14
@gnikit gnikit self-assigned this Jun 1, 2021
@gnikit gnikit requested a review from pedro-ricardo June 1, 2021 17:51
@gnikit
Copy link
Member Author

gnikit commented Jun 2, 2021

I think it might also be worth adding some basic glob support for the includes. We would have to replicate the cpp extension's behaviour for that

@gnikit
Copy link
Member Author

gnikit commented Jun 7, 2021

Pretty sure I should move the changes to helper.ts since they are not specific to the linter.

@gnikit gnikit changed the base branch from master to develop June 7, 2021 15:58
Comment on lines +91 to +92
let options = vscode.workspace.workspaceFolders
? { cwd: vscode.workspace.workspaceFolders }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like this option is not used at all. When running the linter the cwd passed is the one of the active file. This works well for single files but I can imagine that it does not when working on a project context.

Copy link
Member Author

Choose a reason for hiding this comment

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

True, I hadn't noticed I simply updated the rootPath option which was deprecated. I will remove options completely.

return config.get("linterExtraArgs", ["-Wall"]);
let args = config.get("linterExtraArgs", ["-Wall"]);

return args.map(this.resolveVariables);
Copy link
Collaborator

Choose a reason for hiding this comment

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

External args passed by the user can be anything, we should not be overriding them. It can break people's workflow.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we would be overriding something the user can define outside of VS Code, since settings.json does not inherit shell or build-system (cmake/autoconf) variables.
So when the extension calls getLinterExtraArgs() and the variable ${workspaceFolder} is encountered it can be 2 things:

  1. An internal VS Code variable or
  2. A gfortran flag.

However, gfortran does not declare arguments in this format, therefore, to the best of my knowledge ${} would be an illegal argument to pass to gfortran, and hence ${} can be uniquely interpreted as a VS Code internal variable.

Moreover, this is very similar to how the C/C++ extension works which allows for compilerArgs to make use of the predefined VS Code variables.

@gnikit
Copy link
Member Author

gnikit commented Jun 8, 2021

Superseded via #238

@gnikit gnikit closed this Jun 8, 2021
@gnikit gnikit deleted the feature/workspace-paths branch September 22, 2022 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants