the "optimize imports" option on reformat mxml file could / should be enabled (IDEA...
[fedora-idea.git] / lang-api / src / com / intellij / lang / ImportOptimizer.java
blobc4c84f05c0ecd36c9d484e616ff212452711c298
1 /*
2 * Copyright 2000-2007 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.lang;
19 import com.intellij.psi.PsiFile;
20 import org.jetbrains.annotations.NotNull;
22 /**
23 * Implementors of the interface encapsulate optimize imports process for the language.
24 * @author max
25 * @see ImportOptimizer2
27 public interface ImportOptimizer {
28 /**
29 * Implementors of the method are expected to perform all necessary calculations synchronously and return a <code>Runnable</code>,
30 * which performs modifications based on preprocessing results.
31 * processFile() is guaranteed to run with {@link com.intellij.openapi.application.Application#runReadAction(Runnable)} priviledges and
32 * the Runnable returned is guaranteed to run with {@link com.intellij.openapi.application.Application#runWriteAction(Runnable)} privileges.
34 * One can theoretically delay all the calculation until Runnable is called but this code will be executed in Swing thread thus
35 * lenghty calculations may block user interface for some significant time.
37 * @param file to optimize an imports in. It's guaranteed to have a language this <code>ImportOptimizer</code> have been
38 * issued from.
39 * @return a <code>java.lang.Runnable</code> object, which being called will replace original file imports with optimized version.
41 @NotNull
42 Runnable processFile(PsiFile file);