Bug 235685 - CMake completion stops working properly after a multiline command
Summary: CMake completion stops working properly after a multiline command
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Build tools: CMake (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-29 02:55 UTC by Nicolás Alvarez
Modified: 2011-03-08 03:21 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolás Alvarez 2010-04-29 02:55:46 UTC
Version:           4.0.0 (using KDevPlatform 1.0.0) (using 4.3.4 (KDE 4.3.4), Debian packages)
Compiler:          cc
OS:                Linux (x86_64) release 2.6.32-3-amd64

In CMake files, after a multi-line function call, code completion stops working properly.

To reproduce:

Create an empty .cmake file. Press Ctrl-Space. The list of CMake commands appears.

Add this line to the file:
add_executable(foo foo.cpp)

Move cursor to end of file and press Ctrl-Space. A list of commands appears.

Now change the add_executable call to be multi-line:
add_executable(foo
    foo.cpp
)

Move cursor to end of file and press Ctrl-Space. A list of paths or variables will appear, because KDevelop thinks the cursor is still inside the add_executable command.

It's probably incorrect logic for setting m_inside in CMakeCodeCompletionModel::completionInvoked.
Comment 1 Nicolás Alvarez 2010-04-29 05:27:32 UTC
completionInvoked is doing its own half-assed attempt at parsing, searching for balanced parentheses. It would be hard to get that right in all cases, including parentheses in comments or string literals.

The file was already tokenized, parsed, and converted into an AST. Why not use that instead of searching for tokens here again? I thought of looking at the ranges in CMakeFunctionDesc to know if the cursor is inside a function or not.

But it looks like the CMakeFunctionDesc go away after initial parsing, or at least they aren't easily accessible from completionInvoked; and either way I now notice the fatal flaw in my plan: CMake files are *not* re-parsed during typing...
Comment 2 Aleix Pol 2011-03-08 03:21:47 UTC
Git commit d4aeab4ae4ddca67c5d337bcbf08ca611d949893 by Aleix Pol.
Committed on 08/03/2011 at 02:43.
Pushed by apol into branch '4.2'.

Properly figure out if we're in a command or not.

BUG: 235685

M  +13   -3    projectmanagers/cmake/cmakecodecompletionmodel.cpp     

http://commits.kde.org/kdevelop/d4aeab4ae4ddca67c5d337bcbf08ca611d949893