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: link LFortran with -I #44

Closed
wants to merge 1 commit into from
Closed
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
19 changes: 14 additions & 5 deletions server/src/lfortran-accessors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ export class LFortranCLIAccessor implements LFortranAccessor {
lfortranPath);
this.logger.error(LFortranCLIAccessor.LOG_CONTEXT, err);
}

params = params.concat([this.tmpFile.name]);

let escapedCommand: string | undefined;
Expand Down Expand Up @@ -281,7 +280,11 @@ export class LFortranCLIAccessor implements LFortranAccessor {
const fnid: string = "showDocumentSymbols(...)";
const start: number = performance.now();

const flags = ["--show-document-symbols", "--continue-compilation"];
// run `echo "$(find . -type d | sed 's/^/-I/')"` and pass it as an argument to lfortran using spawnSync
// Execute the command within a shell
const find_output = spawnSync("echo $(find $(pwd) -type f -name '*.mod' -exec dirname {} \\; | sort -u | sed 's/^/-I/')", { shell: true });

const flags = ["--show-document-symbols", "--continue-compilation", find_output.stdout.toString().trim()];
const stdout = await this.runCompiler(settings, flags, text, "[]");

let symbols: SymbolInformation[];
Expand Down Expand Up @@ -333,12 +336,15 @@ export class LFortranCLIAccessor implements LFortranAccessor {

const definitions: DefinitionLink[] = [];

const find_output = spawnSync("echo $(find $(pwd) -type f -name '*.mod' -exec dirname {} \\; | sort -u | sed 's/^/-I/')", { shell: true });

try {
const flags = [
"--lookup-name",
"--line=" + (line + 1),
"--column=" + (column + 1),
"--continue-compilation"
"--continue-compilation",
find_output.stdout.toString().trim()
];
const stdout = await this.runCompiler(settings, flags, text, "[]");
const results = JSON.parse(stdout);
Expand Down Expand Up @@ -393,8 +399,9 @@ export class LFortranCLIAccessor implements LFortranAccessor {

const diagnostics: Diagnostic[] = [];
let stdout: string | null = null;
const find_output = spawnSync("echo $(find $(pwd) -type f -name '*.mod' -exec dirname {} \\; | sort -u | sed 's/^/-I/')", { shell: true });
try {
const flags = ["--show-errors", "--continue-compilation"];
const flags = ["--show-errors", "--continue-compilation", find_output.stdout.toString().trim()];
stdout =
await this.runCompiler(settings, flags, text, "[]", true);
if (stdout.length > 0) {
Expand Down Expand Up @@ -463,12 +470,14 @@ export class LFortranCLIAccessor implements LFortranAccessor {
const start: number = performance.now();

const edits: TextEdit[] = [];
const find_output = spawnSync("echo $(find $(pwd) -type f -name '*.mod' -exec dirname {} \\; | sort -u | sed 's/^/-I/')", { shell: true });
try {
const flags = [
"--rename-symbol",
"--line=" + (line + 1),
"--column=" + (column + 1),
"--continue-compilation"
"--continue-compilation",
find_output.stdout.toString().trim()
];
const stdout = await this.runCompiler(settings, flags, text, "[]");
const obj = JSON.parse(stdout);
Expand Down
Loading