| 1 | /* |
| 2 | * Copyright 2000-2021 JetBrains s.r.o. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.jetbrains.annotations; |
| 17 | |
| 18 | import org.intellij.lang.annotations.Language; |
| 19 | |
| 20 | import java.lang.annotation.ElementType; |
| 21 | import java.lang.annotation.Retention; |
| 22 | import java.lang.annotation.RetentionPolicy; |
| 23 | import java.lang.annotation.Target; |
| 24 | |
| 25 | /** |
| 26 | * @since 18.0.0 |
| 27 | */ |
| 28 | public final class Debug { |
| 29 | |
| 30 | /** |
| 31 | * Prohibited default constructor. |
| 32 | */ |
| 33 | private Debug() { |
| 34 | throw new AssertionError("Debug should not be instantiated"); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Allows to change the presentation of an object in debuggers |
| 39 | */ |
| 40 | @Target(ElementType.TYPE) |
| 41 | @Retention(RetentionPolicy.CLASS) |
| 42 | public @interface Renderer { |
| 43 | /** |
| 44 | * Expression to be evaluated and used as the textual representation of the object.<br> |
| 45 | * {@code this} refers to the class instance being presented |
| 46 | */ |
| 47 | @Language(value = "JAVA", prefix = "class Renderer{String $text(){return ", suffix = ";}}") |
| 48 | @NonNls |
| 49 | String text() default ""; |
| 50 | |
| 51 | /** |
| 52 | * Expression to be evaluated to obtain an array of object's children.<br> |
| 53 | * Usually the result is an array of elements in a collection, or an array of entries in a map.<br> |
| 54 | * {@code this} refers to the class instance being presented |
| 55 | */ |
| 56 | @Language(value = "JAVA", prefix = "class Renderer{Object[] $childrenArray(){return ", suffix = ";}}") |
| 57 | @NonNls |
| 58 | String childrenArray() default ""; |
| 59 | |
| 60 | /** |
| 61 | * Expression to be evaluated to check if the object has any children at all.<br> |
| 62 | * This should work faster than {@link #childrenArray()} and return boolean.<br> |
| 63 | * {@code this} refers to the class instance being presented |
| 64 | */ |
| 65 | @Language(value = "JAVA", prefix = "class Renderer{boolean $hasChildren(){return ", suffix = ";}}") |
| 66 | @NonNls |
| 67 | String hasChildren() default ""; |
| 68 | } |
| 69 | } |