Can not get variable name suggest in fields,but work in local variable name,how to fix it?
Java Variable type
Try restoring the default content assist options in Windows > Preferences > Java > Editor > Content Assist > Advanced
Below is an example of what it would look like but you might have different options checked.
Select the proposal kinds contained in the 'default' content assist list:
Other Java Proposals,
SWT Template Proposals,
Template Proposals,
Type Proposals
You can try selecting java proposal(Task-Focused) or just using restore default option.
Related
Let me start of saying that I'm a beginner and don't know much about Github and Java. I'm also using Netbeans. Right now I'm doing the Helsinki MOOC Java Open Course that some of you might be familiar with. I could commit the code and upload to Github easily, but then I noticed that the Author name in Netbeans was different from my Github name and I tried to change this by changing the name in Git.properties file to the same name as on Github, and now I get errors everytime I try to upload new code to Github, even though I have tried reinstalling Netbeans and deleting the git.properties file. To make things easier for you, check my uploaded pictures of the errors I'm getting. How can I fix this?
Git push failed
Merge commit needed
Resolve conflicts
Resolve Conflicts2
It is an option in some java IDEs including eclipse and netbeans which automatically makes a document for your class ,interface etc.
These IDEs use a variable called user in the follow of #author property in class document.
Your problem starts when the user value equals to your current OS username that you login in it.
To prevent "netbeans" to write the OS username as default author name you can go to tools > templates.
after click on templates a dialog will be showed which include some folders like WEB,JAVA,JAVAFX etc.
In every folder we have some files like "Java class","Java Interface" etc which are your default shortcuts when you want to create a new item like an interface or a class , enum etc.
These files are your default templates for instance when you right click on a package > new > java class it make a java class in that package and its content is based on tools > templates > java > java class.
All you must do is to change every shortcut you want like java class or interface by open up tools > templates > java and click on java class or interface then click on open in editor button then search for somewhere like #author ${user} you must change the ${user} to your github username as the following example :
from :
/**
#author ${user}
*/
to :
/**
#author Swedishnovice
*/
Last week I found a setting in Eclipse that allows you to automatically include chosen static imports even when they are not written out. I am creating a Java clone of my OpenGL + GLFW C++ engine over to Java and I want to be able to statically import all of the GL classes without having to specify each version to use a method.
I didn't really bother with the setting, but now that I want it I can't seem to find it.
This setting is found under "Java > Editor > Content Assist > Favorites".
You can add a New Type... like mylibrary.* and everytime you press Ctrl + Space, Eclipse will show the matching static methods from mylibrary.
When I edit the java source code, intellij will auto format my code besides the places I edit, how to disable that ?
In the latest IntelliJ Idea (2021.3), Auto formatting can be stopped for one or more file type by going to
Preferences -> Tools -> Actions on save -> Enable or Disable Reformatting action for one or more file type
For those of you who want to disable formatting just for some specific file(s), there is a way since 2018.3 (IDEA-97848).
Go to Settings > Editor > Code Style > Formatter and add your exclusion pattern(s).
I tried disabling trim trailing spaces in code formatting but this doesn't work for my file type '.erb'.
I added my file type '.erb' to selectively disable code inspection for this file type but this doesn't work in IntelliJ version 2016.2.4.
I locked my file after I had made the changes using the lock icon in the Status Bar and this finally worked!
In Preferences > Tools > Actions on save you have a definition
BUT that can be overwritten by the following one, so check in that order:
In Preferences > Editor > Code style > [language] uncheck reformat on file save.
Update: None of those worked for me, so I change my file, commit without save (DON'T save during commit to avoid data loss, you'll be prompted) and then CTRL-Z.
Your file is committed and saved but only with your changes.
FWIW, I'm using Scala, on IntelliJ Community 2021.2, with the Scala plugin.
In my case intellij was messing with all the spaces in the code.
So, I changed following settings :
Editor > General
You can disable IntelliJ IDEA's ability to format (and therefore auto format) specific file types, but it comes at a cost.
To disable :
Settings > Editor > File Types
Select the file type you want to have never formatted
change the extension to something you don't use - for example '*.styl' to '*.oldstyl'
Now, even if you tell IntelliJ to reformat one of these files it won't.
The cost is that you lose syntax highlighting and language support all together.
In my case for stylus files it was worth it.
IDEA kept removing tab characters in sections of code that I wasn't even working in. SUPER annoying and destructive.
Can anybody reproduce the following?
In my NetBeans 7.2 project I've set the "project.license" property (in project.properties) to "apache20" so that NetBeans generates the appropriate license text in every new .java file. The license text (which is located in "license-apache20.txt") contains the following FreeMarker reference:
${project.organization!user}
When "project.organization" is not set it displays my user name as expected. Also, when I set a custom user name in the User.properties file it displays this user name instead. So far so good.
However, I want to set the "project.organization" property. But when I do this in the project.properties file NetBeans simply doesn't recognize it, displaying my user name instead.
When I remove "!user" from the FreeMarker reference it generates the text "Expression project.organization is undefined on line 4, column 59 in Templates/Licenses/license-apache20.txt." When I set the property in User.properties instead (silly place, but I did it for sake of analysis) I get the same behavior. Does anyone know what might be wrong or how to get NetBeans to find the "project.organization" property? Does anyone have the same behavior on his or her NetBeans?
In license-apache20.txt (or any other license template), change ${project.organization!user} to ${organization!user}
In NetBean menu, Tools ❯ Template, when you click the Setting button, a User.properties file is opened. Add organization=FooBar Inc there.
(This is not very ideal, but at least it allows to customize the organization.)
Just installed Eclipse Helios (Win7 64) and I'm having a strange problem. I type syso-Ctrl-Space which is expected to complete to System.out.println("") but it doesn't work! I searched the web for about an hour now, I set Preferences > Java > Editor > Content Assist to defaults, nothing. Everything else seems to work. Ideas?
To be clear: the shortcut works, it completes everything except "syso" as seen so far, on syso (also tried sysout) it says "No Default Proposals". I couldn't find this kind of shortcuts in the Content Assist, but I set them to default anyway.
If you still cant get auto-completion working,try enabling the Template proposals under Content assist menu.This is the exact location,
Windows->Preferences->Java->Editor->Content Assist->Advanced
And make sure you have only one entry for syso(Under Templates menu).
I believe the right template is "sysout" and I believe this can be configured somewhere but could not tell you where. Try sysout and then Ctrl+Space
It's a template, you can find all templates under
Window -> Preferences -> Java -> Editor -> Templates
There you can see that the template name is "sysout" this will then trigger the string substitution for System.out.writeln() but you can change both the template name (if you prefer syso) and/or the actual code produced by invoking the template
Cheers
I am using Eclipse Galileo and had the same problem. Even after trying the above proposed solutions but it didn't work. After making the below change it finally comes out.
Go to Windows->Preferences->Java->Editor->Templates
Select sysout template and edit it.
Change the context from Java statement to Java.
And it worked for me. I hope this will be helpful for you.
As Peter stated, it is under Window -> Java -> editor -> templates.
Look for the line with the following values.
sysout "Java Statements" "Print to standard out" "on"
the preview should be as follows...
System.out.println(${word_selection}${});${cursor}
Your cursor needs to be located in a place where it would be legal to get that line. If your cursor is within a method definition and you type syso you will get the replacement. However if your cursor is in the portion of the text outside of any method definition, say where you declare variables for your class for instance, then syso will not suggest the illegal line system.output.println();.
I had this problem, read all the answers here, became convinced that it MUST be working in my copy, and realized I had been typing syso BELOW the closing } of my last method instead of in the method.
Eclipse on!
You may try to set the shortcut of Content Assist with ALT+L, if it works, then you can choose your favorite shortcut again. (The shortcut Ctrl+Space conflicts with the shortcut of switching input method). In eclipse on linux, the shortcut of Word Completion is ALT+/, so if you set this as the shortcut of Content Assist it also conflicts.)
Just go to the below address:
Windows->Preferences->Java->Editor->Content Assist->Advanced
and click restore default..........that's all
its work like a charm again.
Also check in this eclipse menu:
Windows -> Preferences -> Java -> Appearance -> Type Filters
If you see java.* or javax.* here then try removing it (or Restore Default will do the job) and see that works, it did for me.
Just found the solution for Eclipse Luna: write syso and press CTRL+Space and click on "enable intelligent code completion" and you are set.
I am sure you can find it somewhere in the options as well but this way it is fast and easy!
DIRTY WORKAROUND:
You can try out the following AutoHotkey-Code if you're still struggling like I am (STILL haven't been able to fix it myself)
#persistent
#ifwinactive ahk_class SWT_Window0 ; eclipse java
:*:syso::
sendraw System.out.println()`;
loop, 2
send {left}
return
#ifwinactive
You need to write this in a .ahk file and run it (AutoHotkey needs to be installed). You might wanna put this file into your startup folder. It's a very useful tool, you might wanna expand it one day.
You might have overlapping shortcuts.. Goto 'Overview' than the 'Keys' subsection. Type "ctrl +space" in the 'filter text' section. You should see the "content assist" and probably another command with the same shortcut. If another shortcut does exists, change its shortcut to something else.