Skip to content
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

Extract an expression as a non-void function #28

Open
thoni56 opened this issue Jan 10, 2018 · 2 comments
Open

Extract an expression as a non-void function #28

thoni56 opened this issue Jan 10, 2018 · 2 comments

Comments

@thoni56
Copy link
Owner

thoni56 commented Jan 10, 2018

If you select an expression, e.g. inside an if statement, and extract that as a function you get a void function. Either c-xref should recognize the text as in the context of an expression, or give you an option to extracting it as a non-void function with a return statement.

The latter is probably the only choice for C since everything is an expression and you can have expressions everywhere. It seems that in Java the distinction is made since there are both Extract Method and Extract Function, but only the latter is available for C.

@thoni56 thoni56 changed the title Extracting an expression as a function does not work Extracting an expression as a non-void function Jan 10, 2018
@thoni56 thoni56 changed the title Extracting an expression as a non-void function Extract an expression as a non-void function Jan 24, 2018
@shanemd
Copy link

shanemd commented Sep 1, 2023

This could possibly be accomplished by combining 'extract variable' on the expression, then applying 'extract' function to the new variable initialization.

I agree that being able to extract expressions in general would be a useful enhancement.

@thoni56
Copy link
Owner Author

thoni56 commented Sep 1, 2023

You are right! I haven't tried that. Perhaps that is also the way to implement the feature, by combining those functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants