View Javadoc
1   /*
2   UnusedImports
3   processJavadoc = (default)true
4   
5   
6   */
7   
8   package com.puppycrawl.tools.checkstyle.checks.imports.unusedimports;
9   
10  import com.google.errorprone.annotations.*;
11  import com.google.errorprone.annotations.concurrent.GuardedBy; //violation
12  
13  import java.io.*;
14  import java.lang.*;
15  import java.lang.String; // violation
16  
17  import java.util.List; // violation
18  import java.util.List; // violation
19  import java.lang.*;
20  import java.util.Iterator;
21  import java.util.Enumeration; // violation
22  import java.util.Arrays;
23  import javax.swing.JToolBar;
24  import javax.swing.JToggleButton; // violation
25  
26  import javax.swing.BorderFactory; // violation
27  
28  import static java.io.File.listRoots;
29  
30  import static javax.swing.WindowConstants.*;
31  import static java.io.File. // violation
32      createTempFile;
33  
34  import java.awt.Graphics2D;
35  import java.awt.HeadlessException;
36  import java.awt.Label; // violation
37  import java.util.Date;
38  import java.util.Calendar;
39  import java.util.BitSet;
40  
41  import com.google.errorprone.annotations.CheckReturnValue;
42  import com.google.errorprone.annotations.CanIgnoreReturnValue;
43  import com.google.errorprone.annotations.CompatibleWith;
44  import com.google.errorprone.annotations.concurrent.LazyInit;
45  import com.google.errorprone.annotations.DoNotCall;
46  import com.google.errorprone.annotations.CompileTimeConstant;
47  import com.google.errorprone.annotations.FormatString;
48  import com.google.errorprone.annotations.ForOverride; // violation
49  
50  /**
51   * Test case for imports
52   * Here's an import used only by javadoc: {@link Date}.
53   * @author Oliver Burn
54   * @author lkuehne
55   * @author Michael Studman
56   * @see Calendar Should avoid unused import for Calendar
57   **/
58  class InputUnusedImports
59  {
60      /** ignore {@literal <B>Test Javadoc Tag that is not processed for imports</B>}**/
61      private Class mUse1 = null;
62      /** ignore **/
63      private Class mUse2 = java.io.File.class;
64      /** ignore **/
65      private Class mUse3 = Iterator[].class;
66      /** ignore **/
67      private Class mUse4 = java.util.Enumeration[].class;
68      /** usage of illegal import **/
69      private Object ftpClient = null;
70  
71      /** usage via static method, both normal and fully qualified */
72      {
73          int[] x = {};
74          Arrays.sort(x);
75          Object obj = javax.swing.BorderFactory.createEmptyBorder();
76          File[] files = listRoots();
77      }
78  
79      /** usage of inner class as type */
80      private JToolBar.Separator mSep = null;
81  
82      /** usage of inner class in Constructor */
83      private Object mUse5 = new Object();
84  
85      /** usage of inner class in constructor, fully qualified */
86      private Object mUse6 = new javax.swing.JToggleButton.ToggleButtonModel();
87  
88      /** we use class name as member's name.
89       *  also an inline JavaDoc-only import {@link Vector linkText} */
90      private int Component;
91  
92      /**
93       * method comment with JavaDoc-only import {@link BitSet#aMethod()}
94       */
95      public void Label() {}
96  
97      /**
98       * Renders to a {@linkplain Graphics2D graphics context}.
99       * @throws HeadlessException if no graphis environment can be found.
100      * @exception HeadlessException if no graphis environment can be found.
101      */
102     public void render() {}
103 
104     /**
105      * First is a class with a method with arguments
106      * {@link CheckReturnValue#method1(CanIgnoreReturnValue)}.
107      * Next is a class with typed method
108      * {@link BaseFileSetCheckTestSupport#method2(CompatibleWith, LazyInit)}.
109      *
110      * @param param1 with a link {@link DoNotCall}
111      * @throws CompileTimeConstant when broken
112      * @deprecated in 1 for removal in 2. Use {@link FormatString}
113      */
114     public void aMethodWithManyLinks() {}
115 }