produce less trash objects

This commit is contained in:
Egor.Ushakov
2014-10-28 21:43:25 +03:00
parent 4d1b545ef9
commit 474dd67a8d
4 changed files with 26 additions and 17 deletions
@@ -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;
@@ -97,7 +97,7 @@ public abstract class JSR45PositionManager<Scope> implements PositionManager {
LOG.info(e);
}
if(sourcePosition == null) {
throw new NoDataException();
throw NoDataException.INSTANCE;
}
return sourcePosition;
}
@@ -135,7 +135,7 @@ public abstract class JSR45PositionManager<Scope> 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;
}
}
@@ -77,11 +77,11 @@ public class GroovyPositionManager implements PositionManager {
List<Location> 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;
}
@@ -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<ReferenceType> referenceTypes = myDebugProcess.getVirtualMachineProxy().classesByName(className);
if (referenceTypes.isEmpty()) throw new NoDataException();
if (referenceTypes.isEmpty()) throw NoDataException.INSTANCE;
Set<ReferenceType> res = new HashSet<ReferenceType>();
@@ -92,7 +92,7 @@ public class SpringLoadedPositionManager implements PositionManager {
}
if (res.isEmpty()) {
throw new NoDataException();
throw NoDataException.INSTANCE;
}
return new ArrayList<ReferenceType>(res);
@@ -101,7 +101,7 @@ public class SpringLoadedPositionManager implements PositionManager {
@NotNull
@Override
public List<Location> 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 + "*");