Skip to content

Commit 1dc53de

Browse files
committed
Merge branch 'dev' into feature/modernise-setup
* dev: Create codeql-analysis.yml Increments version Do not include debug cmd arguments Adds unittest for autocompletion as snippets Updates formatting for fr strings Create FUNDING.yml Fix text completion for procedures
2 parents 5941f55 + 0057f62 commit 1dc53de

File tree

10 files changed

+133
-15
lines changed

10 files changed

+133
-15
lines changed

.github/FUNDING.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# These are supported funding model platforms
2+
3+
github: gnikit # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/workflows/codeql-analysis.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ dev ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ dev ]
20+
schedule:
21+
- cron: '24 7 * * 2'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'python' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37+
# Learn more about CodeQL language support at https://git.io/codeql-language-support
38+
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v2
42+
43+
# Initializes the CodeQL tools for scanning.
44+
- name: Initialize CodeQL
45+
uses: github/codeql-action/init@v1
46+
with:
47+
languages: ${{ matrix.language }}
48+
# If you wish to specify custom queries, you can do so here or in a config file.
49+
# By default, queries listed here will override any specified in a config file.
50+
# Prefix the list here with "+" to use these queries and those in the config file.
51+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
52+
53+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54+
# If this step fails, then you should remove it and run the build manually (see below)
55+
- name: Autobuild
56+
uses: github/codeql-action/autobuild@v1
57+
58+
# ℹ️ Command-line programs to run using the OS shell.
59+
# 📚 https://git.io/JvXDl
60+
61+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62+
# and modify them (or add more) to build your code if your project
63+
# uses a compiled language
64+
65+
#- run: |
66+
# make bootstrap
67+
# make release
68+
69+
- name: Perform CodeQL Analysis
70+
uses: github/codeql-action/analyze@v1

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# CHANGELONG
22

