001 /* 002 * Copyright 2010-2014 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.openapi.editor.Document; 020 import com.intellij.openapi.fileEditor.FileDocumentManager; 021 import com.intellij.openapi.util.Computable; 022 import com.intellij.openapi.vfs.VirtualFile; 023 import com.intellij.psi.PsiDocumentManager; 024 import com.intellij.psi.PsiFile; 025 import org.jetbrains.annotations.NotNull; 026 import org.jetbrains.annotations.Nullable; 027 028 import java.util.Collection; 029 030 // copied from com.intellij.mock.MockPsiDocumentManager 031 public class MockPsiDocumentManager extends PsiDocumentManager { 032 @Override 033 @Nullable 034 public PsiFile getPsiFile(@NotNull Document document) { 035 throw new UnsupportedOperationException("Method getPsiFile is not yet implemented in " + getClass().getName()); 036 } 037 038 @Override 039 @Nullable 040 public PsiFile getCachedPsiFile(@NotNull Document document) { 041 throw new UnsupportedOperationException("Method getCachedPsiFile is not yet implemented in " + getClass().getName()); 042 } 043 044 @Override 045 @Nullable 046 public Document getDocument(@NotNull PsiFile file) { 047 return null; 048 } 049 050 @Override 051 @Nullable 052 public Document getCachedDocument(@NotNull PsiFile file) { 053 VirtualFile vFile = file.getViewProvider().getVirtualFile(); 054 return FileDocumentManager.getInstance().getCachedDocument(vFile); 055 } 056 057 @Override 058 public void commitAllDocuments() { 059 } 060 061 @Override 062 public void performForCommittedDocument(@NotNull final Document document, @NotNull final Runnable action) { 063 action.run(); 064 } 065 066 @Override 067 public void commitDocument(@NotNull Document document) { 068 } 069 070 @NotNull 071 @Override 072 public CharSequence getLastCommittedText(@NotNull Document document) { 073 return document.getImmutableCharSequence(); 074 } 075 076 @Override 077 @NotNull 078 public Document[] getUncommittedDocuments() { 079 throw new UnsupportedOperationException("Method getUncommittedDocuments is not yet implemented in " + getClass().getName()); 080 } 081 082 @Override 083 public boolean isUncommited(@NotNull Document document) { 084 throw new UnsupportedOperationException("Method isUncommited is not yet implemented in " + getClass().getName()); 085 } 086 087 @Override 088 public boolean isCommitted(@NotNull Document document) { 089 throw new UnsupportedOperationException(); 090 } 091 092 @Override 093 public boolean hasUncommitedDocuments() { 094 throw new UnsupportedOperationException("Method hasUncommitedDocuments is not yet implemented in " + getClass().getName()); 095 } 096 097 @Override 098 public void commitAndRunReadAction(@NotNull Runnable runnable) { 099 throw new UnsupportedOperationException("Method commitAndRunReadAction is not yet implemented in " + getClass().getName()); 100 } 101 102 @Override 103 public <T> T commitAndRunReadAction(@NotNull Computable<T> computation) { 104 throw new UnsupportedOperationException("Method commitAndRunReadAction is not yet implemented in " + getClass().getName()); 105 } 106 107 @Override 108 public void addListener(@NotNull Listener listener) { 109 throw new UnsupportedOperationException("Method addListener is not yet implemented in " + getClass().getName()); 110 } 111 112 @Override 113 public void removeListener(@NotNull Listener listener) { 114 throw new UnsupportedOperationException("Method removeListener is not yet implemented in " + getClass().getName()); 115 } 116 117 @Override 118 public boolean isDocumentBlockedByPsi(@NotNull Document doc) { 119 throw new UnsupportedOperationException("Method isDocumentBlockedByPsi is not yet implemented in " + getClass().getName()); 120 } 121 122 @Override 123 public void doPostponedOperationsAndUnblockDocument(@NotNull Document doc) { 124 throw new UnsupportedOperationException( 125 "Method doPostponedOperationsAndUnblockDocument is not yet implemented in " + getClass().getName()); 126 } 127 128 @Override 129 public boolean performWhenAllCommitted(@NotNull Runnable action) { 130 throw new UnsupportedOperationException(); 131 } 132 133 @Override 134 public void reparseFiles(@NotNull Collection<VirtualFile> files, boolean includeOpenFiles) { 135 throw new UnsupportedOperationException(); 136 } 137 }