From 474dd67a8d169293360d3d86db54b7ff90c44c8d Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Tue, 28 Oct 2014 21:43:25 +0300 Subject: [PATCH] produce less trash objects --- .../com/intellij/debugger/NoDataException.java | 11 ++++++++++- .../debugger/engine/JSR45PositionManager.java | 4 ++-- .../groovy/debugger/GroovyPositionManager.java | 16 ++++++++-------- .../SpringLoadedPositionManager.java | 12 ++++++------ 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/java/debugger/openapi/src/com/intellij/debugger/NoDataException.java b/java/debugger/openapi/src/com/intellij/debugger/NoDataException.java index b3f30af716be..707ba0f445f3 100644 --- a/java/debugger/openapi/src/com/intellij/debugger/NoDataException.java +++ b/java/debugger/openapi/src/com/intellij/debugger/NoDataException.java @@ -15,7 +15,16 @@ */ package com.intellij.debugger; -public class NoDataException extends Exception{ +public class NoDataException extends Exception { + public static final NoDataException INSTANCE = new NoDataException(); + + /** + * @deprecated Use shared {@link com.intellij.debugger.NoDataException#INSTANCE} instead + */ + @Deprecated + public NoDataException() { + } + @Override public Throwable fillInStackTrace() { return this; diff --git a/java/debugger/openapi/src/com/intellij/debugger/engine/JSR45PositionManager.java b/java/debugger/openapi/src/com/intellij/debugger/engine/JSR45PositionManager.java index d33e9ade7e08..df2d9bb2e415 100644 --- a/java/debugger/openapi/src/com/intellij/debugger/engine/JSR45PositionManager.java +++ b/java/debugger/openapi/src/com/intellij/debugger/engine/JSR45PositionManager.java @@ -97,7 +97,7 @@ public abstract class JSR45PositionManager implements PositionManager { LOG.info(e); } if(sourcePosition == null) { - throw new NoDataException(); + throw NoDataException.INSTANCE; } return sourcePosition; } @@ -135,7 +135,7 @@ public abstract class JSR45PositionManager implements PositionManager { private void checkSourcePositionFileType(final SourcePosition classPosition) throws NoDataException { final FileType fileType = classPosition.getFile().getFileType(); if(!myFileTypes.contains(fileType)) { - throw new NoDataException(); + throw NoDataException.INSTANCE; } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyPositionManager.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyPositionManager.java index dbbc4333a02d..74972e6165e1 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyPositionManager.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyPositionManager.java @@ -77,11 +77,11 @@ public class GroovyPositionManager implements PositionManager { List locations = getDebugProcess().getVirtualMachineProxy().versionHigher("1.4") ? type.locationsOfLine(DebugProcess.JAVA_STRATUM, null, line) : type.locationsOfLine(line); - if (locations == null || locations.isEmpty()) throw new NoDataException(); + if (locations == null || locations.isEmpty()) throw NoDataException.INSTANCE; return locations; } catch (AbsentInformationException e) { - throw new NoDataException(); + throw NoDataException.INSTANCE; } } @@ -112,7 +112,7 @@ public class GroovyPositionManager implements PositionManager { private static void checkGroovyFile(@NotNull SourcePosition position) throws NoDataException { if (!(position.getFile() instanceof GroovyFileBase)) { - throw new NoDataException(); + throw NoDataException.INSTANCE; } } @@ -127,7 +127,7 @@ public class GroovyPositionManager implements PositionManager { qName = findEnclosingName(position); - if (qName == null) throw new NoDataException(); + if (qName == null) throw NoDataException.INSTANCE; ClassPrepareRequestor waitRequestor = new ClassPrepareRequestor() { @Override public void processClassPrepare(DebugProcess debuggerProcess, ReferenceType referenceType) { @@ -205,13 +205,13 @@ public class GroovyPositionManager implements PositionManager { @Override public SourcePosition getSourcePosition(final Location location) throws NoDataException { - if (location == null) throw new NoDataException(); + if (location == null) throw NoDataException.INSTANCE; PsiFile psiFile = getPsiFileByLocation(getDebugProcess().getProject(), location); - if (psiFile == null) throw new NoDataException(); + if (psiFile == null) throw NoDataException.INSTANCE; int lineNumber = calcLineIndex(location); - if (lineNumber < 0) throw new NoDataException(); + if (lineNumber < 0) throw NoDataException.INSTANCE; return SourcePosition.createFromLine(psiFile, lineNumber); } @@ -323,7 +323,7 @@ public class GroovyPositionManager implements PositionManager { } }); - if (result == null) throw new NoDataException(); + if (result == null) throw NoDataException.INSTANCE; return result; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/springloaded/SpringLoadedPositionManager.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/springloaded/SpringLoadedPositionManager.java index 6adf50e75094..378c15695fd9 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/springloaded/SpringLoadedPositionManager.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/springloaded/SpringLoadedPositionManager.java @@ -62,7 +62,7 @@ public class SpringLoadedPositionManager implements PositionManager { @Override public SourcePosition getSourcePosition(@Nullable Location location) throws NoDataException { - throw new NoDataException(); + throw NoDataException.INSTANCE; } @NotNull @@ -74,7 +74,7 @@ public class SpringLoadedPositionManager implements PositionManager { AccessToken accessToken = ReadAction.start(); try { className = findEnclosingName(classPosition); - if (className == null) throw new NoDataException(); + if (className == null) throw NoDataException.INSTANCE; line = classPosition.getLine(); } @@ -83,7 +83,7 @@ public class SpringLoadedPositionManager implements PositionManager { } List referenceTypes = myDebugProcess.getVirtualMachineProxy().classesByName(className); - if (referenceTypes.isEmpty()) throw new NoDataException(); + if (referenceTypes.isEmpty()) throw NoDataException.INSTANCE; Set res = new HashSet(); @@ -92,7 +92,7 @@ public class SpringLoadedPositionManager implements PositionManager { } if (res.isEmpty()) { - throw new NoDataException(); + throw NoDataException.INSTANCE; } return new ArrayList(res); @@ -101,7 +101,7 @@ public class SpringLoadedPositionManager implements PositionManager { @NotNull @Override public List locationsOfLine(@NotNull ReferenceType type, @NotNull SourcePosition position) throws NoDataException { - throw new NoDataException(); + throw NoDataException.INSTANCE; } @Nullable @@ -164,7 +164,7 @@ public class SpringLoadedPositionManager implements PositionManager { public ClassPrepareRequest createPrepareRequest(@NotNull ClassPrepareRequestor requestor, @NotNull SourcePosition position) throws NoDataException { String className = getOuterClassName(position); if (className == null) { - throw new NoDataException(); + throw NoDataException.INSTANCE; } return myDebugProcess.getRequestsManager().createClassPrepareRequest(requestor, className + "*");