Eclipse: Selectively convert to lambda expression - eclipse

I can configure Eclipse's code "Clean Up" to convert existing code expressions to lamba expressions if possible.
I am trying to find a way to manually trigger this, if possible only for the selected subset of my type.
I do not want to run the complete code cleanup, only the conversion to lambda expressions, and, if possible, also not for the complete type, but only for the selected part of it.

Clean-ups are intended for mass operations. Since you don't seem to be interested in mass operation, you could consider using quick assist (Ctrl+1) on individual expressions.
EDIT: The quick assist is available since Eclipse Luna, see http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2FwhatsNew%2Fjdt_whatsnew.html - second entry "Migrate anonymous class creations to lambda expressions and back".
Or: run the cleanup on a given file and the use the compare editor (against latest from git or similar) to only accept some selected changes.

Related

Filter Eclipse CDT textual search results by program-structural features

I want to use Eclipse CDT to search for all occurrences of regular expresion, say foo(_bar_)*baz - in the bodies/bodies and declarations of functions/methods meeting a certain criterion. For the example let's make it all functions/methods named ignore_me (but within all classes and namespaces).
Is that possible somehow?
I'm not aware of a way to do this sort of search in Eclipse CDT.
Clang's AST matchers provide a rich domain-specific language for expressing queries like yours (and many other kinds), but using them requires writing code (in a clang plugin or standalone clang-based tool). It may be relatively straightforward to write a simple tool that allows you to write a query and searches a codebase for matches. I'm not sure whether such a tool is already available.

Notepad++ and autocompletion

I'm using mainly Notepad++ for my C++ developing and recently i'm in need for some kind of basic autocompletion, nothing fuzzy, just want to type some letters and get my function declaration instead of having a manual opened all of the time..
The integrated autocompletion feature of my Notepad++ version (6.9.2) gives the declaration of basic C functionality like say fopen and parses my current file user defined functions, but without declaration.
I guess it's normal for a text editor to not give easily such information since it has nothing to parse i.e. other files where your declarations are (as it's not an IDE), but i don't want either to mess again with MSVC just for the sake of autocomplete.
Is there an easy, not so-hackish way to add some basic C++ and/or user defined autocomplete?
UPDATE
Adding declarations the "hard way" in some file cpp.xml is a no-no for me as i have a pretty big base of ever changing declarations. Is there a way to just input say some list of h/cpp files and get declarations? or this falls into custom plugin area ?
Edit the cpp.xml file and add all the keywords and function descriptions you'd like. Just make sure you add them in alphabetical order or they will not show up.
Another option is to select Function and word completion in the Auto-Completion area of the Settings-->Preferences dialog. NPP will suggest every "word" in the current file that starts with the first N letters you type (you choose a value for N in the Auto-Completion controls).

Eclipse Contentassist full abbrev only

