To create yml file in eclipse - eclipse

I would like to create buildspec.yml file in eclipse. I have downloaded yaml editor and ydit from eclipse market place. How to create yaml file in src code. i could see only class and other files. not yaml. Please help on this

It's just normal file text, Right click your wanted project -> New -> Other -> File.
If you need more support you could install Yedit from Eclipse Market.
YEdit is an Eclipse editor for editing YAML files. It has the following features:
Syntax highlighting
Syntax checking
Content outline
Templates
Various text editing support like auto-indenting and toggling of comments.
Symfony compatibility mode. * Source formatting (experimental)

Use Right-click > New > Other > File and make sure its extension is .yaml or .yml.
PS: I suggest you try https://marketplace.eclipse.org/content/eclipse-wild-web-developer-web-development-eclipse-ide instead of Yedit. It's a better alternative IMO.

Related

Does STS 4 has yaml editor in build

I have downloaded latest STS 4 for windows 10 but for some reason its not detecting yml formatting errors. Do I need to include any specific plugins
There is a YAML editor but i personally dont like it.
Therefore i would like to recommend the Yaml Editor.
In STS go to help > eclipse marketplace
Find: yaml [enter]
Install Yaml Editor 1.4.2
If there is a warning just select Install anyway and after that restart STS.
For the first time make sure to open the .yml file with the Yaml Editor by using open with > Yaml Editor
STS 4 does not have a dedicate yaml editor. Instead it uses the 'Generic Text Editor' from Eclipse together with textmate grammar for Yaml files.
These are setup to be used with Spring Boot 'application.yml' and Cloud Foundry "manifest.yml" files explicitly. For those specific cases there is also special support for generating completions and validations specifically for those type of yaml files.
For general .yml files there is no built-in support.
I'm not sure exactly what types of files you are trying to edit, and what types of warnings or errors you were expecting. So it's hard to give much/any specific advice than this.

how can I make the internal editor the default editor in eclipse

I want the default edior to be the internal editor and not the system editor.
I have it configured in window->preferences->file associations to use default internal xml editor for *.xml yet eclipse always tries to open files with OS system editor. How can I prevent this?
The editor type is mapped to file type; you can do this on a per-workspace (global) or per-project basis.
It should be pretty much as simple as this:
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.wst.xmleditor.doc.user%2Ftopics%2Ftxprefs.html
Go into "Help, Install Software, What is already installed?" and make sure you have "Eclipse XML Editors and Tools" installed. You you don't, then get it.
Finally, create a new, "clean" project, add an XML file, and verify it works correctly
I found this question but the answers didn't help me, so I continued searching and found the answer here http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-51.xhtml
Basically, in the Preferences, General > Editors > File Associations, then define your file types (if not already there), and select an editor.
Right Click on File from Project,
Select Open with ....
Select your editor

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)

Eclipse autocomplete not working in some Java files

I have noticed that autocomplete is not working in some of java files in Eclipse.
Also, the files where autocomplete is not working, display a hollow "J" as the icon for the Java file. The files where autocomplete is working, icon for java file is a filled "J"
I am wondering if someone can point out what went wrong all of suddent, why the change in icons and why autocomplete and syntax highlighting is turned-off in the files with a hollow "J" icon?
Thanks.
update
Basically, I was doing what VonC has suggested but Eclipse was not refreshing that it why I was thinking that VonC's suggestion isn't working, after doing a refresh, the problem resolved.
Since this question is highly ranked on Google, I will add a solution to fix general auto complete issue, not for 'hollow J' ones.
Try Window (Windows/Linux) or Eclipse (OS X) -> Preferences -> Java -> Editor -> Content Assist -> Restore Defaults
also
Content Assist -> Advanced -> Restore Defaults
some answers (restore defaults) above do not work for some adt bundle installs as of jan '13.
in those cases, go to
Window -> Preferences -> Java -> Editor -> Content Assist -> Advanced
and tick on the JAVA PROPOSAL options.
In this following picture, MyClass.java has a hollow J, because it is explicitly excluded from the sources to build:
Could you go to the properties of the project, "Java Build Path" Section, "Source" tab and see if some exclusion filter has been set ?
It is usual for instance to define:
**/Test*.java
to exclude at first building any unit-test class (when you have a large set of sources and do not want to be presented with Test classes during auto-completion, or do not want them considered during source searches).
Those with a hollow J aren't part of the build path of the project, so they can't participate in the normal build process and therefore auto-complete won't be enabled for these files (and other Java editor features!). You must add the folders with the Java files to be built to the build path using the 'source path' section of the project properties. This can be accessed by right clicking on a project in the project navigator / package explorer and going to Properties. See http://www.informit.com/articles/article.aspx?p=367962 for details.
Additionally, if the files aren't part of a Java project in the first place, you must create a project and move the files in, or put the files in an existing one. Again, make sure these file are under a source directory as described by that section of the project properties.
(source: teradata.com)
I cope with the issue by deleting the file if autocomplete does not work. Just before copying the source code. Then I have recreated the java file with the same name. Pasted the source code previously copied.
As an addendum to the #VonC answer, make sure that the Java files are part of the Inclusion pattern. I had a case where a build process was creating the project while only including .js files and not the Java files:
You can manually edit the inclusions via the Edit button. In my case, a fix was made to the build script to make it permanent.
Neither Restoring Defaults or my build path (file was already in package directory w/other files where auto-complete was working) fixed problem. Fix for me was to close the file explicitly (right click on file name in tab) and re-open. Interestingly, just re-starting Eclipse didn't work either.
Make sure you have the right directory structure. I believe that:
Hollow J icon beside Java file - will not be build
Normal J icon beside Java file - is a file to be build.
I made a mistake when I created webapp artefact. By default it does not create folder for Java, but for resources. I mistakenly put my sources there.
Have a look - see the difference.
I was able to get this fixed in Visual Studio Code, VSCode but entering crtl-shift-p and typing in clean. When I did that I ran the "Java: Clean Java Language Sever Workspace" command. This fixed my autocomplete issue for me.