diff --git a/platform/core-api/src/com/intellij/psi/PsiFileFactory.java b/platform/core-api/src/com/intellij/psi/PsiFileFactory.java index 9cc652443a0d..600d02ad7cc5 100644 --- a/platform/core-api/src/com/intellij/psi/PsiFileFactory.java +++ b/platform/core-api/src/com/intellij/psi/PsiFileFactory.java @@ -7,6 +7,7 @@ import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -22,7 +23,7 @@ public abstract class PsiFileFactory { } /** - * Please use {@link #createFileFromText(String, com.intellij.openapi.fileTypes.FileType, CharSequence)}, + * Please use {@link #createFileFromText(String, FileType, CharSequence)} instead, * since file type detecting by file extension becomes vulnerable when file type mappings are changed. *

* Creates a file from the specified text. @@ -30,42 +31,42 @@ public abstract class PsiFileFactory { * @param name the name of the file to create (the extension of the name determines the file type). * @param text the text of the file to create. * @return the created file. - * @throws com.intellij.util.IncorrectOperationException + * @throws IncorrectOperationException * if the file type with specified extension is binary. */ @Deprecated @NotNull - public abstract PsiFile createFileFromText(@NotNull @NonNls String name, @NotNull @NonNls String text); + public abstract PsiFile createFileFromText(@NotNull @NonNls String name, @NotNull @NonNls String text) throws IncorrectOperationException; @NotNull - public abstract PsiFile createFileFromText(@NonNls @NotNull String fileName, @NotNull FileType fileType, @NotNull CharSequence text); + public abstract PsiFile createFileFromText(@NonNls @NotNull String fileName, @NotNull FileType fileType, @NotNull CharSequence text) throws IncorrectOperationException; @NotNull public abstract PsiFile createFileFromText(@NonNls @NotNull String name, @NotNull FileType fileType, @NotNull CharSequence text, - long modificationStamp, boolean eventSystemEnabled); + long modificationStamp, boolean eventSystemEnabled) throws IncorrectOperationException; @NotNull public abstract PsiFile createFileFromText(@NonNls @NotNull String name, @NotNull FileType fileType, @NotNull CharSequence text, - long modificationStamp, boolean eventSystemEnabled, boolean markAsCopy); + long modificationStamp, boolean eventSystemEnabled, boolean markAsCopy) throws IncorrectOperationException; - public abstract PsiFile createFileFromText(@NotNull String name, @NotNull Language language, @NotNull CharSequence text); + public abstract PsiFile createFileFromText(@NotNull String name, @NotNull Language language, @NotNull CharSequence text) throws IncorrectOperationException; - public PsiFile createFileFromText(@NotNull Language language, @NotNull CharSequence text) { + public PsiFile createFileFromText(@NotNull Language language, @NotNull CharSequence text) throws IncorrectOperationException { return createFileFromText("foo.bar", language, text); } public abstract PsiFile createFileFromText(@NotNull String name, @NotNull Language language, @NotNull CharSequence text, - boolean eventSystemEnabled, boolean markAsCopy); + boolean eventSystemEnabled, boolean markAsCopy) throws IncorrectOperationException; public abstract PsiFile createFileFromText(@NotNull String name, @NotNull Language language, @NotNull CharSequence text, - boolean eventSystemEnabled, boolean markAsCopy, boolean noSizeLimit); + boolean eventSystemEnabled, boolean markAsCopy, boolean noSizeLimit) throws IncorrectOperationException; public abstract PsiFile createFileFromText(@NotNull String name, @NotNull Language language, @NotNull CharSequence text, boolean eventSystemEnabled, boolean markAsCopy, boolean noSizeLimit, - @Nullable VirtualFile original); + @Nullable VirtualFile original) throws IncorrectOperationException; - public abstract PsiFile createFileFromText(FileType fileType, String fileName, CharSequence chars, int startOffset, int endOffset); + public abstract PsiFile createFileFromText(FileType fileType, String fileName, CharSequence chars, int startOffset, int endOffset) throws IncorrectOperationException; @Nullable - public abstract PsiFile createFileFromText(@NotNull CharSequence chars, @NotNull PsiFile original); + public abstract PsiFile createFileFromText(@NotNull CharSequence chars, @NotNull PsiFile original) throws IncorrectOperationException; } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/find/FindProgressIndicator.java b/platform/lang-impl/src/com/intellij/find/FindProgressIndicator.java index d0448217cee1..ee653ec1e4d9 100644 --- a/platform/lang-impl/src/com/intellij/find/FindProgressIndicator.java +++ b/platform/lang-impl/src/com/intellij/find/FindProgressIndicator.java @@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull; * @author ven */ public class FindProgressIndicator extends BackgroundableProcessIndicator { - public FindProgressIndicator(@NotNull Project project, String scopeString) { + public FindProgressIndicator(@NotNull Project project, @NotNull String scopeString) { super(project, FindBundle.message("find.progress.searching.message", scopeString), new SearchInBackgroundOption(), diff --git a/platform/platform-impl/src/com/intellij/codeInsight/hint/HintManagerImpl.java b/platform/platform-impl/src/com/intellij/codeInsight/hint/HintManagerImpl.java index 92af48d2d7f8..c72af293b9d4 100644 --- a/platform/platform-impl/src/com/intellij/codeInsight/hint/HintManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/codeInsight/hint/HintManagerImpl.java @@ -258,6 +258,7 @@ public class HintManagerImpl extends HintManager { * So, first of all, editor will be scrolled to make the caret position visible. */ public void showEditorHint(final LightweightHint hint, final Editor editor, @PositionFlags final short constraint, @HideFlags final int flags, final int timeout, final boolean reviveOnEditorChange) { + ApplicationManager.getApplication().assertIsDispatchThread(); editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); editor.getScrollingModel().runActionOnScrollingFinished(() -> { LogicalPosition pos = editor.getCaretModel().getLogicalPosition(); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/ScrollingModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/ScrollingModelImpl.java index c99954f41523..f2c9257e9fa6 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/ScrollingModelImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/ScrollingModelImpl.java @@ -4,7 +4,7 @@ package com.intellij.openapi.editor.impl; import com.intellij.ide.RemoteDesktopService; import com.intellij.openapi.Disposable; -import com.intellij.openapi.application.ex.ApplicationManagerEx; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.LogicalPosition; @@ -39,8 +39,8 @@ public class ScrollingModelImpl implements ScrollingModelEx { private final List myVisibleAreaListeners = ContainerUtil.createLockFreeCopyOnWriteList(); private final List myScrollRequestListeners = ContainerUtil.createLockFreeCopyOnWriteList(); - private AnimatedScrollingRunnable myCurrentAnimationRequest = null; - private boolean myAnimationDisabled = false; + private AnimatedScrollingRunnable myCurrentAnimationRequest; + private boolean myAnimationDisabled; private int myAccumulatedXOffset = -1; private int myAccumulatedYOffset = -1; @@ -161,7 +161,7 @@ public class ScrollingModelImpl implements ScrollingModelEx { } private static void assertIsDispatchThread() { - ApplicationManagerEx.getApplicationEx().assertIsDispatchThread(); + ApplicationManager.getApplication().assertIsDispatchThread(); } @Override @@ -225,7 +225,7 @@ public class ScrollingModelImpl implements ScrollingModelEx { // to avoid 'hysteresis', minAcceptableY should be always less or equal to maxAcceptableY int minAcceptableY = viewRect.y + Math.max(0, Math.min(lineHeight, viewRect.height - 3 * lineHeight)); int maxAcceptableY = viewRect.y + (viewRect.height <= lineHeight ? 0 : - (viewRect.height - (viewRect.height <= 2 * lineHeight ? lineHeight : 2 * lineHeight))); + viewRect.height - (viewRect.height <= 2 * lineHeight ? lineHeight : 2 * lineHeight)); int scrollUpBy = minAcceptableY - targetLocation.y; int scrollDownBy = targetLocation.y - maxAcceptableY; int centerPosition = targetLocation.y - viewRect.height / 3; @@ -496,7 +496,7 @@ public class ScrollingModelImpl implements ScrollingModelEx { myAnimator = new Animator("Animated scroller", myStepCount, SCROLL_DURATION, false, true) { @Override public void paintNow(int frame, int totalFrames, int cycle) { - double time = ((double)(frame + 1)) / (double)totalFrames; + double time = (frame + 1.0) / totalFrames; double fraction = timeToFraction(time); final int hOffset = (int)(myStartHOffset + (myEndHOffset - myStartHOffset) * fraction + 0.5); @@ -518,7 +518,7 @@ public class ScrollingModelImpl implements ScrollingModelEx { } @NotNull - public Rectangle getTargetVisibleArea() { + Rectangle getTargetVisibleArea() { Rectangle viewRect = getVisibleArea(); return new Rectangle(myEndHOffset, myEndVOffset, viewRect.width, viewRect.height); } @@ -528,7 +528,7 @@ public class ScrollingModelImpl implements ScrollingModelEx { finish(scrollToTarget); } - public void addPostRunnable(Runnable runnable) { + void addPostRunnable(Runnable runnable) { myPostRunnables.add(runnable); } @@ -559,7 +559,7 @@ public class ScrollingModelImpl implements ScrollingModelEx { double fraction = Math.pow(time * 2, myPow) / 2; if (myTotalDist > myMaxDistToScroll) { - fraction *= (double)myMaxDistToScroll / myTotalDist; + fraction *= myMaxDistToScroll / myTotalDist; } return fraction; diff --git a/xml/xml-psi-api/src/com/intellij/psi/XmlElementFactory.java b/xml/xml-psi-api/src/com/intellij/psi/XmlElementFactory.java index 517878a2bffd..e4eb9fe6ff57 100644 --- a/xml/xml-psi-api/src/com/intellij/psi/XmlElementFactory.java +++ b/xml/xml-psi-api/src/com/intellij/psi/XmlElementFactory.java @@ -30,7 +30,6 @@ import org.jetbrains.annotations.Nullable; * @author Dmitry Avdeev */ public abstract class XmlElementFactory { - public static XmlElementFactory getInstance(Project project) { return ServiceManager.getService(project, XmlElementFactory.class); } @@ -40,7 +39,7 @@ public abstract class XmlElementFactory { * * @param s the text of the element to create. * @return the created element. - * @throws com.intellij.util.IncorrectOperationException if the creation failed for some reason. + * @throws IncorrectOperationException if the creation failed for some reason. */ @NotNull public abstract XmlText createDisplayText(@NotNull @NonNls String s) throws IncorrectOperationException; @@ -70,7 +69,7 @@ public abstract class XmlElementFactory { * * @param text the text of an XML tag (which can contain attributes and subtags). * @return the created tag instance. - * @throws com.intellij.util.IncorrectOperationException if the text does not specify a valid XML fragment. + * @throws IncorrectOperationException if the text does not specify a valid XML fragment. * @see #createTagFromText(CharSequence text, Language language) */ @NotNull @@ -82,7 +81,7 @@ public abstract class XmlElementFactory { * @param text the text of an XML tag (which can contain attributes and subtags). * @param language the language for tag to be created. * @return the created tag instance. - * @throws com.intellij.util.IncorrectOperationException if the text does not specify a valid XML fragment. + * @throws IncorrectOperationException if the text does not specify a valid XML fragment. * @see #createTagFromText(CharSequence) */ @NotNull