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.

JavadocTest.java 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*******************************************************************************
  2. * Copyright (c) 2004 IBM Corporation and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v 2.0
  5. * which accompanies this distribution, and is available at
  6. * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
  7. *
  8. * Contributors:
  9. * Andy Clement - initial implementation
  10. *******************************************************************************/
  11. package org.aspectj.ajdt.internal.compiler.batch;
  12. import java.io.File;
  13. import java.util.ArrayList;
  14. import java.util.List;
  15. import org.aspectj.tools.ajc.AjcTestCase;
  16. import org.aspectj.tools.ajc.CompilationResult;
  17. public class JavadocTest extends AjcTestCase {
  18. public static final String PROJECT_DIR = "javadoc";
  19. private File baseDir;
  20. @Override
  21. protected void setUp() throws Exception {
  22. super.setUp();
  23. baseDir = new File("../org.aspectj.ajdt.core/testdata", PROJECT_DIR);
  24. }
  25. /**
  26. * Aim: Check javadoc warning that appear are appropriate
  27. *
  28. * ajc -warn:allJavadoc World.java
  29. *
  30. */
  31. public void testMissingJavadoc() {
  32. String[] args = new String[] { "World.java", "-warn:allJavadoc", "-1.4" };
  33. List<Message> warningMessages = new ArrayList<>();
  34. // These warnings are against public textX() methods declared in the World.java
  35. // type. These test methods are spread between AJ constructs, meaning
  36. // if someone messes up and the javadoc is not associated with the aspectj
  37. // construct then it will associated by accident with one of the testX() methods.
  38. // By checking we get a warning against every testX() method, we are verifying
  39. // that the javadoc is being attached to the aspectj constructs.
  40. warningMessages.add(new Message(10, "Missing comment for public declaration"));
  41. warningMessages.add(new Message(18, "Missing comment for public declaration"));
  42. warningMessages.add(new Message(28, "Missing comment for public declaration"));
  43. warningMessages.add(new Message(36, "Missing comment for public declaration"));
  44. warningMessages.add(new Message(44, "Missing comment for public declaration"));
  45. warningMessages.add(new Message(53, "Missing comment for public declaration"));
  46. warningMessages.add(new Message(61, "Missing comment for public declaration"));
  47. warningMessages.add(new Message(69, "Missing comment for public declaration"));
  48. // TODO why don't see these for the other ones that have the same problem?
  49. // Basically that the javadoc on a public member refers to something that is not public
  50. warningMessages.add(new Message(6,"'public' visibility for malformed doc comments hides this 'default' reference"));
  51. warningMessages.add(new Message(32,"'public' visibility for malformed doc comments hides this 'default' reference"));
  52. warningMessages.add(new Message(22,"'public' visibility for malformed doc comments hides this 'default' reference"));
  53. warningMessages.add(new Message(48,"'public' visibility for malformed doc comments hides this 'default' reference"));
  54. MessageSpec spec = new MessageSpec(warningMessages, null);
  55. CompilationResult result = ajc(baseDir, args);
  56. assertMessages(result, spec);
  57. // dump(result.getWarningMessages());
  58. // System.err.println("-----------\n"+ajc.getLastCompilationResult().getStandardError());
  59. // List l = result.getWarningMessages();
  60. // IMessage m = ((IMessage)l.get(0));
  61. }
  62. // private void dump(List l) {
  63. // for (Iterator iter = l.iterator(); iter.hasNext();) {
  64. // IMessage element = (IMessage) iter.next();
  65. // System.err.println("Warning: "+element);
  66. // }
  67. // }
  68. }