Skip to content

Commit 4c85449

Browse files
committed
add fortran keywords autocompletion
1 parent 5f39193 commit 4c85449

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/lib/helper.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,28 @@ export const intrinsics = [
2222
"SYSTEM_CLOCK", "TAN", "TANH", "THIS_IMAGE", "TIME", "TIME8", "TINY", "TRAILZ", "TRANSFER", "TRANSPOSE", "TRIM", "TTYNAM", "UBOUND", "UCOBOUND", "UMASK", "UNLINK", "UNPACK", "VERIFY", "XOR"];
2323

2424

25-
export const FORTRAN_KEYWORDS = ["FUNCTION", "MODULE", "SUBROUTINE", "CONTAINS", "USE","KIND", "DO", "IF", "ELIF","END", "IMPLICIT"];
25+
export const FORTRAN_KEYWORDS = ["FUNCTION", "MODULE", "SUBROUTINE", "CONTAINS", "USE", "KIND", "DO", "IF", "ELIF", "END", "IMPLICIT"];
2626

2727
export const isIntrinsic = (keyword) => {
2828
return intrinsics.findIndex(intrinsic => intrinsic === keyword.toUpperCase()) !== -1;
2929
}
3030

3131

32-
interface Doc{
32+
interface Doc {
3333
keyword: string;
3434
docstr: string;
3535
}
3636

3737

3838
export const loadDocString = (keyword) => {
3939
keyword = keyword.toUpperCase();
40-
let filepath = __dirname + "/../docs/" + keyword + ".json";
40+
let filepath = __dirname + "/../docs/" + keyword + ".json";
4141
let docstr = fs.readFileSync(filepath).toString();
42-
let doc:Doc = JSON.parse(docstr);
42+
let doc: Doc = JSON.parse(docstr);
4343
return doc.docstr;
4444

4545
}
46-
export const _loadDocString = (keyword:string) => {
46+
export const _loadDocString = (keyword: string) => {
4747

4848
keyword = keyword.toUpperCase();
4949

@@ -80,30 +80,30 @@ export const _loadDocString = (keyword:string) => {
8080
return docText;
8181
}
8282

83-
export const getIncludeParams = (paths: string[]) => {
84-
return paths.map(path => "-I " + path).join(" ");
85-
}
83+
export const getIncludeParams = (paths: string[]) => {
84+
return "-I " + paths.join(" ");
85+
};
8686

8787

8888

8989
export function isPositionInString(document: vscode.TextDocument, position: vscode.Position): boolean {
90-
let lineText = document.lineAt(position.line).text;
91-
let lineTillCurrentPosition = lineText.substr(0, position.character);
90+
let lineText = document.lineAt(position.line).text;
91+
let lineTillCurrentPosition = lineText.substr(0, position.character);
9292

93-
// Count the number of double quotes in the line till current position. Ignore escaped double quotes
94-
let doubleQuotesCnt = (lineTillCurrentPosition.match(/\"/g) || []).length;
95-
let escapedDoubleQuotesCnt = (lineTillCurrentPosition.match(/\\\"/g) || []).length;
93+
// Count the number of double quotes in the line till current position. Ignore escaped double quotes
94+
let doubleQuotesCnt = (lineTillCurrentPosition.match(/\"/g) || []).length;
95+
let escapedDoubleQuotesCnt = (lineTillCurrentPosition.match(/\\\"/g) || []).length;
9696

97-
doubleQuotesCnt -= escapedDoubleQuotesCnt;
98-
return doubleQuotesCnt % 2 === 1;
97+
doubleQuotesCnt -= escapedDoubleQuotesCnt;
98+
return doubleQuotesCnt % 2 === 1;
9999
}
100100

101101

102102
let saveKeywordToJson = (keyword) => {
103-
let doc = _loadDocString(keyword);
104-
let docObject = JSON.stringify({"keyword": keyword, "docstr": doc});
105-
fs.appendFile( "src/docs/" + keyword + ".json", docObject, function (err) {
106-
if (err) throw err;
107-
console.log('Saved!');
108-
});
103+
let doc = _loadDocString(keyword);
104+
let docObject = JSON.stringify({ "keyword": keyword, "docstr": doc });
105+
fs.appendFile("src/docs/" + keyword + ".json", docObject, function (err) {
106+
if (err) throw err;
107+
console.log('Saved!');
108+
});
109109
};

0 commit comments

Comments
 (0)