3+
## 2.1.2
4+
5+
### Fixed
6+
7+
- Fixed code autocompletion bug with f-strings
8+
([#39](https://github.com/hansec/fortran-language-server/issues/39))
9+
310
## 2.1.1
411

512
### Added

fortls/interface.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ def commandline_args(name: str = "fortls") -> argparse.ArgumentParser:
152152
group.add_argument(
153153
"--use_signature_help",
154154
action="store_true",
155-
help="Use signature help instead of subroutine/function snippets",
155+
help=(
156+
"Use signature help instead of subroutine/function snippets. This"
157+
" effectively sets --autocomplete_no_snippets"
158+
),
156159
)
157160

158161
# Hover options ------------------------------------------------------------

fortls/langserver.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ def __init__(self, conn, settings: dict):
101101
# class variable. This way the command line and the file interfaces
102102
# are always on sync, with the same default arguments
103103
for k, v in settings.items():
104+
# Do not parse command line debug arguments
105+
if k.startswith("debug_") and k != "debug_log":
106+
continue
104107
setattr(self, k, v)
105108

106109
self.sync_type: int = 2 if self.incremental_sync else 1
@@ -882,7 +885,7 @@ def get_all_references(self, def_obj, type_mem, file_obj=None):
882885
# Search through all files
883886
def_name = def_obj.name.lower()
884887
def_fqsn = def_obj.FQSN
885-
NAME_REGEX = re.compile(fr"(?:\W|^)({def_name})(?:\W|$)", re.I)
888+
NAME_REGEX = re.compile(rf"(?:\W|^)({def_name})(?:\W|$)", re.I)
886889
if file_obj is None:
887890
file_set = self.workspace.items()
888891
else:

fortls/objects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,9 @@ def get_placeholders(arg_list: list[str]):
427427
for i, arg in enumerate(arg_list):
428428
opt_split = arg.split("=")
429429
if len(opt_split) > 1:
430-
place_holders.append(f"{opt_split[0]}=${{{i+1}}}:{{{opt_split[1]}}}")
430+
place_holders.append(f"{opt_split[0]}=${{{i+1}:{opt_split[1]}}}")
431431
else:
432-
place_holders.append(f"${{{i+1}}}:{{{arg}}}")
432+
place_holders.append(f"${{{i+1}:{arg}}}")
433433
arg_str = f"({', '.join(arg_list)})"
434434
arg_snip = f"({', '.join(place_holders)})"
435435
return arg_str, arg_snip

fortls/parse_fortran.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,7 @@ def replace_vars(line: str):
13811381
for def_tmp, value in defs_tmp.items():
13821382
def_regex = def_regexes.get(def_tmp)
13831383
if def_regex is None:
1384-
def_regex = re.compile(fr"\b{def_tmp}\b")
1384+
def_regex = re.compile(rf"\b{def_tmp}\b")
13851385
def_regexes[def_tmp] = def_regex
13861386
line_new, nsubs = def_regex.subn(value, line)
13871387
if nsubs > 0:

fortls/regex_patterns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,4 @@ def src_file_exts(input_exts: list[str] = []) -> Pattern[str]:
157157
FORTRAN_FILE_EXTS.append(e.replace(".", ""))
158158
# Cast into a set to ensure uniqueness of extensions & sort for consistency
159159
# Create a regular expression from this
160-
return re.compile(fr"\.({'|'.join(sorted(set(FORTRAN_FILE_EXTS)))})?$")
160+
return re.compile(rf"\.({'|'.join(sorted(set(FORTRAN_FILE_EXTS)))})?$")

test/setup_tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def run_request(request, fortls_args: list[str] = None):
2424
sys.executable,
2525
str(root_dir / "fortls.py"),
2626
"--incremental_sync",
27-
"--use_signature_help",
2827
]
2928
if fortls_args:
3029
# Input args might not be sanitised, fix that

test/test_server.py

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from pathlib import Path
2-
31
# from types import NoneType
42
from setup_tests import (
53
path_to_uri,
@@ -233,6 +231,10 @@ def check_return(result_array, checks):
233231
if checks[0] > 0:
234232
assert result_array[0]["label"] == checks[1]
235233
assert result_array[0]["detail"] == checks[2]
234+
try:
235+
assert result_array[0]["insertText"] == checks[3]
236+
except KeyError:
237+
pass
236238

237239
def comp_request(file_path, line, char):
238240
return write_rpc_request(
@@ -296,15 +298,23 @@ def comp_request(file_path, line, char):
296298
file_path = test_dir / "completion" / "test_vis_mod_completion.f90"
297299
string += comp_request(file_path, 12, 16)
298300
string += comp_request(file_path, 12, 24)
299-
errcode, results = run_request(string)
301+
errcode, results = run_request(string, ["--use_signature_help"])
302+
assert errcode == 0
303+
304+
string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir)})
305+
file_path = test_dir / "test_prog.f08"
306+
string += comp_request(file_path, 12, 6)
307+
errcode, res = run_request(string)
300308
assert errcode == 0
309+
results.extend(res[1:])
310+
301311
#
302312
exp_results = (
303313
# test_prog.f08
304-
[1, "myfun", "DOUBLE PRECISION FUNCTION myfun(n, xval)"],
305-
[9, "glob_sub", "SUBROUTINE glob_sub(n, xval, yval)"],
306-
[1, "bound_nopass", "SUBROUTINE bound_nopass(a, b)"],
307-
[1, "bound_pass", "SUBROUTINE bound_pass(arg1)"],
314+
[1, "myfun", "DOUBLE PRECISION FUNCTION myfun(n, xval)", "myfun"],
315+
[9, "glob_sub", "SUBROUTINE glob_sub(n, xval, yval)", "glob_sub"],
316+
[1, "bound_nopass", "SUBROUTINE bound_nopass(a, b)", "bound_nopass"],
317+
[1, "bound_pass", "SUBROUTINE bound_pass(arg1)", "bound_pass"],
308318
[1, "stretch_vector", "TYPE(scaled_vector)"],
309319
[6, "scale", "TYPE(scale_type)"],
310320
[2, "n", "INTEGER(4)"],
@@ -337,7 +347,12 @@ def comp_request(file_path, line, char):
337347
[10, "READ", "STATEMENT"],
338348
[11, "READ", "STATEMENT"],
339349
# subdir/test_generic.f90
340-
[4, "my_gen", "SUBROUTINE my_gen(self, a, b)"],
350+
[
351+
4,
352+
"my_gen",
353+
"SUBROUTINE my_gen(self, a, b)",
354+
"my_gen(${1:self}, ${2:a}, ${3:b})",
355+
],
341356
# subdir/test_inherit.f90
342357
[1, "val", "REAL(8)"],
343358
# subdir/test_rename.F90
@@ -352,6 +367,14 @@ def comp_request(file_path, line, char):
352367
# completion/test_vis_mod_completion.f90
353368
[1, "some_var", "INTEGER"],
354369
[3, "length", "INTEGER"],
370+
# test_prog.f08, completion without signature_help
371+
# returns the entire completion as a snippet
372+
[
373+
1,
374+
"myfun",
375+
"DOUBLE PRECISION FUNCTION myfun(n, xval)",
376+
"myfun(${1:n}, ${2:xval})",
377+
],
355378
)
356379
assert len(exp_results) + 1 == len(results)
357380
for i in range(len(exp_results)):

0 commit comments

Comments
 (0)