diff --git a/platform/lang-impl/src/com/intellij/openapi/editor/ex/InjectedAwareEditorRepaintStrategy.java b/platform/lang-impl/src/com/intellij/openapi/editor/ex/InjectedAwareEditorRepaintStrategy.java deleted file mode 100644 index 30547b3c1b91..000000000000 --- a/platform/lang-impl/src/com/intellij/openapi/editor/ex/InjectedAwareEditorRepaintStrategy.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2000-2011 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. - */ -package com.intellij.openapi.editor.ex; - -import com.intellij.injected.editor.DocumentWindow; -import com.intellij.openapi.editor.RangeMarker; -import com.intellij.openapi.editor.impl.EditorRepaintStrategy; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.TextRange; -import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.PsiFile; -import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -/** - * This strategy handles the situation when typing is performed inside parsed injected text. Usually editor's highlighter - * doesn't know anything about injected context internals and sees it just as a single big token (e.g. MXML files may contain - * Flash code inside CDATA comment and the highlighter (based on XML lexer) considers the whole Flash code block to be just - * a CDATA token). - *

- * So, every time user types at injected context, highlighter receives document change event and asks editor to repaint - * affected token. That is rather heavy operation if performed frequently for the large text range. That's why current - * strategy handles such requests to the whole injected context repaint and skips them. - *

- * It's assumed that corresponding repainting is performed during editor's markup model updates triggered by injected - * context processing. - * - * @author Denis Zhdanov - * @since 6/17/11 11:16 AM - */ -public class InjectedAwareEditorRepaintStrategy implements EditorRepaintStrategy { - - @Override - public TextRange adjustHighlighterRegion(@NotNull EditorEx editor, int startOffset, int endOffset) { - return isInjectedContext(editor, startOffset, endOffset) ? null : new TextRange(startOffset, endOffset); - } - - private static boolean isInjectedContext(@NotNull EditorEx editor, int startOffset, int endOffset) { - final Project project = editor.getProject(); - if (project == null) { - return false; - } - final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project); - final PsiFile psiFile = documentManager.getCachedPsiFile(editor.getDocument()); - if (psiFile == null) { - return false; - } - - final List injectedDocuments = InjectedLanguageUtil.getCachedInjectedDocuments(psiFile); - for (DocumentWindow injectedDocument : injectedDocuments) { - if (injectedDocument.containsRange(startOffset, endOffset)) { - return true; - } - } - return false; - } -} diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/ComplementaryFontsRegistry.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/ComplementaryFontsRegistry.java index 9d5b2e3f5f03..4779a17076b5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/ComplementaryFontsRegistry.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/ComplementaryFontsRegistry.java @@ -18,6 +18,7 @@ package com.intellij.openapi.editor.impl; import com.intellij.openapi.application.ApplicationManager; import gnu.trove.TIntHashSet; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import java.awt.*; import java.util.ArrayList; @@ -31,7 +32,7 @@ public class ComplementaryFontsRegistry { private static final Object lock = new String("common lock"); private static final ArrayList ourFontNames; private static final LinkedHashMap ourUsedFonts; - private static FontKey ourSharedKeyInstance = new FontKey(null, 0, 0); + private static FontKey ourSharedKeyInstance = new FontKey("", 0, 0); private static FontInfo ourSharedDefaultFont; private static final TIntHashSet ourUndisplayableChars = new TIntHashSet(); @@ -43,7 +44,7 @@ public class ComplementaryFontsRegistry { public int mySize; public int myStyle; - public FontKey(final String familyName, final int size, final int style) { + public FontKey(@NotNull String familyName, final int size, final int style) { myFamilyName = familyName; mySize = size; myStyle = style; @@ -86,7 +87,7 @@ public class ComplementaryFontsRegistry { ourUsedFonts = new LinkedHashMap(); } - public static FontInfo getFontAbleToDisplay(char c, int size, int style, String defaultFontFamily) { + public static FontInfo getFontAbleToDisplay(char c, int size, int style, @NotNull String defaultFontFamily) { synchronized (lock) { if (ourSharedKeyInstance.mySize == size && ourSharedKeyInstance.myStyle == style && @@ -108,7 +109,7 @@ public class ComplementaryFontsRegistry { if (defaultFont == null) { defaultFont = new FontInfo(defaultFontFamily, size, style); ourUsedFonts.put(ourSharedKeyInstance, defaultFont); - ourSharedKeyInstance = new FontKey(null, 0, 0); + ourSharedKeyInstance = new FontKey("", 0, 0); } ourSharedDefaultFont = defaultFont; diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index 463d744bda53..bcf919d8a036 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -51,7 +51,6 @@ import com.intellij.openapi.editor.impl.softwrap.SoftWrapAppliancePlaces; import com.intellij.openapi.editor.impl.softwrap.SoftWrapDrawingType; import com.intellij.openapi.editor.impl.softwrap.SoftWrapHelper; import com.intellij.openapi.editor.markup.*; -import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory; import com.intellij.openapi.options.FontSize; @@ -134,8 +133,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi private final EditorGutterComponentImpl myGutterComponent; static { - @SuppressWarnings({"UnusedDeclaration"}) - ComplementaryFontsRegistry registry; // load costly font info + ComplementaryFontsRegistry.getFontAbleToDisplay(' ', 0,0,""); // load costly font info } private final CommandProcessor myCommandProcessor; @@ -1328,22 +1326,9 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi } int startOffsetToUse = startOffset; - int endOffsetToUse = endOffset; + int endOffsetToUse = Math.min(endOffset, myDocument.getTextLength()); assertIsDispatchThread(); - if (endOffsetToUse > myDocument.getTextLength()) { - endOffsetToUse = myDocument.getTextLength(); - } - - for (EditorRepaintStrategy repaintStrategy : Extensions.getExtensions(EditorRepaintStrategy.EP_NAME)) { - final TextRange range = repaintStrategy.adjustHighlighterRegion(this, startOffsetToUse, endOffsetToUse); - if (range == null) { - return; - } - startOffsetToUse = range.getStartOffset(); - endOffsetToUse = range.getEndOffset(); - } - // We do repaint in case of equal offsets because there is a possible case that there is a soft wrap at the same offset and // it does occupy particular amount of visual space that may be necessary to repaint. if (startOffsetToUse <= endOffsetToUse) { @@ -4114,7 +4099,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi return insets.bottom + incrButtonValue.getHeight(); } catch (Exception exc) { - throw new IllegalStateException(exc.getMessage()); + throw new IllegalStateException(exc); } } else if (APPLE_LAF_AQUA_SCROLL_BAR_UI_CLASS.equals(barUI.getClass().getName())) { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorRepaintStrategy.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorRepaintStrategy.java deleted file mode 100644 index 315c7816525f..000000000000 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorRepaintStrategy.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2000-2011 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. - */ -package com.intellij.openapi.editor.impl; - -import com.intellij.openapi.editor.ex.EditorEx; -import com.intellij.openapi.extensions.ExtensionPointName; -import com.intellij.openapi.util.TextRange; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Defines contract for the strategy that may adjust/control editor's repainting. - * - * @author Denis Zhdanov - * @since 6/17/11 11:04 AM - */ -public interface EditorRepaintStrategy { - - ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.editorRepaintStrategy"); - - /** - * Asks current strategy to adjust (if necessary) target document region repaint request received from the given editor's highlighter. - * - * @param editor target editor - * @param startOffset start offset of the document text range requested to be repainted (inclusive) - * @param endOffset end offset of the document text range requested to be repainted (exclusive) - * @return actual text range to repaint (if any); null as an indication that no further processing - * for the current repaint request should be performed - */ - @Nullable - TextRange adjustHighlighterRegion(@NotNull EditorEx editor, int startOffset, int endOffset); -} diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml index 9978a033babe..d967fc9fd69e 100644 --- a/platform/platform-resources/src/META-INF/LangExtensions.xml +++ b/platform/platform-resources/src/META-INF/LangExtensions.xml @@ -496,7 +496,6 @@ - diff --git a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml index 70adb7d38066..49801499e884 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml @@ -115,8 +115,7 @@ - - +