Eclipse PDT, PHPUnit autocomplete - eclipse

Is there a way to get PHPUnit auto-completion to work in Eclipse PDT without including the libraries in your project?

Have you tried putting the PHPUnit code on your project's include path?

How do you add a PHP framework to code completion/assist in Eclipse PDT and can the framework be added as default for all projects?
Generally speaking in Eclipse, you can add a library or framework to code assist/completion by:
Going into Project > Properties
Under PHP Include Path, pick the "Libaries" tab.
Add an "external folder" with the path to where your framework is
located.

You need to enable it.
Go to menu: Window -> Preferences. Then under PHP -> Editor -> Code Assist. From under auto activation check the enable auto activation check box (note: 200 ms default is a bit slow). You can adjust the timing.

Related

Autocomplete not working with Eclipse Oxygen Javascript project

I'm using Eclipse Oxygen (4.7) with the Eclipse Web Tools Platform installed on Ubuntu 16.04.3. Auto-completion of variables and functions only works provided that the variable or function is local to the file that I'm currently working on. Auto-completion attempts using Ctrl-Space for variables and functions that are located outside the current file result in the dialog with No Default Proposals. Also, auto-completion for var/funcs within the current file are case sensitive, otherwise no proposals are displayed (a problem that I didn't have with previous versions of eclipse).
My project is a JS project and I am using the JS perspective. Under the Source files and folder in the global scope section of the Include Path of my project, the source tab shows Included: (All). Is there something else I need to do?
As a side note, I can't correctly configure the syntax highlighting for Javascript source files successfully. Certain things work fine, but others (like local variables) refuse to use the color that I've selected. Are these all bugs?
NOTE: I'm using the Darkest Dark eclipse theme. I don't know if that has any impact on auto-completion (but seems likely it would for syntax high-lighting).
I had the same problem in Eclipse Oxygen using Ubuntu 18.03, and I fixed it doing next:
Go to Window -> Preference -> Javascript -> Editor -> Content Assist -> Advanced and put the configuration like this one
After that I was able to autocomplete Javascript code.

Cannot get Symfony2 Eclipse plugin working

I normally use PHPStorm for development, however I have noticed http://symfony.dubture.com/ plugin for eclipse that looks like it would make symfony2 development much more easy. So I wanted to give it a try.
However I for the life of me cannot get it working.
I have never used eclipse before, but here is the entire process I have gone through
Download eclipse (latest version of eclipse classic juno)
Install the symfony2 plugin (p2.dubture.com)
install eclipse web development plugin
Switch to PHP Perspective
Create symfony project at existing location
Enable javascript support
Enable twig support
Enable doctrine support
PHP Build path is correctly set as according to the FAQ on the site
I let the DLTK finish indexing my project.
I open one of my twig views, and no code assist at all. {{path(' brings up nothing {% block brings up nothing {% extends brings up nothing, etc. I do have twig syntax highlighting so I know part of it is there.
Now, I go to one of my controllers
and type in
$product = $this->getDoctrine()->getRepository("
This does bring up code assitance and lists all the available bundles. So I select my bundles, but none of my entities appear, all it says is "No default proposals"
I do get code assist for $this->get("
If I rightclick on my project, go to properties, go to builders Doctrine, Symfony, Validation, Script Builder are all present and checked.. Do not see an entry for twig though.
Here is a pastebin of my eclipse log http://pastebin.com/CA76YvKf
I have tried cleaning the projects, repeatedly starting my entire process over and over again, even on different machines and always this exact same results
I know a lot of people are using it, so I must just be doing something wrong.. If anyone here has any suggestions that would be great.
The way I do:
download eclipse (juno)
install pdt for eclipse (http://wiki.eclipse.org/PDT/Installation_3.1.x) // as you can see: 'PHP Development Tools (PDT) Runtime Feature' under 'PHP Development Tools'
create php project
contextual menu on the project > configure > add php support
install the symfony2 plugin (p2.dubture.com)
contextual menu on the project > configure > convert to symfony project
hope this helps.

Eclipse managed bean binding on pages

Neither Ctrl+click nor Ctrl+space works for beans on pages, i.e. i can't go into bean from page just moving mouse on its name and pressing Ctrl+click, and i don't get content assist when typing some element's value using bean value. All this perfectly works in eclipse 3.5, but not in eclipse 3.7, neither in JSP editor nor in HTML editor. How can i make it work?
You might need a plugin for do so. Take a look at what plugins are you starting in Preferences -> general -> startup and shutdown and compare with 3.5.
If you find that a missing plugin is needed install it. You can do so (depending on the version) by Help -> Eclipse Marketplace.
Your plugins are Help -> Install new software -> in this screen there is a link to "What is already installed"
For me I did the following and it worked:
Right Click on project -> properties
Go to Project Facets
Click on "convert to faceted form"
Check in Java, Dynamic Web Module and Java Server Faces in my case I put it Version 1.8
For Java Server Faces, click on Further Configuration Required -> and choose the proper for your case.
Apply and close.

Eclipse Indigo "Save Actions" are not being applied

I'm new to Eclipse and downloaded the following version:
Eclipse Java EE IDE for Web Developers.
Version: Indigo Release
Build id: 20110615-0604
[edit] Eclipse Platform Version 3.7
I have edited Java > Editor > Save Actions to do the following: Remove trailing white spaces on all lines, Correct indentation
When I save the .java file, those actions are not applied... is this a bug?
Found this that might be related: https://bugs.eclipse.org/bugs/show_bug.cgi?id=350475
Assuming that this relates to JavaScript files, then the related Eclipse bug could be helpful.
The problem (as I've just experienced) is that you can edit the JavaScript -> Save Actions preferences via the context menu when editing a JavaScript file, but the actions will not be run.
The solution is to right click on the project containing the .js file, and select Configure -> Convert to JavaScript project.
The bad news is that this will then will also enable Eclipse's not-so-great JavaScript validation, therefore telling you that libraries such as moment.min.js are broken.
Well for those of you who have found this topic... I did find 2 solutions, no thanks to Eclipse, other than the fact that it is open source and people can write plugins.
Eclipse Platform Version 3.7
AnyEdit - plugin that does it for you when you Save file (I believe this is what eclipse SHOULD be doing)
Go to: Window > Preferences. Then under General > Keys. Make sure drop down for Scheme: is Default and enter 'remove trailing' in the filter. You should then see "Remove Trailing Whitespace" under the command column. Bind it to your own key command.
The only drawback to #2 is that you have to actually press the key binding while editing the file, kindof like a cleanup action.
Too bad Eclipse hasn't taken the approach that ALL file types should be configurable in this way... sometimes I miss TextPad.
Old question, but at least for newer Eclipse versions there's a better solution: Go to the project properties, then to Project Facets. If it tells you that your project isn't in faceted form yet, then convert it. Afterwards (or if it already was faceted), just enable the JavaScript checkbox.
I had the same issue with Eclipse 4.4 (Luna) and this fixed it for me, the save actions are now executed on save.
Adding to jlh's answer, I also had to configure the JavaScript include path of the project to enable save actions. Before that even a manual "Clean Up ..." from the source menu wouldn't work.

How can I add a default header to my source files automatically in Eclipse?

I'm trying to figure out how I can have a comment header automatically added to all new source files in my eclipse java project. I've looked around but I haven't found a simple solution to automate this process. I gave JAutodoc a try, and even though it does allow me to specify a header I still had to tell the plugin manually to inject the header and it didn't seem very fond of my keyword-subsitution.
I'm by the way using the Maven2 plugin for Eclipse for most of my projects if that's any help.
Any tips?
Comments generation is configured in:
Main Menu -> Window -> Preferences -> Java -> Code Style -> Code Templates -> Configure generated code and comments
You can change directly the New Java files template:
Code -> New Java files -> Edit
As of Eclipse 3.6 version, it is already configured that for new Java files ${filecomment} is inserted, so it is probably better to edit it instead:
Comments -> Files -> Edit
If you want to add your comment a the top of the file (to add a copyright header), give a try to Eclipse Copyright Generator. There is a wizard that ask you what you want to include. Therefore you can add every kind of comment header.
After installation you get a new menu: Project > Apply Copyright....
In the include files field enter *.java to reduce the set of files.
see also this answer
As indicated in the comments, there is an other tool provided by the Eclipse Fundation: Eclipse Copyright Tool (as part of their releng tools)