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: add settings.compiler.flags #45

Merged
merged 2 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions integ/spec/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ export async function initState(): Promise<CommonState> {
const lfortranPathSetting: Setting =
await settingsEditor.findSettingByID("LFortranLanguageServer.compiler.lfortranPath");
await lfortranPathSetting.setValue("./lfortran/src/bin/lfortran");
const compilerFlagsSetting: Setting =
await settingsEditor.findSettingByID("LFortranLanguageServer.compiler.flags");
await compilerFlagsSetting.setValue("");
const fontFamily: Setting =
await settingsEditor.findSettingByID("editor.fontFamily");
await fontFamily.setValue('consolas, "DejaVu Sans Mono", monospace');
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@
"default": "lfortran",
"description": "The path to the LFortran compiler executable."
},
"LFortranLanguageServer.compiler.flags": {
dylon marked this conversation as resolved.
Show resolved Hide resolved
"scope": "resource",
"type": "string",
"default": "",
"description": "Additional flags to pass to the LFortran compiler ( space separated )."
},
"LFortranLanguageServer.log.level": {
"scope": "resource",
"type": "string",
Expand Down
12 changes: 12 additions & 0 deletions server/src/lfortran-accessors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ export class LFortranCLIAccessor implements LFortranAccessor {
const start: number = performance.now();

const flags = ["--show-document-symbols", "--continue-compilation"];
if (settings.compiler.flags !== "") {
flags.push(settings.compiler.flags);
dylon marked this conversation as resolved.
Show resolved Hide resolved
}
const stdout = await this.runCompiler(settings, flags, text, "[]");

let symbols: SymbolInformation[];
Expand Down Expand Up @@ -340,6 +343,9 @@ export class LFortranCLIAccessor implements LFortranAccessor {
"--column=" + (column + 1),
"--continue-compilation"
];
if (settings.compiler.flags !== "") {
flags.push(settings.compiler.flags);
dylon marked this conversation as resolved.
Show resolved Hide resolved
}
const stdout = await this.runCompiler(settings, flags, text, "[]");
const results = JSON.parse(stdout);
for (let i = 0, k = results.length; i < k; i++) {
Expand Down Expand Up @@ -395,6 +401,9 @@ export class LFortranCLIAccessor implements LFortranAccessor {
let stdout: string | null = null;
try {
const flags = ["--show-errors", "--continue-compilation"];
if (settings.compiler.flags !== "") {
flags.push(settings.compiler.flags);
dylon marked this conversation as resolved.
Show resolved Hide resolved
}
stdout =
await this.runCompiler(settings, flags, text, "[]", true);
if (stdout.length > 0) {
Expand Down Expand Up @@ -470,6 +479,9 @@ export class LFortranCLIAccessor implements LFortranAccessor {
"--column=" + (column + 1),
"--continue-compilation"
];
if (settings.compiler.flags !== "") {
flags.push(settings.compiler.flags);
dylon marked this conversation as resolved.
Show resolved Hide resolved
}
const stdout = await this.runCompiler(settings, flags, text, "[]");
const obj = JSON.parse(stdout);
for (let i = 0, k = obj.length; i < k; i++) {
Expand Down
1 change: 1 addition & 0 deletions server/src/lfortran-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface LFortranSettings {
maxNumberOfProblems: number;
compiler: {
lfortranPath: string;
flags: string;
dylon marked this conversation as resolved.
Show resolved Hide resolved
};
log: {
level: string;
Expand Down
Loading