001    /*
002     * Copyright 2010-2013 JetBrains s.r.o.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package org.jetbrains.jet.cli.jvm.compiler;
018    
019    import com.intellij.codeInsight.BaseExternalAnnotationsManager;
020    import com.intellij.openapi.vfs.VirtualFile;
021    import com.intellij.psi.*;
022    import org.jetbrains.annotations.NotNull;
023    import org.jetbrains.annotations.Nullable;
024    
025    import java.util.ArrayList;
026    import java.util.List;
027    
028    public class CoreExternalAnnotationsManager extends BaseExternalAnnotationsManager {
029        static {
030            // This is an ugly workaround for JDOM 1.1 used from application started from Ant 1.8 without forking
031            System.setProperty("javax.xml.parsers.SAXParserFactory", "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
032        }
033    
034        private final List<VirtualFile> externalAnnotationsRoots = new ArrayList<VirtualFile>();
035    
036        public CoreExternalAnnotationsManager(@NotNull PsiManager psiManager) {
037            super(psiManager);
038        }
039    
040        public void addExternalAnnotationsRoot(VirtualFile externalAnnotationsRoot) {
041            externalAnnotationsRoots.add(externalAnnotationsRoot);
042        }
043    
044        @Override
045        protected boolean hasAnyAnnotationsRoots() {
046            return true;
047        }
048    
049        @NotNull
050        @Override
051        protected List<VirtualFile> getExternalAnnotationsRoots(@NotNull VirtualFile libraryFile) {
052            return externalAnnotationsRoots;
053        }
054    
055        @Override
056        public void annotateExternally(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQName, @NotNull PsiFile fromFile,
057                PsiNameValuePair[] value) {
058            throw new UnsupportedOperationException();
059        }
060    
061        @Override
062        public boolean deannotate(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN) {
063            throw new UnsupportedOperationException();
064        }
065    
066        @Override
067        public boolean editExternalAnnotation(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN,
068                @Nullable PsiNameValuePair[] value) {
069            throw new UnsupportedOperationException();
070        }
071    
072        @Override
073        public AnnotationPlace chooseAnnotationsPlace(@NotNull PsiElement element) {
074            throw new UnsupportedOperationException();
075        }
076    }