krasa / GrepConsole

IntelliJ plugin - https://plugins.jetbrains.com/plugin/7125
Apache License 2.0
437 stars 57 forks source link

Grep console not working in AppCode #129

Closed SirWellington closed 5 years ago

SirWellington commented 5 years ago

In reference to #120

Unfortunately, this issue is happening again. I've tried everything I can think of. I will have to try and debug the plugin like you suggested.

SirWellington commented 5 years ago

I have tried debugging. Unfortunately I can't seem to debug the plugin off AppCode.

I get a whole bunch of compile-time errors when I link it to AppCode's SDK.

screen shot 2018-10-22 at 10 07 36 am

Seems to debug just fine from IntelliJ though.

krasa commented 5 years ago

You could setup the SDK from IntelliJ Community, and JRE from AppCode, or comment/remove those classes.

SirWellington commented 5 years ago

@krasa Just tried your tip. It worked and I was able to debug the plugin.

The GrepCopyingFilterSyncListener.process() function is only getting called when a grep tab is first opened, and not for subsequent events.

Regular Console

screen shot 2018-10-22 at 11 56 11 am

Grep Console

screen shot 2018-10-22 at 11 56 29 am

As you can see, none of the new events are picked up in the Grep Tab.

screen shot 2018-10-22 at 11 55 52 am

krasa commented 5 years ago

Check if .GrepConsoleInputFilterProvider#getDefaultFilters is called when you run the app. Then com.intellij.execution.filters.CompositeInputFilter#applyFilter and krasa.grepconsole.filter.GrepCopyingFilter#applyFilter

krasa commented 5 years ago

I suspect that com.intellij.execution.impl.ConsoleViewImpl#print(java.lang.String, com.intellij.execution.ui.ConsoleViewContentType) might be overriden. and not call InputFilters - com.jetbrains.commandInterface.console.CommandConsole does that.

SirWellington commented 5 years ago

GrepConsoleInputFilterProvider.getDefaultFilters() was called. CompositeInputFilter#applyFilter was also called. See attached.

screen shot 2018-10-22 at 2 44 04 pm

screen shot 2018-10-22 at 2 44 11 pm

screen shot 2018-10-22 at 2 44 19 pm

screen shot 2018-10-22 at 2 44 25 pm

screen shot 2018-10-22 at 2 48 10 pm

screen shot 2018-10-22 at 2 48 30 pm

SirWellington commented 5 years ago

The result = filter.applyFilter(text, contentType); line is returning null for both filters that I am seeing.

screen shot 2018-10-22 at 2 57 40 pm

screen shot 2018-10-22 at 2 57 58 pm

krasa commented 5 years ago

Everything looks fine unless there are some other filters in those InputFilterWrappers. The important thing is that krasa.grepconsole.filter.GrepCopyingFilter#applyFilter is called, and then you should be able to step through the code and see where it goes wrong - which may be pretty soon if as you say GrepCopyingFilterSyncListener is not called.

SirWellington commented 5 years ago

Right. Well it would appear that this function indeed gets called. However the copyingListeners list is empty, so the function invariably returns null.

screen shot 2018-10-22 at 4 24 41 pm

What are your thoughts? Wish I could do more, but you understand this framework far better than I.

SirWellington commented 5 years ago

Dug some more. Looks like there are multiple GrepCopyingFilter instances running around. One of them has the listener registered, but the others do not.

screen shot 2018-10-22 at 4 32 50 pm

The one that is getting called does not have any listeners registered. Do you know why that might be?

krasa commented 5 years ago

The one that has it, should be for the console from which you are grepping.

If not, then perhaps it was unregistered by: https://github.com/krasa/GrepConsole/blob/278a868c810636d6b7f821f5b208b1b3beb9bbf0/src/krasa/grepconsole/grep/OpenGrepConsoleAction.java#L178 Or a wrong instance was used at some point.

SirWellington commented 5 years ago

@krasa I put on a breakpoint on removeListener(), and I know that wasn't called. So it must be the other thing.

This is weird. I suspect the AppCode is using a different platform jar which might be breaking tings.

krasa commented 5 years ago

That must mean that hashcode is broken and this does not work https://github.com/krasa/GrepConsole/blob/fe78e7bb8284cba3897a7e999bef3a03cc774663/src/krasa/grepconsole/plugin/ServiceManager.java#L86

     * As much as is reasonably practical, the hashCode method defined by
     * class {@code Object} does return distinct integers for distinct
     * objects. (This is typically implemented by converting the internal
     * address of the object into an integer, but this implementation
     * technique is not required by the
     * Java™ programming language.)

hmm

SirWellington commented 5 years ago

I temporarily hacked it by setting the copyingListeners field to static, and then doing:

public void addListener(GrepCopyingFilterListener copyingListener) {
        if (copyingListeners.contains(copyingListener)) return;
        copyingListeners.add(copyingListener);
}

on GrepCopyingFilter.java#L41

@krasa What do you recommend we try next?

krasa commented 5 years ago

I will try to set up a VirtualBox with MacOS and reproduce it.

krasa commented 5 years ago

Try to add this thing: https://github.com/krasa/GrepConsole/commit/08beae1b9284ab465d4eb2a2cb316a2d93d9af8f

I think it is more probable than broken JVM, and I still did not make macOs work.

SirWellington commented 5 years ago

@krasa So far so good. Looks like that commit did the trick. Thanks.