8000 fix(cpp): resolve default param case by kkoomen · Pull Request #613 · kkoomen/vim-doge · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(cpp): resolve default param case #613

8000 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

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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