|
22 | 22 | package com.igormaznitsa.jcp.directives; |
23 | 23 |
|
24 | 24 | import com.igormaznitsa.jcp.context.PreprocessorContext; |
| 25 | +import java.util.ArrayList; |
| 26 | +import java.util.List; |
25 | 27 |
|
26 | 28 | /** |
27 | 29 | * The class is the abstract parent for all classes process preprocessor |
@@ -52,55 +54,46 @@ public abstract class AbstractDirectiveHandler { |
52 | 54 | */ |
53 | 55 | public static final String ONE_LINE_COMMENT = "//"; |
54 | 56 |
|
55 | | - /** |
56 | | - * The array contains all directives of the preprocessor |
57 | | - */ |
58 | | - private static volatile AbstractDirectiveHandler[] allDirectives; |
59 | | - |
60 | | - |
61 | | - public static AbstractDirectiveHandler[] getAllDirectives() { |
62 | | - if (allDirectives == null) { |
63 | | - allDirectives = new AbstractDirectiveHandler[] { |
64 | | - new LocalDirectiveHandler(), |
65 | | - new IfDefinedDirectiveHandler(), |
66 | | - new IfNDefDirectiveHandler(), |
67 | | - new IfDefDirectiveHandler(), |
68 | | - new IfDirectiveHandler(), |
69 | | - new ElseDirectiveHandler(), |
70 | | - new EndIfDirectiveHandler(), |
71 | | - new WhileDirectiveHandler(), |
72 | | - new BreakDirectiveHandler(), |
73 | | - new ContinueDirectiveHandler(), |
74 | | - new EndDirectiveHandler(), |
75 | | - new ExitIfDirectiveHandler(), |
76 | | - new ExitDirectiveHandler(), |
77 | | - new OutdirDirectiveHandler(), |
78 | | - new OutEnabledDirectiveHandler(), |
79 | | - new OutNameDirectiveHandler(), |
80 | | - new OutDisabledDirectiveHandler(), |
81 | | - new CommentNextLineDirectiveHandler(), |
82 | | - new DefinelDirectiveHandler(), |
83 | | - new DefineDirectiveHandler(), |
84 | | - new UndefDirectiveHandler(), |
85 | | - new FlushDirectiveHandler(), |
86 | | - new IncludeDirectiveHandler(), |
87 | | - new ActionDirectiveHandler(), |
88 | | - new PostfixDirectiveHandler(), |
89 | | - new PrefixDirectiveHandler(), |
90 | | - new GlobalDirectiveHandler(), |
91 | | - new GlobalElseDirectiveHandler(), |
92 | | - new GlobalEndIfDirectiveHandler(), |
93 | | - new GlobalIfDirectiveHandler(), |
94 | | - new ExcludeIfDirectiveHandler(), |
95 | | - new ErrorDirectiveHandler(), |
96 | | - new WarningDirectiveHandler(), |
97 | | - new EchoDirectiveHandler(), |
98 | | - new MsgDirectiveHandler(), |
99 | | - new NoAutoFlushHandler(), |
100 | | - new AbortDirectiveHandler() |
101 | | - }; |
102 | | - } |
103 | | - return allDirectives; |
| 57 | + public static List<AbstractDirectiveHandler> findAllDirectives() { |
| 58 | + final List<AbstractDirectiveHandler> result = new ArrayList<>(); |
| 59 | + result.add(new LocalDirectiveHandler()); |
| 60 | + result.add(new IfDefinedDirectiveHandler()); |
| 61 | + result.add(new IfNDefDirectiveHandler()); |
| 62 | + result.add(new IfDefDirectiveHandler()); |
| 63 | + result.add(new IfDirectiveHandler()); |
| 64 | + result.add(new ElseDirectiveHandler()); |
| 65 | + result.add(new EndIfDirectiveHandler()); |
| 66 | + result.add(new WhileDirectiveHandler()); |
| 67 | + result.add(new BreakDirectiveHandler()); |
| 68 | + result.add(new ContinueDirectiveHandler()); |
| 69 | + result.add(new EndDirectiveHandler()); |
| 70 | + result.add(new ExitIfDirectiveHandler()); |
| 71 | + result.add(new ExitDirectiveHandler()); |
| 72 | + result.add(new OutdirDirectiveHandler()); |
| 73 | + result.add(new OutEnabledDirectiveHandler()); |
| 74 | + result.add(new OutNameDirectiveHandler()); |
| 75 | + result.add(new OutDisabledDirectiveHandler()); |
| 76 | + result.add(new CommentNextLineDirectiveHandler()); |
| 77 | + result.add(new DefinelDirectiveHandler()); |
| 78 | + result.add(new DefineDirectiveHandler()); |
| 79 | + result.add(new UndefDirectiveHandler()); |
| 80 | + result.add(new FlushDirectiveHandler()); |
| 81 | + result.add(new IncludeDirectiveHandler()); |
| 82 | + result.add(new ActionDirectiveHandler()); |
| 83 | + result.add(new PostfixDirectiveHandler()); |
| 84 | + result.add(new PrefixDirectiveHandler()); |
| 85 | + result.add(new GlobalDirectiveHandler()); |
| 86 | + result.add(new GlobalElseDirectiveHandler()); |
| 87 | + result.add(new GlobalEndIfDirectiveHandler()); |
| 88 | + result.add(new GlobalIfDirectiveHandler()); |
| 89 | + result.add(new ExcludeIfDirectiveHandler()); |
| 90 | + result.add(new ErrorDirectiveHandler()); |
| 91 | + result.add(new WarningDirectiveHandler()); |
| 92 | + result.add(new EchoDirectiveHandler()); |
| 93 | + result.add(new MsgDirectiveHandler()); |
| 94 | + result.add(new NoAutoFlushHandler()); |
| 95 | + result.add(new AbortDirectiveHandler()); |
| 96 | + return result; |
104 | 97 | } |
105 | 98 |
|
106 | 99 | /** |
|
0 commit comments