KnoP-01 / krl-for-vim

Vim plugins (syntax, indent and more) for Kuka Robot Language
MIT License
8 stars 0 forks source link

avoid false positives of gd on a variable type if variable type is not declared as STRUC #3

Open KnoP-01 opened 6 years ago

KnoP-01 commented 6 years ago

gd can look up declarations of user defined structures. However, it displays false positives if the structure declaration is not present in the current source tree, but a variable declaration is present which comes with more then one word (not only DECL but also GLOBAL and/or CONST) in front of the type.

e.g. in the MsgLib.src

A struct is used called KrlMsgOpt_T. This appear to be an KSS-internal type. So the declaration of this struc is not visible. But gd finds (as false positive) a declaration of a variable of this type:

DECL GLOBAL CONST KRLMSGOPT_T Opt_NOVLSTO...

The pattern to find declarations is defined in

ftplugin\krl.vim

in function

function <SID>KrlGoDefinition()

as

let l:declPrefix = 

.

It's quite complicate already. But I don't get this false positive out of the way.

A more simple example of the false positive would be:

In a line like this

DECL CHAR DMY[3]

hitting gd on the "CHAR", it will find variable declarations which look like this:

DECL GLOBAL CHAR varname="a"

.

PS: If the STRUC declaration is present gd does work correctly with the pattern as it is. So the pattern is not fundamentaly incorrect.