lahodaj commented on PR #7059:
URL: https://github.com/apache/netbeans/pull/7059#issuecomment-1948964918
> > made only to the Lookup used for `isActionEnabled` ("test Lookup"),
> > but not to the Lookup used for `invokeAction` ("invoke Lookup")
>
> I am pretty sure the `createTargetLookup` is used for both. Otherwise, as
you point out, it would make no sense. Btw. the [ActionProvider in question is
here](https://github.com/enso-org/enso/pull/9041/files).
Sorry, but I don't see this in the code. I may be reading the code wrong,
but what I see, the `createTargetLookup` is only used to produce lookup sent to
`findActionProvider` and `findNestedActionProviders`, and neither of those
seems to do `invokeAction` (that is done on a completely different level, as
far as I can tell). The code is a bit messy, but I simple don't see this change
affect both.
In addition to that, I've added this log:
```
diff --git
a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/actions/SingleJavaSourceRunActionProvider.java
b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/actions/SingleJavaSourceRunActionProvider.java
index 007764c964..61c6a38686 100644
---
a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/actions/SingleJavaSourceRunActionProvider.java
+++
b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/actions/SingleJavaSourceRunActionProvider.java
@@ -53,6 +53,7 @@ public final class SingleJavaSourceRunActionProvider
implements ActionProvider {
})
@Override
public void invokeAction(String command, Lookup context) throws
IllegalArgumentException {
+ System.err.println("invokeAction context content: " +
context.lookupAll(Object.class));
FileObject fileObject =
SingleSourceFileUtil.getJavaFileWithoutProjectFromLookup(context);
if (fileObject == null)
return;
@@ -77,6 +78,7 @@ public final class SingleJavaSourceRunActionProvider
implements ActionProvider {
@Override
public boolean isActionEnabled(String command, Lookup context) throws
IllegalArgumentException {
+ System.err.println("isActionEnabled context content: " +
context.lookupAll(Object.class));
FileObject fileObject =
SingleSourceFileUtil.getJavaFileWithoutProjectFromLookup(context);
return fileObject != null;
}
```
and ran a source file outside of a project, and got this output:
```
isActionEnabled context content:
[org.netbeans.modules.java.JavaDataObject@3acf453f[/home/jlahoda/test-projects/multi-file-unnamed/test/Test.java@bd92ca97:7de40d80],
CES: DocumentOpenClose: SimpleES@1970961222, documentStatus=OPENED,
docRef=(NbEditorDocument@91025795),
/home/jlahoda/test-projects/multi-file-unnamed/test/Test.java@bd92ca97:7de40d80,
org.netbeans.modules.java.JavaNode[name=Test;
displayName=Test.java][Name=Test, displayName=Test.java]]
invokeAction context content:
[/home/jlahoda/test-projects/multi-file-unnamed/test/Test.java@bd92ca97:7de40d80,
org.netbeans.api.extexecution.base.ExplicitProcessParameters@30be000e,
org.netbeans.modules.java.lsp.server.debugging.launch.NbProcessConsole@1de77413,
org.netbeans.modules.java.lsp.server.debugging.launch.NbLaunchDelegate$1@a74d360]
```
To me, it seems clear the `isActionEnabled` context contains stuff that is
not in the `invokeAction` context.
>
> > * Project Lookups are not (AFAIK) required to contain the reference to
the Project (so this is potentially a breaking change),
>
> I thought they are required to contain `this`. I can make sure to add
`Lookups.fixed(prj)` if `prj.getLookup().lookup(Project.class) != prj` - if you
want.
I wonder what's the purpose of flattening the whole Project's Lookup into
the context. Is that done anywhere else? What do we expect the
`ActionProvider`s will lookup here? Project Lookups may contain stuff that may
conflict with other things, because they are normally a separate domain. IMO,
at least.
And, if both Project and FileObject Lookup are flattened, what about their
order? And what about duplicities?
I don't think the Project Lookup must contain anything `Lookup.EMPTY` is
absolutely valid.
>
> > * adding the whole `FileObject.getLookup()` - but I understand this may
match the usual content of the Lookup when running inside the whole NetBeans
GUI, so this is not a huge concern.
>
> I hope it matches the original spirit more. On the other hand I admit I
was ready to remove the change, if it was the reason why the tests were failing
(but it wasn't).
From my view - I'd say that `FileObject.getLookup()` is much more acceptable
(because I think you are right that's the normal context lookup) than
`Project.getLookup()` (which I don't think is ever flattened anywhere).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists