Skip to content

Commit

Permalink
fix: queryMember - #eq? Unmatched capture warning
Browse files Browse the repository at this point in the history
It seems this was checked multiple times.

Change-Id: I379d028f27c2d67051628ebc7664ffa359d6aee0
Reviewed-on: https://codereview.kdab.com/c/knut/+/140941
Reviewed-by: Nicolas Arnaud-Cormos <nicolas@kdab.com>
Tested-by: Continuous Integration <build@kdab.com>
  • Loading branch information
LeonMatthesKDAB committed Apr 30, 2024
1 parent 880089b commit 65b82d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
12 changes: 6 additions & 6 deletions docs/API/script/cppdocument.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ If an empty string is provided as the `signature`, all overloads of the function
#### <a name="gotoBlockEnd"></a>int **gotoBlockEnd**(int count)

Moves the cursor to the end of the block it's in, and returns the new cursor position.
A block is definied by {} or () or [].
A block is defined by {} or () or [].
Does it `count` times.

#### <a name="gotoBlockStart"></a>int **gotoBlockStart**(int count)

Moves the cursor to the start of the block it's in, and returns the new cursor position.
A block is definied by {} or () or [].
A block is defined by {} or () or [].
Does it `count` times.

#### <a name="insertCodeInMethod"></a>**insertCodeInMethod**(string methodName, string code, Position insertAt)
Expand Down Expand Up @@ -264,7 +264,7 @@ Returns the list of function calls to the function `functionName`, no matter how
The returned QueryMatch instances will have the following captures available:
- `call` - The entire call expresssion
- `call` - The entire call expression
- `name` - The name of the function (the text will be equal to functionName)
- `argument-list` - The entire list of arguments, including the surroundg parentheses `()`
- `arguments` - Each argument provided to the function call, in order, excluding any comments
Expand Down Expand Up @@ -343,13 +343,13 @@ The `include` string should be either `<foo.h>` or `"foo.h"`, it will returns fa
#### <a name="selectBlockEnd"></a>int **selectBlockEnd**()
Selects the text from current cursor position to the end of the block, and returns the new cursor position.
A block is definied by {} or () or [].
A block is defined by {} or () or [].
Does it `count` times.
#### <a name="selectBlockStart"></a>int **selectBlockStart**()
Selects the text from current cursor position to the start of the block, and returns the new cursor position.
A block is definied by {} or () or [].
A block is defined by {} or () or [].
Does it `count` times.
#### <a name="selectBlockUp"></a>int **selectBlockUp**()
Expand All @@ -358,7 +358,7 @@ Does it `count` times.
Since: Knut 1.1
Selects the text of the block the cursor is in, and returns the new cursor position.
A block is definied by {} or () or [].
A block is defined by {} or () or [].
Does it `count` times.
#### <a name="toggleSection"></a>**toggleSection**()
Expand Down
19 changes: 9 additions & 10 deletions src/core/cppdocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ Core::QueryMatchList CppDocument::queryFunctionCall(const QString &functionName,
*
* The returned QueryMatch instances will have the following captures available:
*
* - `call` - The entire call expresssion
* - `call` - The entire call expression
* - `name` - The name of the function (the text will be equal to functionName)
* - `argument-list` - The entire list of arguments, including the surroundg parentheses `()`
* - `arguments` - Each argument provided to the function call, in order, excluding any comments
Expand Down Expand Up @@ -746,9 +746,7 @@ Core::QueryMatch CppDocument::queryMember(const QString &className, const QStrin
auto classQuery = queryClassDefinition(className);

// clang-format off
auto queryMemberName = QString(R"EOF(
(field_identifier) @name (#eq? @name "%1")
)EOF").arg(memberName);
auto queryMemberName = QString("(field_identifier) @name");
// handle Type, Type *, Type &, Type *&, Type &* and Type **
auto queryString = QString(R"EOF(
(field_declaration
Expand All @@ -758,8 +756,9 @@ Core::QueryMatch CppDocument::queryMember(const QString &className, const QStrin
declarator: (_ %1 )
declarator: %1
]
(#eq? @name "%2")
) @member
)EOF").arg(queryMemberName);
)EOF").arg(queryMemberName, memberName);
// clang-format on

auto matches = classQuery.queryIn("body", queryString);
Expand All @@ -779,7 +778,7 @@ Core::QueryMatch CppDocument::queryMember(const QString &className, const QStrin
/*!
* \qmlmethod int CppDocument::gotoBlockStart(int count)
* Moves the cursor to the start of the block it's in, and returns the new cursor position.
* A block is definied by {} or () or [].
* A block is defined by {} or () or [].
* Does it `count` times.
*/
int CppDocument::gotoBlockStart(int count)
Expand All @@ -798,7 +797,7 @@ int CppDocument::gotoBlockStart(int count)
/*!
* \qmlmethod int CppDocument::gotoBlockEnd(int count)
* Moves the cursor to the end of the block it's in, and returns the new cursor position.
* A block is definied by {} or () or [].
* A block is defined by {} or () or [].
* Does it `count` times.
*/
int CppDocument::gotoBlockEnd(int count)
Expand All @@ -817,7 +816,7 @@ int CppDocument::gotoBlockEnd(int count)
/*!
* \qmlmethod int CppDocument::selectBlockStart()
* Selects the text from current cursor position to the start of the block, and returns the new cursor position.
* A block is definied by {} or () or [].
* A block is defined by {} or () or [].
* Does it `count` times.
*/
int CppDocument::selectBlockStart(int count)
Expand All @@ -842,7 +841,7 @@ int CppDocument::selectBlockStart(int count)
/*!
* \qmlmethod int CppDocument::selectBlockEnd()
* Selects the text from current cursor position to the end of the block, and returns the new cursor position.
* A block is definied by {} or () or [].
* A block is defined by {} or () or [].
* Does it `count` times.
*/
int CppDocument::selectBlockEnd(int count)
Expand All @@ -868,7 +867,7 @@ int CppDocument::selectBlockEnd(int count)
* \qmlmethod int CppDocument::selectBlockUp()
* \since 1.1
* Selects the text of the block the cursor is in, and returns the new cursor position.
* A block is definied by {} or () or [].
* A block is defined by {} or () or [].
* Does it `count` times.
*/
int CppDocument::selectBlockUp(int count)
Expand Down

0 comments on commit 65b82d3

Please sign in to comment.