Skip to content

Commit 88fdd3a

Browse files
authored
Merge pull request #613 from kkoomen/feature/fix-cpp-default-param
fix(cpp): resolve default param case
2 parents a9148bc + 5c87d7b commit 88fdd3a

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

helper/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

helper/src/cpp/parser.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,17 @@ impl<'a> CppParser<'a> {
160160
}
161161
}
162162
}
163-
164-
if node.kind() == "identifier" {
165-
param.insert("name".to_string(), Value::String(self.get_node_text(&node)));
166-
}
167163
});
168164

165+
let name = node
166+
.children(&mut node.walk())
167+
.filter(|node| node.kind() == "identifier")
168+
.next()
169+
.and_then(|node| Some(self.get_node_text(&node)));
170+
if name.is_some(){
171+
param.insert("name".to_string(), Value::String(name.unwrap()));
172+
}
173+
169174
params.push(Value::Object(param));
170175
});
171176

test/filetypes/cpp/functions.vader

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,23 @@ Expect cpp (generated comment with @brief and @param tag):
8888
int* fun1(int a,int b,int c){
8989
return nullptr;
9090
}
91+
92+
# ==============================================================================
93+
# Functions with a default value
94+
# ==============================================================================
95+
Given cpp (function with a default value):
96+
int y = 5;
97+
void foo( int x = y );
98+
99+
Do (trigger doge):
100+
:2\<CR>
101+
\<C-d>
102+
103+
Expect cpp (generated comment with @brief and @param tag):
104+
int y = 5;
105+
/**
106+
* @brief [TODO:summary]
107+
*
108+
* @param[[TODO:direction]] x [TODO:description]
109+
*/
110+
void foo( int x = y );

0 commit comments

Comments
 (0)