From 5e0e2f086082d1bddbc8e020eccf0d4db4b97e63 Mon Sep 17 00:00:00 2001 From: Tom Weber Date: Thu, 1 Dec 2022 16:34:00 -0500 Subject: [PATCH] fix for issue #45 --- sas_kernel/kernel.py | 85 +++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/sas_kernel/kernel.py b/sas_kernel/kernel.py index d4eeb2e..d851b62 100644 --- a/sas_kernel/kernel.py +++ b/sas_kernel/kernel.py @@ -243,50 +243,53 @@ def get_completions(self, info): else: relstart = info['start'] seg = info['line'][:relstart] - if relstart > 0 and re.match('(?i)proc', seg.rsplit(None, 1)[-1]): + try: + if relstart > 0 and re.match('(?i)proc', seg.rsplit(None, 1)[-1]): + potentials = re.findall( + '(?i)^' + info['obj'] + '.*', self.strproclist, re.MULTILINE) + return potentials + except: + pass + + lastproc = info['code'].lower()[:info['help_pos']].rfind('proc') + lastdata = info['code'].lower()[:info['help_pos']].rfind('data ') + proc = False + data = False + if lastproc + lastdata == -2: + pass + else: + if lastproc > lastdata: + proc = True + else: + data = True + + if proc: + # we are not in data section should see if proc option or statement + lastsemi = info['code'].rfind(';') + mykey = 's' + if lastproc > lastsemi: + mykey = 'p' + procer = re.search(r'(?i)proc\s\w+', info['code'][lastproc:]) + method = procer.group(0).split(' ')[-1].upper() + mykey + mylist = self.compglo[method][0] + potentials = re.findall( + '(?i)' + info['obj'] + '.+', '\n'.join(str(x) for x in mylist), re.MULTILINE) + return potentials + elif data: + # we are in statements (probably if there is no data) + # assuming we are in the middle of the code + + lastsemi = info['code'].rfind(';') + mykey = 's' + if lastproc > lastsemi: + mykey = 'p' + mylist = self.compglo['DATA' + mykey][0] potentials = re.findall( - '(?i)^' + info['obj'] + '.*', self.strproclist, re.MULTILINE) + '(?i)^' + info['obj'] + '.*', '\n'.join(str(x) for x in mylist), re.MULTILINE) return potentials else: - lastproc = info['code'].lower()[:info['help_pos']].rfind('proc') - lastdata = info['code'].lower()[:info['help_pos']].rfind('data ') - proc = False - data = False - if lastproc + lastdata == -2: - pass - else: - if lastproc > lastdata: - proc = True - else: - data = True - - if proc: - # we are not in data section should see if proc option or statement - lastsemi = info['code'].rfind(';') - mykey = 's' - if lastproc > lastsemi: - mykey = 'p' - procer = re.search(r'(?i)proc\s\w+', info['code'][lastproc:]) - method = procer.group(0).split(' ')[-1].upper() + mykey - mylist = self.compglo[method][0] - potentials = re.findall( - '(?i)' + info['obj'] + '.+', '\n'.join(str(x) for x in mylist), re.MULTILINE) - return potentials - elif data: - # we are in statements (probably if there is no data) - # assuming we are in the middle of the code - - lastsemi = info['code'].rfind(';') - mykey = 's' - if lastproc > lastsemi: - mykey = 'p' - mylist = self.compglo['DATA' + mykey][0] - potentials = re.findall( - '(?i)^' + info['obj'] + '.*', '\n'.join(str(x) for x in mylist), re.MULTILINE) - return potentials - else: - potentials = [''] - return potentials + potentials = [''] + return potentials @staticmethod def _get_right_list(s):