+++ /dev/null
-/*
- * Copyright 2000-2015 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * User: anna
- * Date: 25-Jan-2008
- */
-package com.intellij.codeEditor.printing;
-
-import com.intellij.codeInsight.daemon.LineMarkerInfo;
-import com.intellij.codeInsight.daemon.impl.LineMarkersPass;
-import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.psi.PsiFile;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-public class MethodSeparatorProvider extends FileSeparatorProvider {
- @Override
- public List<LineMarkerInfo> getFileSeparators(final PsiFile file, final Document document, @Nullable final Editor editor) {
- final List<LineMarkerInfo> result = new ArrayList<LineMarkerInfo>();
- LineMarkersPass pass = new LineMarkersPass(file.getProject(), file, editor, document, file.getTextRange());
- for (LineMarkerInfo lineMarkerInfo : pass.queryLineMarkers()) {
- if (lineMarkerInfo.separatorColor != null) {
- result.add(lineMarkerInfo);
- }
- }
-
- Collections.sort(result, new Comparator<LineMarkerInfo>() {
- public int compare(final LineMarkerInfo i1, final LineMarkerInfo i2) {
- return i1.startOffset - i2.startOffset;
- }
- });
- return result;
- }
-}
\ No newline at end of file
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.intellij.ide.BrowserUtil;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.extensions.Extensions;
}
}
- private static boolean exportPsiFile(final PsiFile psiFile, String outputDirectoryName, Project project, HashMap<PsiFile, PsiFile> filesMap) {
- ExportToHTMLSettings exportToHTMLSettings = ExportToHTMLSettings.getInstance(project);
+ private static boolean exportPsiFile(final PsiFile psiFile,
+ final String outputDirectoryName,
+ final Project project,
+ final HashMap<PsiFile, PsiFile> filesMap) {
+ final ExportToHTMLSettings exportToHTMLSettings = ExportToHTMLSettings.getInstance(project);
if (psiFile instanceof PsiBinaryFile) {
return true;
}
- TreeMap<Integer, PsiReference> refMap = null;
- for (PrintOption printOption : Extensions.getExtensions(PrintOption.EP_NAME)) {
- final TreeMap<Integer, PsiReference> map = printOption.collectReferences(psiFile, filesMap);
- if (map != null) {
- refMap = new TreeMap<Integer, PsiReference>();
- refMap.putAll(map);
- }
- }
+ ApplicationManager.getApplication().runReadAction(new Runnable() {
+ @Override
+ public void run() {
+ TreeMap<Integer, PsiReference> refMap = null;
+ for (PrintOption printOption : Extensions.getExtensions(PrintOption.EP_NAME)) {
+ final TreeMap<Integer, PsiReference> map = printOption.collectReferences(psiFile, filesMap);
+ if (map != null) {
+ refMap = new TreeMap<Integer, PsiReference>();
+ refMap.putAll(map);
+ }
+ }
- String dirName = constructOutputDirectory(psiFile, outputDirectoryName);
- HTMLTextPainter textPainter = new HTMLTextPainter(psiFile, project, dirName, exportToHTMLSettings.PRINT_LINE_NUMBERS);
- try {
- textPainter.paint(refMap, psiFile.getFileType());
- }
- catch (FileNotFoundException e) {
- myLastException = e;
- return false;
- }
- return true;
+ String dirName = constructOutputDirectory(psiFile, outputDirectoryName);
+ HTMLTextPainter textPainter = new HTMLTextPainter(psiFile, project, dirName, exportToHTMLSettings.PRINT_LINE_NUMBERS);
+ try {
+ textPainter.paint(refMap, psiFile.getFileType());
+ }
+ catch (FileNotFoundException e) {
+ myLastException = e;
+ }
+ }
+ });
+ return myLastException == null;
}
private static String constructOutputDirectory(PsiFile psiFile, String outputDirectoryName) {
final ArrayList<PsiFile> filesList = new ArrayList<PsiFile>();
final boolean isRecursive = myExportToHTMLSettings.isIncludeSubdirectories();
- try {
- addToPsiFileList(myPsiDirectory, filesList, isRecursive, myOutputDirectoryName);
- }
- catch (FileNotFoundException e) {
- myLastException = e;
+ ApplicationManager.getApplication().runReadAction(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ addToPsiFileList(myPsiDirectory, filesList, isRecursive, myOutputDirectoryName);
+ }
+ catch (FileNotFoundException e) {
+ myLastException = e;
+ }
+ }
+ });
+ if (myLastException != null) {
return;
}
HashMap<PsiFile, PsiFile> filesMap = new HashMap<PsiFile, PsiFile>();
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package com.intellij.codeEditor.printing;
import com.intellij.codeInsight.daemon.LineMarkerInfo;
-import com.intellij.openapi.components.ServiceManager;
+import com.intellij.codeInsight.daemon.impl.LineMarkersPass;
import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.Nullable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
public class FileSeparatorProvider {
- public static FileSeparatorProvider getInstance() {
- return ServiceManager.getService(FileSeparatorProvider.class);
- }
-
@Nullable
- public List<LineMarkerInfo> getFileSeparators(PsiFile file, final Document document, @Nullable final Editor editor) {
- return null;
+ public static List<LineMarkerInfo> getFileSeparators(PsiFile file, final Document document) {
+ final List<LineMarkerInfo> result = new ArrayList<LineMarkerInfo>();
+ LineMarkersPass pass = new LineMarkersPass(file.getProject(), file, null, document, file.getTextRange());
+ for (LineMarkerInfo lineMarkerInfo : pass.queryLineMarkers()) {
+ if (lineMarkerInfo.separatorColor != null) {
+ result.add(lineMarkerInfo);
+ }
+ }
+
+ Collections.sort(result, new Comparator<LineMarkerInfo>() {
+ public int compare(final LineMarkerInfo i1, final LineMarkerInfo i2) {
+ return i1.startOffset - i2.startOffset;
+ }
+ });
+ return result;
}
}
\ No newline at end of file
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.intellij.psi.PsiReference;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.impl.file.PsiDirectoryFactory;
-import com.intellij.psi.util.PsiUtilBase;
import com.intellij.ui.JBColor;
import org.jetbrains.annotations.NonNls;
ArrayList<LineMarkerInfo> methodSeparators = new ArrayList<LineMarkerInfo>();
if (document != null) {
- final List<LineMarkerInfo> separators = FileSeparatorProvider.getInstance().getFileSeparators(psiFile, document,
- PsiUtilBase.findEditor(psiFile));
+ final List<LineMarkerInfo> separators = FileSeparatorProvider.getFileSeparators(psiFile, document);
if (separators != null) {
methodSeparators.addAll(separators);
}
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
FileType fileType,
Editor editor) {
this(editorDocument, highlighter, fullFileName, shortFileName, psiFile.getProject(), fileType,
- FileSeparatorProvider.getInstance().getFileSeparators(psiFile, editorDocument, editor));
+ FileSeparatorProvider.getFileSeparators(psiFile, editorDocument));
}
public TextPainter(@NotNull DocumentEx editorDocument,
myMarkers = mergeLineMarkers(lineMarkers, myEditor);
}
- static List<LineMarkerInfo> mergeLineMarkers(@NotNull List<LineMarkerInfo> markers, Editor editor) {
+ static List<LineMarkerInfo> mergeLineMarkers(@NotNull List<LineMarkerInfo> markers, @Nullable Editor editor) {
List<MergeableLineMarkerInfo> forMerge = new ArrayList<MergeableLineMarkerInfo>();
final Iterator<LineMarkerInfo> iterator = markers.iterator();
while (iterator.hasNext()) {
<refactoring.copyHandler implementation="com.intellij.refactoring.copy.CopyFilesOrDirectoriesHandler"/>
<refactoring.moveHandler implementation="com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectoriesHandler" id="moveFileOrDir"/>
- <applicationService serviceInterface="com.intellij.codeEditor.printing.FileSeparatorProvider"
- serviceImplementation="com.intellij.codeEditor.printing.FileSeparatorProvider"/>
<treeStructureProvider implementation="com.intellij.platform.PlatformProjectViewStructureProvider"/>
<macro implementation="com.intellij.ide.macro.OutputPathMacro"/>
<printOption implementation="com.intellij.codeEditor.printing.HyperlinksToClassesOption"/>
- <applicationService serviceInterface="com.intellij.codeEditor.printing.FileSeparatorProvider"
- serviceImplementation="com.intellij.codeEditor.printing.MethodSeparatorProvider"/>
<indexPatternBuilder implementation="com.intellij.psi.impl.search.JavaIndexPatternBuilder"/>
<indexPatternBuilder implementation="com.intellij.psi.impl.search.JspIndexPatternBuilder"/>