Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scope: Improved evaluation on-hover #823

Merged
merged 1 commit into from
Jul 11, 2019

Conversation

lpaulsen93
Copy link
Contributor

Scope automatically evaluates an expression if the mouse pointer is hovered over it. But before this change it only evaluated words. E.g. if the mouse was hovered over structa->item1 then scope would have evaluated structa or itemb depending on the exact position of the mouse pointer. With this change it will instead evaluate the value of structa->item1.

@b4n
Copy link
Member

b4n commented Feb 20, 2019

Just from the top of my head, wouldn't it be better to evaluate structa when over structa, and structa->item1 when over item1? I think it's reasonably useful to be able to get the evaluation of a part of the expression, here the parent.

Also if you wanted to be thorough, the C and C++ syntax allows for any kind of spaces between structa, -> and item1 😁

@lpaulsen93
Copy link
Contributor Author

Just from the top of my head, wouldn't it be better to evaluate structa when over structa, and structa->item1 when over item1?

Yes, good idea. I'll try to implement that.

Also if you wanted to be thorough, the C and C++ syntax allows for any kind of spaces between structa, -> and item1 😁

True. But and it might even include linebreaks I think. And for C++ we might need to allow :: for static class members.

@lpaulsen93
Copy link
Contributor Author

@b4n, @elextr: I just pushed another improvement for the on-hover-evaluation of expressions. It works like suggested by b4n and also allows spaces but it does only work on the current line.

I wanted to write unit tests for the function that parses the current line and extracts the expression to evaluate. But my unit tests don't build. I have setup an extra folder tests. In it are the test files. If I try to build the tests via make check then compilation for the scope unit tests fails because check.h cannot be found. Another thing is that if I remove the comments from scope/tests/Makefile.am then none of the tests source code files is compiled. It now looks like this:

#if UNITTESTS

include $(top_srcdir)/build/vars.build.mk
plugin = scope

check_PROGRAMS = scope-check

scope_check_SOURCES  = unittests.c utils_test.c
scope_check_CPPFLAGS = -DTEST
scope_check_CFLAGS   = $(GEANY_CFLAGS) -DUNITTESTS
scope_check_LDADD    = @GEANY_LIBS@ $(INTLLIBS) @CHECK_LIBS@

TESTS = $(check_PROGRAMS)

#endif

So it seems that I have overseen one magic autotools switch which is still missing. Any help would be highly appreciated.

@frlan frlan requested a review from b4n March 31, 2019 14:52
@lpaulsen93
Copy link
Contributor Author

So it seems that I have overseen one magic autotools switch which is still missing. Any help would be highly appreciated.

Junk! I simply forgot to install check on my machine (embarrassing). For anyone reading this: make sure you have check installed if you want to write unit tests. Otherwise you might get an error message like this:

gp-check-h-missing

If you execute the command ./autogen.sh it will show if check is present/if unit tests can be created:

gp-unittests-no

In case check is installed it will show Unit tests: yes. If not, building tests via make check will fail.

@lpaulsen93 lpaulsen93 force-pushed the scope-improve-on-hover-evaluate branch from b4b7380 to f8ee04b Compare May 8, 2019 19:26
Scope automatically evaluates an expression if the mouse pointer is hovered over it.
But before this change it only evaluated words. E.g. if the mouse was hovered over
"structa->item1" then scope would have evaluated "structa" or "item1" depending on
the exact position of the mouse pointer. With this change it will instead evaluate
the value of "structa" if the mouse pointer is over "structa". If the mouse pointer
is over "item1" then the expression "structa->item1" will be evaluated.
@lpaulsen93 lpaulsen93 force-pushed the scope-improve-on-hover-evaluate branch from f8ee04b to 648224a Compare May 8, 2019 19:30
@lpaulsen93
Copy link
Contributor Author

This looks quite good to me now. Unit tests worked and were run successfully on my machine. Unfortunately scope isn't build in Travis CI as VTE support is missing.

The array in scope/src/tests/utils_test.c shows which situations are handled.

@lpaulsen93
Copy link
Contributor Author

@frlan: I would also like to have this one in milestone 1.36.0 - if no one objects.

@lpaulsen93
Copy link
Contributor Author

@b4n, @frlan: If no one objects I will merge this soon also.

@lpaulsen93
Copy link
Contributor Author

No complaints, so I merge this now.

@lpaulsen93 lpaulsen93 merged commit 42f0fc9 into geany:master Jul 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants