You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2020/11/03 14:14:35 UTC

[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #2513: ioContainer in IOProvider.getIO(...) is allowed to be null.

JaroslavTulach commented on a change in pull request #2513:
URL: https://github.com/apache/netbeans/pull/2513#discussion_r515758086



##########
File path: platform/openide.io/test/unit/src/org/openide/io/BridgingIOProviderTest.java
##########
@@ -78,9 +84,37 @@ public void bridgeToNullColor() throws IOException {
         assertEquals("Null!", sb.toString());
     }
 
+    @Test
+    public void nullIOContainer() throws IOException {
+        MockIOP mock = new MockIOP();
+        IOProvider provider = BridgingIOProvider.create(mock);
+        Action testAction = new AbstractAction("test") {
+            @Override public void actionPerformed(ActionEvent e) {}
+        };
+        InputOutput io = provider.getIO("test", false, new Action[] {testAction}, null);
+        assertSame(testAction, mock.last.lookup.lookup(Action.class));
+    }
+
+    @Test
+    public void hasIOContainer() throws IOException {
+        MockIOP mock = new MockIOP();
+        IOProvider provider = BridgingIOProvider.create(mock);
+        Action testAction = new AbstractAction("test") {
+            @Override public void actionPerformed(ActionEvent e) {}
+        };
+        IOContainer ioContainer = IOContainer.create(new MockIOProvider());
+        InputOutput io = provider.getIO("test", false, new Action[] {testAction}, ioContainer);
+        assertSame(testAction, mock.last.lookup.lookup(Action.class));

Review comment:
       I'd expect a failure here in the previous version of the code.

##########
File path: platform/openide.io/src/org/openide/io/BridgingIOProvider.java
##########
@@ -92,9 +93,16 @@ public InputOutput getIO(String name, Action[] actions,
     @Override
     public InputOutput getIO(String name, boolean newIO, Action[] actions,
             IOContainer ioContainer) {
+        Object[] lookupContent;
+        if (ioContainer != null) {
+            lookupContent = Arrays.copyOf(actions, actions.length + 1, Object[].class);
+            lookupContent[actions.length] = ioContainer;
+        } else {
+            lookupContent = actions;
+        }
         return new BridgingInputOutput(
                 providerDelegate.getIO(name, newIO,
-                        Lookups.fixed((Object[]) actions, ioContainer)));

Review comment:
       Do I read the change correctly?
   
   Previously the `Lookup` had two elements one of the type `Action[]` and one of the type `IOContainer`. The new `Lookup` is going to have n-elements of type `Action` and optionally one element of type `IOContainer`. 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists