getUserData always return null

this is my test project: https://github.com/roroco/getUserData-return-null

see my screencast, i get following

// c.getUserData(new Key<RunContentDescriptor>("Descriptor"))
// => null

// ((ContentImpl) c).getUserDataString()
// => Pair: (Descriptor -> com.intellij.execution.ui.RunContentDescriptor#726969510(ExTest.testM); ContentIcon -> true)

my question is how to fix it? please tell me some way in idea 13, idea 14 ruby plugin has severe bug, i temporarily can't move to idea 14



Attachment(s):
getUserData-return-null.ogv.zip
8 comments
Comment actions Permalink

getUserData() is not an API that is supposed to be used by plugin developers in this fashion. Please use getUserData() only for getting the data that you put there yourself; any other use can break at any moment.

1
Comment actions Permalink

i'm confuse:
- if i can't user getUserData() "in this fashion, where i can use it
- is there better way to get myUserData?

0
Comment actions Permalink

I have seen this example: https://devnet.jetbrains.com/message/5487853#5487853

why
"RunContentDescriptor descriptor = content.getUserData(new Key<RunContentDescriptor>("Descriptor")"
can work well?

update it also doen't work

0
Comment actions Permalink

You can use getUserData() and putUserData() by defining your own key and getting/putting your own data. User data stored by other code, just like the contents of private fields, is implementation details and not intended to be used by plugin developers.

0
Comment actions Permalink

in my code https://github.com/roroco/getUserData-return-null/blob/master/src/ro/test/getUserReturnNull.java
if i can't use getUserData to get a debug descriptor, is there better way to get it?

i hope fix my old questoin https://devnet.jetbrains.com/thread/458334 with a better way
in current idea 14, ruby plugin has severe bug, so i hope temporarily implement  "rerun debug" in idea 13(ExecutionUtil.restart() is in idea 14, i can't use it)

0
Comment actions Permalink

I fix it with:

RunContentDescriptor d = new RunContentManagerImpl(e.getProject(), DockManager.getInstance(e.getProject())).getRunContentDescriptorByContent(c);

but i hope you can reply me: i think if getUserData() work, the plugin development will be easier, why you say "not intended to be used by plugin developers."

0
Comment actions Permalink

You most definitely don't need to create a RunContentManagerImpl instance. Use ExecutionManager.getInstance(project).getRunContentManager() instead.

getUserData() does work for the purpose it is intended to be used: attaching *your own data* to IntelliJ object instances.

0
Comment actions Permalink

getRunContentManager seems didn't work in idea 13, after idea 14 fix ruby plugin bug, i will try it

0

Please sign in to leave a comment.