Don't use struct/class/... member types when the edited text isn't a member
commit932dc71fe2edc0c58b15aface319d38855c5e612
authorJiří Techet <techet@gmail.com>
Sun, 10 Jan 2016 11:41:59 +0000 (10 12:41 +0100)
committerJiří Techet <techet@gmail.com>
Mon, 18 Jan 2016 21:55:02 +0000 (18 22:55 +0100)
treef0966d722eb3726a8962113c9b9fa0f2e879d26a
parente0122592d95f8cd5347729c3d15c05c40094edcd
Don't use struct/class/... member types when the edited text isn't a member

For instance, consider

class A {
    int a;
    int b;
}

class B {
    A c;
    void foo() {
        c.    //<---- (3)
    }
}

int main() {
    c.    //<---- (1)
    foo.c.    //<---- (2)
}

Consider cases (1) and (2) first - in the case (1) scope completion
shouldn't be performed because c isn't a global variable; however,
in case (2) it should be performed because c is a member.

To fix this, we can check whether the typed variable ('c' in this case)
is preceeded by another dot - if it is, use member tags for scope
completion; otherwise don't use them.

There's one exception from this rule - in the case (3) we are accessing
a member variable from a member function at the same scope so the
function should have access to the variable. For this we can use the
scope at the position of the cursor. It should be

B::foo

in this case, more generally ...::class_name::function_name. We need
to check if class_name exists at the given scope and if the member
variable we are trying to access is inside ...::class_name - if so,
scope completion can be performed using member tags (without explicit
invocation on a member).
src/editor.c
tagmanager/src/tm_workspace.c
tagmanager/src/tm_workspace.h