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.
17 package com.intellij.util.xml;
19 import com.intellij.ide.structureView.StructureViewBuilder;
20 import com.intellij.openapi.components.ServiceManager;
21 import com.intellij.openapi.project.Project;
22 import com.intellij.openapi.util.Condition;
23 import com.intellij.openapi.vfs.VirtualFile;
24 import com.intellij.psi.search.GlobalSearchScope;
25 import com.intellij.psi.xml.XmlFile;
26 import com.intellij.util.Function;
27 import com.intellij.util.containers.ContainerUtil;
28 import org.jetbrains.annotations.NotNull;
29 import org.jetbrains.annotations.Nullable;
31 import java.util.Collection;
32 import java.util.List;
35 * @author Gregory.Shrago
37 public abstract class DomService {
39 public static DomService getInstance() {
40 return ServiceManager.getService(DomService.class);
43 public Collection<VirtualFile> getDomFileCandidates(Class<? extends DomElement> description, Project project, final GlobalSearchScope scope) {
44 return ContainerUtil.findAll(getDomFileCandidates(description, project), new Condition<VirtualFile>() {
45 public boolean value(final VirtualFile file) {
46 return scope.contains(file);
51 public abstract Collection<VirtualFile> getDomFileCandidates(Class<? extends DomElement> description, Project project);
53 public abstract <T extends DomElement> List<DomFileElement<T>> getFileElements(Class<T> clazz, final Project project, @Nullable GlobalSearchScope scope);
55 public abstract ModelMerger createModelMerger();
58 public abstract XmlFile getContainingFile(@NotNull DomElement domElement);
61 public abstract EvaluatedXmlName getEvaluatedXmlName(@NotNull DomElement element);
63 public enum StructureViewMode {
64 SHOW, SHOW_CHILDREN, SKIP
66 public abstract StructureViewBuilder createSimpleStructureViewBuilder(final XmlFile file, final Function<DomElement, StructureViewMode> modeProvider);