When I like to create a new variable of type ImageObserver and the line starts like this:
IO
and I press Ctrl+Space , I get a couple of wrong suggestions! Suggestions for abbrevs that do not fully match!
Eclipse's content assist suggestions are:
IOException (no! full abbrev is IOE, not IO!)
IOError (no! full abbrev is IOE too, but not IO!)
IndexOutOfBoundsException (no! full abbrev is IOOBE, not IO!)
ImageObserver (yes! full abbrev is IO)
ImageOutputStream (no! full abbrev is IOS, not IO!)
How to get rid of all the other non-full-matching-abbrevs?
Keep in mind that the completion proposals fall into a bunch of categories (ie, lots of different sources of potential matches). Your example text, IO, can logically be interpreted as either a camel-case abbreviation (such as ImageObserver) or as the start of a class name (such as IOException), or even as a camel-case-starts-with match (such as ImageOutputStream, whose abbreviation starts with IO).
I don't know of a tool that's clairvoyant enough to know which of those you want given such a small input. Eclipse, by default, uses a "relevance" ordering for completion proposals and it weighs "starts with" matches ahead of camel-case matches (rightly so, in my opinion). There's no publicly exposed way to change that weighting algorithm, that I know of.
If these are classes or packages that you simply never want to see in Content-Assist, you can define Type Filters to exclude them. In Preferences, go to Java > Appearance > Type Filters to do so. But be aware that Type Filters apply to the entire workspace and in multiple places in the UI, not just Content Assist completion proposals.
You really want IOException to be excluded on auto-complete when IO is typed even though IOException starts with IO?
If so, this sounds like a feature request, but unless you are ready to contribute I can't see it getting added anytime soon.
Contributing
If you are interested in contributing, you need to write a Java Completion Proposal Computer. Once you do that, you can enable only your proposer in the preferences (Java / Editor / Content Assist / Advanced ).
You can even bind your special completer to its own Keyboard Short-cut so you can get "full abbrev" completions only.
Here is a screenshot of my binding of Template Proposals to Ctrl+4 so with a single key combination I can get quickly get them all.
Code Recommenders
I also recommend reading about Code Recommenders, the project adds significantly more sophisticated code completion to Eclipse.
I have raised a bug with Eclipse to see if sorting perfect Camel Case matches could be on the cards.

Passing macros with coverity exe files while using them through cmd

I am new to Coverity,I am using it from the command prompt with it's .exe files.So I want to pass specific macros in coverity cov-build.exe so that those macros will be implemented when cov-emit.exe(when it is called by cov-build.exe) is parsing the .c files.Till now I have tried the below stated configurations.
code-build.exe Intermediate_folder --delete-stale-tus --preprocessor-first --return-emit-failure "My_bat_file" -- -D My_macro_name=my_macro_body
So any help will be much be appreciated.I am stuck on this.
Thanks and regards,
Newbie_in
cov-build wraps your existing build command, monitors it and spawns parallel compiler invocations in order to understand your code. These parallel compiler invocations will see the same command line being passed to your own compiler.
So if you want this define to take effect for your compiler as well as Coverity's then you should simply just add it to your build the way you would normally and Coverity will see it.
If you want to add a define that only Coverity's compiler can see, this is best done with within the config for your compiler.
You can either edit the config directly (add
<append_arg>-Dmy_macro_name=my_macro_body</append_arg>
after the <begin_command_line_config> line), or re-configure using --xml-option.
For example, if you're using the shortcut gcc config this would look like this:
$ cov-configure --gcc --xml-option=append_arg>-Dmy_macro_name=my_macro_body.
I noticed you're using --preprocess-first on the cov-build command line - I recommend against this, as it destroys XREFs making it much more difficult to browse defect information, as well as makes the analysis unable to find some defects (i.e. ones that are due to macros). --preprocess-next behaves like --preprocess-first and will only fire if the initial compilation attempt fails, so if you're using --preprocess-first to work around compilation issues, I strongly recommend using --preprocess-next instead.
If you do have compilation issues, it's always good to report them (along with a reproducer) to Coverity support so that they can be fixed in future releases.

Eclipse code completion problem

why doesn't eclipse match the argument while doing code completion. In the following example it should have automatically matched the throwable. In stead it shows arg1 as the first option.
The autocomplete options in Eclipse for auto-completed method arguments, start with the parameter names found in the source distribution (that contains the class with the method). If no source distribution is available, then it will use the parameter names as indicated in the binary distributions i.e. in the compiled byte code. This is the default behavior
If you want to change this behavior of inserting parameter names from source code or binaries to inserting the best guessed arguments (including local variables), then you can configure the auto-complete options of Eclipse to do so, as shown in the following screenshot:
This will produce the desired result of automatically displaying the options containing the list of best-guessed arguments. This also seems to avoid suggesting parameter names:
I guess arg1 is thing you already typed. So the proposal eclipse can provide is trying to find something which start from arg1.
So it puts it as the first choice.
You can type t , and try Alt+/ , to see if this is the reason.