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
.editor
.impl
;
18 import com
.intellij
.openapi
.components
.ProjectComponent
;
19 import com
.intellij
.openapi
.diagnostic
.Logger
;
20 import com
.intellij
.openapi
.project
.Project
;
21 import com
.intellij
.util
.containers
.WeakHashMap
;
22 import org
.jetbrains
.annotations
.NotNull
;
29 public class DocumentMarkupModelManager
implements ProjectComponent
{
30 private static final Logger LOG
= Logger
.getInstance("#com.intellij.openapi.editor.impl.DocumentMarkupModelManager");
32 private final WeakHashMap
<DocumentImpl
,String
> myDocumentSet
= new WeakHashMap
<DocumentImpl
, String
>();
33 private final Project myProject
;
34 private boolean myIsDisposed
= false;
36 public static DocumentMarkupModelManager
getInstance(Project project
) {
37 return project
.getComponent(DocumentMarkupModelManager
.class);
40 public DocumentMarkupModelManager(Project project
) {
44 public void projectOpened() {
47 public void projectClosed() {
51 public void registerDocument(DocumentImpl doc
) {
52 LOG
.assertTrue(!myIsDisposed
);
53 myDocumentSet
.put(doc
, "");
57 public String
getComponentName() {
58 return "DocumentMarkupModelManager";
61 public boolean isDisposed() {
65 public void initComponent() { }
67 public void disposeComponent() {
71 private void cleanup() {
74 Set
<DocumentImpl
> docs
= myDocumentSet
.keySet();
75 for (DocumentImpl doc
: docs
) {
76 doc
.removeMarkupModel(myProject
);