You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NullIdeTaskListManager.java 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* *******************************************************************
  2. * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Common Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/cpl-v10.html
  8. *
  9. * Contributors:
  10. * Xerox/PARC initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.ajde;
  13. import java.util.ArrayList;
  14. import java.util.List;
  15. import org.aspectj.bridge.*;
  16. /**
  17. * Used for displaying tasks, such as compiler messages, to the user.
  18. *
  19. * @author Mik Kersten
  20. */
  21. public class NullIdeTaskListManager implements TaskListManager {
  22. List sourceLineTasks = new ArrayList();
  23. boolean hasWarning = false;
  24. public void addSourcelineTask(
  25. String message,
  26. ISourceLocation sourceLocation,
  27. IMessage.Kind kind) {
  28. addSourcelineTask(new Message(message, kind, null, sourceLocation));
  29. if (!hasWarning && IMessage.WARNING.isSameOrLessThan(kind)) {
  30. hasWarning = true;
  31. }
  32. }
  33. public void addSourcelineTask(IMessage message) {
  34. sourceLineTasks.add(new SourceLineTask(message));
  35. if (!hasWarning && IMessage.WARNING.isSameOrLessThan(message.getKind())) {
  36. hasWarning = true;
  37. }
  38. /* Guard against null source locations e.g. JAR file messages */
  39. if (null != message.getSourceLocation()) {
  40. System.out.println("NullIde> task: " + message.getMessage() + ", file: " + message.getSourceLocation().getSourceFile().getAbsolutePath()
  41. + ": " + message.getSourceLocation().getLine());
  42. }
  43. else {
  44. System.out.println("NullIde> task: " + message);
  45. }
  46. }
  47. public void addProjectTask(String message, IMessage.Kind kind) {
  48. if (!hasWarning && IMessage.WARNING.isSameOrLessThan(kind)) {
  49. hasWarning = true;
  50. }
  51. System.out.println("NullIde> task: " + message + ", kind: " + kind);
  52. }
  53. public boolean hasWarning() {
  54. return hasWarning;
  55. }
  56. public void clearTasks() {
  57. sourceLineTasks = new ArrayList();
  58. hasWarning = false;
  59. }
  60. /**
  61. * Return the list of source line compiler messages resulting from a compile, so
  62. * that we can test them.
  63. * @return List
  64. */
  65. public List getSourceLineTasks() {
  66. return sourceLineTasks;
  67. }
  68. public static class SourceLineTask {
  69. IMessage message;
  70. public SourceLineTask(IMessage m) {
  71. message = m;
  72. }
  73. public IMessage getContainedMessage() {
  74. return message;
  75. }
  76. public String toString() {
  77. String loc = "<no location>";
  78. if (null != message.getSourceLocation()) {
  79. loc = message.getSourceLocation().getSourceFile() + ":" + message.getSourceLocation().getLine();
  80. }
  81. return "SourceLineTask [" + message.getMessage()
  82. + ", " + loc
  83. + ", " + message.getKind()
  84. + "]";
  85. }
  86. }
  87. }