Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

IMessage.java 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* *******************************************************************
  2. * Copyright (c) 1999-2001 Xerox Corporation,
  3. * 2002 Palo Alto Research Center, Incorporated (PARC).
  4. * All rights reserved.
  5. * This program and the accompanying materials are made available
  6. * under the terms of the Eclipse Public License v1.0
  7. * which accompanies this distribution and is available at
  8. * http://www.eclipse.org/legal/epl-v10.html
  9. *
  10. * Contributors:
  11. * Xerox/PARC initial implementation
  12. * ******************************************************************/
  13. package org.aspectj.bridge;
  14. import java.util.Arrays;
  15. import java.util.Collections;
  16. import java.util.Comparator;
  17. import java.util.List;
  18. /**
  19. * Wrap message with any associated throwable or source location.
  20. */
  21. public interface IMessage {
  22. /** no messages */
  23. public static final IMessage[] RA_IMessage = new IMessage[0];
  24. // int values must sync with KINDS order below
  25. public static final Kind WEAVEINFO = new Kind("weaveinfo",5);
  26. public static final Kind INFO = new Kind("info", 10);
  27. public static final Kind DEBUG = new Kind("debug", 20);
  28. public static final Kind TASKTAG = new Kind("task",25); // represents a 'TODO' from eclipse - producted by the compiler and consumed by AJDT
  29. public static final Kind WARNING = new Kind("warning", 30);
  30. public static final Kind ERROR = new Kind("error", 40);
  31. public static final Kind FAIL = new Kind("fail", 50);
  32. public static final Kind ABORT = new Kind("abort", 60);
  33. // XXX prefer another Kind to act as selector for "any",
  34. // but can't prohibit creating messages with it.
  35. //public static final Kind ANY = new Kind("any-selector", 0);
  36. /** list of Kind in precedence order. 0 is less than
  37. * IMessage.Kind.COMPARATOR.compareTo(KINDS.get(i), KINDS.get(i + 1))
  38. */
  39. public static final List KINDS =
  40. Collections.unmodifiableList(
  41. Arrays.asList(
  42. new Kind[] { WEAVEINFO, INFO, DEBUG, TASKTAG, WARNING, ERROR, FAIL, ABORT }));
  43. /** @return non-null String with simple message */
  44. String getMessage();
  45. /** @return the kind of this message */
  46. Kind getKind();
  47. /** @return true if this is an error */
  48. boolean isError();
  49. /** @return true if this is a warning */
  50. boolean isWarning();
  51. /** @return true if this is an internal debug message */
  52. boolean isDebug();
  53. /** @return true if this is information for the user */
  54. boolean isInfo();
  55. /** @return true if the process is aborting */
  56. boolean isAbort(); // XXX ambiguous
  57. /** @return true if this is a task tag message */
  58. boolean isTaskTag();
  59. /** @return true if something failed */
  60. boolean isFailed();
  61. /** Caller can verify if this message came about because of a DEOW */
  62. boolean getDeclared();
  63. /** Return the ID of the message where applicable, see IProblem for list of valid IDs */
  64. int getID();
  65. /** Return the start position of the problem (inclusive), or -1 if unknown. */
  66. int getSourceStart();
  67. /** Return the end position of the problem (inclusive), or -1 if unknown. */
  68. int getSourceEnd();
  69. /** @return Throwable associated with this message, or null if none */
  70. Throwable getThrown();
  71. /** @return source location associated with this message, or null if none */
  72. ISourceLocation getSourceLocation();
  73. public static final class Kind implements Comparable {
  74. public static final Comparator COMPARATOR = new Comparator() {
  75. public int compare(Object o1, Object o2) {
  76. Kind one = (Kind) o1;
  77. Kind two = (Kind) o2;
  78. if (null == one) {
  79. return (null == two ? 0 : -1);
  80. } else if (null == two) {
  81. return 1;
  82. } else if (one == two) {
  83. return 0;
  84. } else {
  85. return (one.precedence - two.precedence);
  86. }
  87. }
  88. };
  89. /**
  90. * @param kind the Kind floor
  91. * @return false if kind is null or this
  92. * has less precedence than kind,
  93. * true otherwise.
  94. */
  95. public boolean isSameOrLessThan(Kind kind) {
  96. return (0 >= COMPARATOR.compare(this, kind));
  97. }
  98. public int compareTo(Object other) {
  99. return COMPARATOR.compare(this, other);
  100. }
  101. private final int precedence;
  102. private final String name;
  103. private Kind(String name, int precedence) {
  104. this.name = name;
  105. this.precedence = precedence;
  106. }
  107. public String toString() {
  108. return name;
  109. }
  110. }
  111. /**
  112. * @return Detailed information about the message. For example, for declare
  113. * error/warning messages this returns information about the corresponding
  114. * join point's static part.
  115. */
  116. public String getDetails();
  117. /**
  118. * @return List of <code>ISourceLocation</code> instances that indicate
  119. * additional source locations relevent to this message as specified by the
  120. * message creator. The list should not include the primary source location
  121. * associated with the message which can be obtained from
  122. * <code>getSourceLocation()<code>.
  123. * <p>
  124. * An example of using extra locations would be in a warning message that
  125. * flags all shadow locations that will go unmatched due to a pointcut definition
  126. * being based on a subtype of a defining type.
  127. * @see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=41952">AspectJ bug 41952</a>
  128. */
  129. public List getExtraSourceLocations();
  130. }