|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | +package org.netbeans.spi.debugger.jpda; |
| 20 | + |
| 21 | +import org.netbeans.api.debugger.Session; |
| 22 | +import org.netbeans.api.debugger.jpda.ObjectVariable; |
| 23 | + |
| 24 | +/** Provider of additional information about objects in the heap. |
| 25 | + * Register your implementation as |
| 26 | + * <pre> |
| 27 | + * @DebuggerServiceRegistration(path="netbeans-JPDASession", types=ObjectInfoProvider.class) |
| 28 | + * public final class YourProvider implements ObjectInfoProvider { |
| 29 | + * ... |
| 30 | + * } |
| 31 | + * </pre> |
| 32 | + * @since 3.45 |
| 33 | + */ |
| 34 | +public interface ObjectInfoProvider { |
| 35 | + /** Handles showing the info about provided object. |
| 36 | + * |
| 37 | + * @param session the debugging session sending the request |
| 38 | + * @param obj the object to display additional information about |
| 39 | + * @return {@code true} if the object information can be shown, |
| 40 | + * {@code false} otherwise |
| 41 | + */ |
| 42 | + boolean display(Session session, ObjectVariable obj); |
| 43 | + |
| 44 | + |
| 45 | + /** Requests additional information about an object to be shown. |
| 46 | + * Iterates all providers registered in the |
| 47 | + * {@code session.lookup(null, ObjectInfoProvider.class)}. |
| 48 | + * |
| 49 | + * @param session the debugging session that's requesting |
| 50 | + * @param obj reference to an object in the heap |
| 51 | + * @return {@code true} if the object information can be shown, |
| 52 | + * {@code false} otherwise |
| 53 | + */ |
| 54 | + static boolean showObjectInfo(Session session, ObjectVariable obj) { |
| 55 | + for (var output : session.lookup(null, ObjectInfoProvider.class)) { |
| 56 | + if (output != null && output.display(session, obj)) { |
| 57 | + return true; |
| 58 | + } |
| 59 | + } |
| 60 | + return false; |
| 61 | + } |
| 62 | + |
| 63 | +} |
0 commit comments