IntelliJ Ultimate 14 find usages not working - intellij-idea

I am using IntelliJ IDEA 14 Ultimate. When I search find usages, in find view, there is an info like "Searching for usages in project files" and doesn't return any result. Scope is "whole project".
I have also IntelliJ 14 Community Edition. When it tries find usages in Community Edition, it works.
Do you have any idea?

I had exactly the same problem, so for people looking for the quick answer, try
File -> Invalidate Caches / Restart
Thanks to user #yole and his comment.

If it doesn't solve by File -> Invalidate Caches / Restart
then make sure your 'src' folder is marked as 'Sources' in project structure.

If File -> Invalidate Caches / Restart is not working -> close the project, remove it from recent projects and then delete the .idea folder then open the project again.

In PhpStorm version 2019.1 on a Windows machine, if you hold AltGr key and hover on a function, it appears the popup 'Show usage of Method ...' but it's misleading since doesn't find the calls to that method from other files.
The correct way to show usages, is to hold the Ctrl button and click on the method name.

There are also other cases the "Find Usages" feature does not work. I can illustrate one very simple case.
Provider.java:
public class Provider {
private static final Provider instance = new Provider();
public static Provider getInstance() { return instance; }
public Integer getID() { return 0; }
}
User.java:
public class User {
private final Integer pID;
public User() { pID = Provider.getInstance().getID(); }
}
If you click on the getID() method in Provider.java and call "Find Usages", it finds the call in the User.java easily. But if you rename or remove the getInstance() method in Provider.java, then it won't find the getID() call in User.java anymore.
I assume that it happens because the line Provider.getInstance().getID() is marked with red (compilation error) and the "Find Usages" feature does not consider this failing code as a valid call of getID(). It means that, at least some compilation errors affect the "Find Usages" results.
I was curious enough to look into the list of bugs related to this feature on https://youtrack.jetbrains.com/issues?q=find%20usages and there I saw there are other cases and made my conclusion. To sum up, if you don't like to keep in mind all the conditions in which it works and want always full search I recommend using grep which finds always and everything.

IntelliJ IDEA 2022.2.1
After Invalidate Caches/Restart did not work, what did fix the problem was Mark Directory As -> Unmark As Sources Root, followed by Mark Directory As -> Sources Root on 'src/main/java'

Sometimes problem in your code format structure.
Try this -
Press ctrl+alt+shift+l and
Choose selected text
Code cleanup
then your problem is resolved

You can also temporarily force a "bad" source folder (ex: .../tmp), then switch back to the correct source folder (ex: src/main/java).
This, combined with cache cleaning as explained in the other posts solved the problem for one of my collegues.
You declare / undeclar source folder with a right click on the folder, then "Mark Directory as ...".

have u tried mark directory as -> Project Source and Header?I just work out it in CLion.

Related

How do I start Etoys from Squeak?

In the Squeak System Browser, I see that there are many class categories related to Etoys:
But how do I access Etoys from Squeak? How do I get something like the screenshot shown below?
(Source of Etoys screenshot: https://commons.wikimedia.org/wiki/File:Squeak_screenshot.png)
There are also Squeak versions set up specifically for Etoys, e.g.:
https://squeak.js.org/etoys/#fullscreen
I think there is easier way than Leandro is proposing.
Just run the Workspace from the menu where you type:
Project enterNewWithInitialBalloons
Select it with mouse and run it - Do it (alt+d). Application should start. I'm unfamiliar with the application. To me it looks similar to the picture you show.
Edit: how did I find it?
I searched through the source code. I have to agree that this is not straight forward.
First I tried to find anything that has to do with Etoys project/class. I tried to find anything that would indicate that you can start it.
This way I found Etoys-Experimental package with class EToysLauncher. The word launcher to me sounded like it could be launched. I looked at the class of the EToysLauncher where I found instance creating protocol where you can find these methods (remember we are still at the experimental package!):
#buildGallery
#buildPanel
#openGallery
#openPanel
If you go through these e.g. EToysLauncher openPanel you will get a message doesNotUnderstand: #latestProjectVersionsFromFileEntries. I then started to investigate the Walkback. I tried to check what is the issue here. I got this message because of the last line ^ Project latestProjectVersionsFromFileEntries: entries.
I went to the Project>>latestProjectVersionsFromFileEntries: to check what it is actually doing. In meantime I have inspected the values from the entries variable in the debugger. In the entries I could find an OrderedCollection but nothing what would satisfy #('*.pr' '*.pr.gz' '*.project') from the method. So I thought to myself, that perphaps the Project itself could satisfy it.
I went to the Project class and protocol Etoys-Squeakland-instance creation where I found two methods #enterNew and #enterNewWithInitialBalloons.
The #enterNew gives doesNotUnderstand: #newMorphicOn: so I skipped that one and tried the #enterNewWithInitialBalloons, which worked and since it is in the protocol Etoys-Squeakland-instance creation I came to the conclusion it has create Etoys-Squeakland new instance.
Edit: Show shared flaps?
Yes, you can activate the flaps also via Show shared flaps.
There is, however, quite a difference between running the Project enterNewWithInitialBalloons and Showing the shared flaps via Preferences.
If you start the Etoys via the Project enterNewWithInitialBalloons you will start completely new project (your currently opened windows will be hidden). To see your previous windows you need to either Porojects/Enter Project and switch to the HomeProject or you have to close the newly opened project via Projects/Close This Project.
The source that shows it is:
enterNewWithInitialBalloons
| newP |
newP := MorphicProject new.
newP world addMorph: (DoCommandOnceMorph new extent: 1#1; actionBlock: [SugarNavigatorBar putUpInitialBalloonHelp]; yourself).
newP enter.
This creates new MorphicProject and to this project it adds new Morph.
On the other hand, if you start it with Preferences/Show shared flaps the flaps will be just added to your current environment without creating a new project.
The source that shows it is: Preferences class >>sharedFlapsSettingChanged
sharedFlapsSettingChanged
"The current value of the showSharedFlaps flag has changed; now react"
self showSharedFlaps "viz. the new setting"
ifFalse:
[Flaps globalFlapTabsIfAny do:
[:aFlapTab | Flaps removeFlapTab: aFlapTab keepInList: true]]
ifTrue:
[Smalltalk isMorphic ifTrue:
[self currentWorld addGlobalFlaps]]
The self currentWorld addGlobalFlaps adds the flaps to the currentWorld. The PasteUpMorph>>addGlobalFlaps creates new PasteUpMorph and adds it.
You can also notice the difference also in the menu bar title Untitled vs. HomeProject.

How to create a Kotlin console application with Gradle in Intellij IDEA

I found this tutorial from JetBrains: https://www.jetbrains.com/help/idea/create-your-first-kotlin-app.html?section=Gradle%20Kotlin
It is dated August 19th, 2020.
I am using the same IntelliJ IDEA version as in their documentation: 2020.2.
However, my project creation wizard looks quite different from theirs.
They provide this screenshot:
But for me, it looks like this:
and when I click on Next:
I don't see where I can choose the Console Application template, or Gradle.
I found a second tutorial - https://kotlinlang.org/docs/tutorials/jvm-get-started.html , which shows yet a third variation of the New Project wizard:
Are the tutorials out of date? Am I doing anything wrong? How do I create a Kotlin project, based on a console application template, with Gradle?
The wizard you have seems to be obsolete now. There was a brand-new one, released as a part of Kotlin 1.4 recently(see here). Most probably, the problem is caused by the Kotlin IDE plugin being outdated or something. Please try to delete in and re-install using the Preferences -> Plugins menu. Comment here with the results, please. I'd like to know if this would help.
Indeed it's quite weird, I've never seen the dialog to look like yours (mine looks like the one in the tutorials). However, choosing the template doesn't do anything special - it simply creates the main file, which you can do so yourself.
So create a new project with the "JVM/IDEA" option. If it already opens up a main.kt file, you don't need to do anything else. If it didn't, look in the src folder - you should see a folder named main with a folder named kotlin (with a blue icon instead of grey) inside - here's where you wanna create your main file (right click -> new kotlin file/class -> main.kt and make it a file, not a class). Finally, put this in the file:
fun main(args: Array<String>) {
println("Hello world!")
}
Note: if you don't have a kotlin folder, create the file in the folder with the blue icon (might even be src). Also, if this doesn't use Gradle (for some reason), create a Gradle project instead, and at the "Additional libraries and frameworks" option, uncheck Java and check Kotlin, then continue with creating main.kt if it isn't created.
You may create a Kotlin + gradle project from the terminal:
$mkdir myProject; cd myProject; gradle init
follow the tutorial.
And then start the Intellij & open the dir
You're good to go
Same process like this
The same happened to me but I figured out how to fix it:
Just disable Material Theme UI.

Intellij Idea does not detect and underline non-existing methods in the editor pane

In the idea editor and my java project , idea does not detect non-existing methods and underline in the editor pane, so i could not use alt + enter to generate new methods.
Example screenshot is below :
BTW : powersave mode is disabled, in the project setting sources are selected.
Project window is seen below:
I created demo maven project in idea, still the problem continues.
I created DemoNew Class.
public class DemoNew {
}
Then i created DemoImpl class:
public class DemoImpl {
public static void main(String[] args) {
DemoNew demoObject = new DemoNew();
demoObject.ssss(); // idea does not detect this non-existing method.
}
}
As seen above, idea does not detect the non existing ssss method in DemoNew class.
I uploaded demo project and my settings in intellij idea.
demo project and settings
After compiling project, still idea does not underline non-existing method with red color in the editor pane.
JetBrains Team answered the question
Looks like JDK uses wrong locale:
https://youtrack.jetbrains.com/issue/IDEA-190718 Please try to add
"-Dsun.locale.formatasdefault=true" option to JVM settings.
I added that parameters from intellij idea / help / edit custom vm options.
And parameters are seen below.
-Dsun.locale.formatasdefault=true
-Duser.language=en
-Duser.region=US
-Dfile.encoding=UTF8
I added last four items in the file.
That fixed the problem.

IntelliJ File and Code Templates error

This isn't specifically code-related, but about the templates of IntelliJ IDEA. In File -> Settings... -> File and Code Templates, it shows the templates of various file types that you can edit (when you create a file of that type, it provides the layout from the template, pretty simple). However, my problem is that it doesn't exactly follow my desired template. For example, let's take the Class type.
This is what I want:
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
public class ${NAME}
{
}
This is what I get:
package name
class name {
}
Why does IntelliJ IDEA ignore my moving of the block character onto the next line? How do I fix this? It's incredibly frustrating.
IntelliJ is deciding where to put the brace using your current code style.

Eclipse custom text editor update syntax highlighting

I am writing an Eclipse plugin (Indigo/Juno) that contains a text editor for a custom text format. I am following the tutorial here: http://www.realsolve.co.uk/site/tech/jface-text.php
So far I have everything working. Eclipse will use my editor to edit files. I have partitioning, damaging, repairing, syntax highlighting all working.
I added a preferences page with color pickers to control syntax highlighting. It works mostly correct. If I update the colors, the editor uses them the next time I open or reopen a file.
How do I get an editor tab to update itself without opening a new one? The built-in JDT Java editor does this, but so far I have not been able to decipher how (it is a very large and complex editor).
I gather that I need to create a preferences listener (http://www.vogella.com/articles/EclipsePreferences/article.html). I have done this and can verify that my listener code is being invoked when I set a breakpoint in it.
The missing piece is the wiring between the listener and reinitializing the editor. I have tried reconstructing the partitioning logic, the color logic, the damager/repairer, etc. but nothing seems to work. It either does nothing I can see or at worst will corrupt the display until I scroll the current text out of view to repaint it... with the old colors.
Any ideas?
I think SourceViewer.invalidatePresentation() needs to be called.
It may be already late to you, but if you want you could use LiClipse for that (http://brainwy.github.io/liclipse/) -- one of its targets is easily doing an editor with syntax highlighting, basic code-completion, outline, etc targeting Eclipse.
No java skills are required to add a new language (mostly creating a new .liclipse -- which is a YAML -- file in the proper place and creating some basic rules to say how to partition your language -- i.e.: usually just separating code from comments from strings -- and specifying the keywords you have in the partition would already give you proper syntax highlighting).
If you download it, there are a number of examples at plugins\com.brainwy.liclipse.editor\languages and there's some basic documentation at http://brainwy.github.io/liclipse/supported_languages.html and http://brainwy.github.io/liclipse/scope_definition.html on how to do it.
For anyone coming across this as I did:
My solution involved adding the following lines into the Constructor of my Editor
Activator.getActivator().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
#Override
public void propertyChange(PropertyChangeEvent event) {
getSourceViewer().invalidateTextPresentation();
handlePreferenceStoreChanged(event);
}
});
and then creating a custom class that extended IToken. In the constructor I pass the String of the preference field and then in the 'getObject' method I create the TextAttribute: snippets below
public class MyToken extends Token implements IToken {
public MyToken(Object data) {
super(data);
}
#Override
public Object getData() {
String dataString = (String) super.getData();
return getAttributeFromColorName(dataString);
}
private TextAttribute getAttributeFromColorName(String preferenceField) {
Color color = new Color(Display.getCurrent(), StringConverter.asRGB(Activator.getActivator().getPreferenceStore().getString(preferenceField)));
return new TextAttribute(color);
}
}
When I generate my Rules I have all of my tokens as my custom class and this allowed me to change syntax color dynamically.
I also added an example for updating the coloring if the preference changes to https://www.vogella.com/tutorials/EclipseEditors/article.html#exercise-allow-user-to-customize-the-colors
This is using the Generic editor (currently the best approach to implement a customer editor) but it should be possible to adjust this to any Eclipse editor implementation.