2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com
.intellij
.openapi
.roots
;
18 import com
.intellij
.openapi
.vfs
.VirtualFile
;
19 import com
.intellij
.util
.ArrayUtil
;
21 import java
.util
.ArrayList
;
22 import java
.util
.Collections
;
23 import java
.util
.List
;
28 public class AnnotationOrderRootType
extends PersistentOrderRootType
{
30 * @return External annotations path
32 public static OrderRootType
getInstance() {
33 return getOrderRootType(AnnotationOrderRootType
.class);
36 private AnnotationOrderRootType() {
37 super("ANNOTATIONS", "annotationsPath", "annotation-paths", null);
40 public boolean skipWriteIfEmpty() {
44 public static VirtualFile
[] getFiles(OrderEntry entry
) {
45 List
<VirtualFile
> result
= new ArrayList
<VirtualFile
>();
46 RecursiveRootPolicy
<List
<VirtualFile
>> policy
= new RecursiveRootPolicy
<List
<VirtualFile
>>() {
47 public List
<VirtualFile
> visitLibraryOrderEntry(final LibraryOrderEntry orderEntry
, final List
<VirtualFile
> value
) {
48 Collections
.addAll(value
, orderEntry
.getRootFiles(getInstance()));
52 public List
<VirtualFile
> visitJdkOrderEntry(final JdkOrderEntry orderEntry
, final List
<VirtualFile
> value
) {
53 Collections
.addAll(value
, orderEntry
.getRootFiles(getInstance()));
57 public List
<VirtualFile
> visitModuleSourceOrderEntry(final ModuleSourceOrderEntry orderEntry
,
58 final List
<VirtualFile
> value
) {
59 Collections
.addAll(value
, orderEntry
.getRootModel().getRootPaths(getInstance()));
63 entry
.accept(policy
, result
);
64 return result
.toArray(new VirtualFile
[result
.size()]);
67 public static String
[] getUrls(OrderEntry entry
) {
68 List
<String
> result
= new ArrayList
<String
>();
69 RecursiveRootPolicy
<List
<String
>> policy
= new RecursiveRootPolicy
<List
<String
>>() {
70 public List
<String
> visitLibraryOrderEntry(final LibraryOrderEntry orderEntry
, final List
<String
> value
) {
71 Collections
.addAll(value
, orderEntry
.getRootUrls(getInstance()));
75 public List
<String
> visitJdkOrderEntry(final JdkOrderEntry orderEntry
, final List
<String
> value
) {
76 Collections
.addAll(value
, orderEntry
.getRootUrls(getInstance()));
80 public List
<String
> visitModuleSourceOrderEntry(final ModuleSourceOrderEntry orderEntry
,
81 final List
<String
> value
) {
82 Collections
.addAll(value
, orderEntry
.getRootModel().getRootUrls(getInstance()));
86 entry
.accept(policy
, result
);
87 return ArrayUtil
.toStringArray(result
);