Skip to content

Commit

Permalink
Merge pull request #613 from kkoomen/feature/fix-cpp-default-param
Browse files Browse the repository at this point in the history
fix(cpp): resolve default param case
  • Loading branch information
kkoomen authored Aug 15, 2023
2 parents a9148bc + 5c87d7b commit 88fdd3a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion helper/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions helper/src/cpp/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,17 @@ impl<'a> CppParser<'a> {
}
}
}

if node.kind() == "identifier" {
param.insert("name".to_string(), Value::String(self.get_node_text(&node)));
}
});

let name = node
.children(&mut node.walk())
.filter(|node| node.kind() == "identifier")
.next()
.and_then(|node| Some(self.get_node_text(&node)));
if name.is_some(){
param.insert("name".to_string(), Value::String(name.unwrap()));
}

params.push(Value::Object(param));
});

Expand Down
20 changes: 20 additions & 0 deletions test/filetypes/cpp/functions.vader
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,23 @@ Expect cpp (generated comment with @brief and @param tag):
int* fun1(int a,int b,int c){
return nullptr;
}

# ==============================================================================
# Functions with a default value
# ==============================================================================
Given cpp (function with a default value):
int y = 5;
void foo( int x = y );

Do (trigger doge):
:2\<CR>
\<C-d>

Expect cpp (generated comment with @brief and @param tag):
int y = 5;
/**
* @brief [TODO:summary]
*
* @param[[TODO:direction]] x [TODO:description]
*/
void foo( int x = y );

0 comments on commit 88fdd3a

Please sign in to comment.