Get rid of redundant local variables

This commit is contained in:
Pavel Dolgov
2018-09-05 18:17:47 +03:00
parent 73c58e0cdc
commit aef071388f
19 changed files with 22 additions and 46 deletions
@@ -109,8 +109,7 @@ public class ObjectReferenceProxyImpl extends JdiProxy {
}
if(this == o) return true;
ObjectReference ref = myObjectReference;
return ref.equals(((ObjectReferenceProxyImpl)o).myObjectReference);
return myObjectReference.equals(((ObjectReferenceProxyImpl)o).myObjectReference);
}
@@ -159,8 +159,7 @@ public class ExpectedTypeInfoImpl implements ExpectedTypeInfo {
if (info1.type.isAssignableFrom(type)) return new ExpectedTypeInfoImpl[] {info1};
}
else if (info1.kind == TYPE_OR_SUBTYPE) {
PsiType otherType = info1.type;
if (otherType.isAssignableFrom(type)) return new ExpectedTypeInfoImpl[] {this};
if (info1.type.isAssignableFrom(type)) return new ExpectedTypeInfoImpl[] {this};
}
else if (info1.kind == TYPE_OR_SUPERTYPE) {
PsiType otherType = info1.type;
@@ -118,9 +118,8 @@ public class PackageNode extends PackageDependenciesNode {
@Override
public boolean canSelectInLeftTree(final Map<PsiFile, Set<PsiFile>> deps) {
Set<PsiFile> files = deps.keySet();
String packageName = myPackageQName;
for (PsiFile file : files) {
if (file instanceof PsiJavaFile && Comparing.equal(packageName, ((PsiJavaFile)file).getPackageName())) {
if (file instanceof PsiJavaFile && Comparing.equal(myPackageQName, ((PsiJavaFile)file).getPackageName())) {
return true;
}
}
@@ -442,7 +442,6 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper {
}
if (!(param instanceof PsiClassType)) return null;
PsiManager manager = myManager;
if (arg instanceof PsiPrimitiveType) {
if (!JavaVersionService.getInstance().isAtLeast(typeParam, JavaSdkVersion.JDK_1_7) && !isContraVariantPosition) return null;
arg = ((PsiPrimitiveType)arg).getBoxedType(typeParam);
@@ -477,7 +476,7 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper {
PsiClass argClass = (PsiClass)argResult.getElement();
if (argClass == null) return null;
PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
PsiElementFactory factory = JavaPsiFacade.getInstance(myManager.getProject()).getElementFactory();
PsiType patternType = factory.createType(typeParam);
if (isContraVariantPosition) {
PsiSubstitutor substitutor = TypeConversionUtil.getClassSubstitutor(paramClass, argClass, argResult.getSubstitutor());
@@ -104,8 +104,7 @@ public class FavoritesTreeUtil {
@Nullable
public static FavoritesListNode extractParentList(FavoritesTreeNodeDescriptor descriptor) {
final AbstractTreeNode node = descriptor.getElement();
AbstractTreeNode current = node;
AbstractTreeNode current = descriptor.getElement();
while (current != null) {
if (current instanceof FavoritesListNode) {
return (FavoritesListNode)current;
@@ -212,9 +212,8 @@ public class BlockViewerPsiBasedTree implements ViewerPsiBasedTree {
if (!(item instanceof BlockTreeNode)) return;
BlockTreeNode descriptor = (BlockTreeNode)item;
PsiElement rootPsi = myRootElement;
int blockStart = descriptor.getBlock().getTextRange().getStartOffset();
PsiFile file = rootPsi.getContainingFile();
PsiFile file = myRootElement.getContainingFile();
PsiElement currentPsiEl = InjectedLanguageUtil.findElementAtNoCommit(file, blockStart);
if (currentPsiEl == null) currentPsiEl = file;
int blockLength = descriptor.getBlock().getTextRange().getLength();
@@ -78,11 +78,7 @@ public class FileTypeConfigurable implements SearchableConfigurable, Configurabl
private void updateFileTypeList() {
FileType[] types = myTempFileTypes.toArray(FileType.EMPTY_ARRAY);
Arrays.sort(types, (o1, o2) -> {
FileType fileType1 = (FileType)o1;
FileType fileType2 = (FileType)o2;
return fileType1.getDescription().compareToIgnoreCase(fileType2.getDescription());
});
Arrays.sort(types, (o1, o2) -> o1.getDescription().compareToIgnoreCase(o2.getDescription()));
myRecognizedFileType.setFileTypes(types);
}
@@ -138,8 +138,7 @@ public class FormattingDocumentModelImpl implements FormattingDocumentModel {
@Override
public boolean containsWhiteSpaceSymbolsOnly(int startOffset, int endOffset) {
WhiteSpaceFormattingStrategy strategy = myWhiteSpaceStrategy;
if (strategy.check(myDocument.getCharsSequence(), startOffset, endOffset) >= endOffset) {
if (myWhiteSpaceStrategy.check(myDocument.getCharsSequence(), startOffset, endOffset) >= endOffset) {
return true;
}
PsiElement injectedElement = InjectedLanguageUtil.findElementAtNoCommit(myFile, startOffset);
@@ -31,9 +31,8 @@ public class Highlighters implements DnDEvent.DropTargetHighlightingType {
static void show(int aType, JLayeredPane aPane, Rectangle aRectangle, DnDEvent aEvent) {
List<DropTargetHighlighter> toShow = new ArrayList<>();
for (DropTargetHighlighter ourHightlighter : ourHightlighters) {
DropTargetHighlighter each = (DropTargetHighlighter)ourHightlighter;
if ((each.getMask() & aType) != 0) {
toShow.add(each);
if ((ourHightlighter.getMask() & aType) != 0) {
toShow.add(ourHightlighter);
}
}
@@ -163,7 +163,7 @@ public class ProcessPopup {
myActiveFocusedContent.add(wrapper, BorderLayout.CENTER);
final JScrollPane scrolls = new JBScrollPane(myActiveFocusedContent) {
myActiveContentComponent = new JBScrollPane(myActiveFocusedContent) {
@Override
public Dimension getPreferredSize() {
if (myProcessBox.getComponentCount() > 0) {
@@ -173,7 +173,6 @@ public class ProcessPopup {
}
}
};
myActiveContentComponent = scrolls;
updateContentUI();
}
@@ -857,7 +857,6 @@ public class IdeFrameFixture extends ComponentFixture<IdeFrameFixture, IdeFrameI
// "{@code level} * {@code numIndentSpaces}" whitespaces. Each node is printed on a separate line. The indent level for every child node
// is 1 more than their parent.
private static void printNode(XDebuggerTreeNode node, StringBuilder builder, int level, int numIndentSpaces) {
int numIndent = level;
if (builder.length() > 0) {
builder.append(System.getProperty("line.separator"));
}
@@ -84,11 +84,10 @@ public class VcsAnnotationCachedProxy implements AnnotationProvider {
*/
private FileAnnotation annotate(VirtualFile file, final VcsRevisionNumber revisionNumber, final boolean currentRevision,
final ThrowableComputable<FileAnnotation, VcsException> delegate) throws VcsException {
final AnnotationProvider annotationProvider = myAnnotationProvider;
final FilePath filePath = VcsUtil.getFilePath(file);
final VcsCacheableAnnotationProvider cacheableAnnotationProvider = (VcsCacheableAnnotationProvider)annotationProvider;
final VcsCacheableAnnotationProvider cacheableAnnotationProvider = (VcsCacheableAnnotationProvider)myAnnotationProvider;
VcsAnnotation vcsAnnotation = null;
if (revisionNumber != null) {
@@ -87,10 +87,9 @@ public class LineReader {
return getLineArray();
}
}
final byte[] buffer = myBuffer;
while (myBytesBuffered != -1) {
for (; myPosition < myBytesBuffered; myPosition++) {
final byte c = buffer[myPosition];
final byte c = myBuffer[myPosition];
switch (c) {
case '\r':
if (myLastEol == '\r') {
@@ -216,8 +216,7 @@ final public class LogMessageParser extends AbstractMessageParser {
return;
}
if (line.startsWith(TOTAL_REVISIONS)) {
final String separator = SELECTED_REVISIONS;
final int semicolonIndex = line.indexOf(separator);
final int semicolonIndex = line.indexOf(SELECTED_REVISIONS);
if (semicolonIndex < 0) {
// no selected revisions here..
logInfo.setTotalRevisions(line.substring(TOTAL_REVISIONS.length()).trim());
@@ -601,9 +601,8 @@ public class DependencyResolverImpl implements DependencyResolver {
File artifactDir = parents.get(parents.size() - 2);
File versionDir = parents.get(parents.size() - 3);
File parentFile = versionDir;
if (parentFile != null) {
File[] hashDirs = parentFile.listFiles();
if (versionDir != null) {
File[] hashDirs = versionDir.listFiles();
if (hashDirs != null) {
for (File hashDir : hashDirs) {
File[] sourcesJars = hashDir.listFiles(new FilenameFilter() {
@@ -210,9 +210,8 @@ public class MvcProjectViewPane extends AbstractProjectViewPSIPane implements Id
@NotNull
@Override
protected ProjectAbstractTreeStructureBase createStructure() {
final Project project = myProject;
final String id = getId();
return new ProjectTreeStructure(project, id) {
return new ProjectTreeStructure(myProject, id) {
@Override
public boolean isHideEmptyMiddlePackages() {
@@ -1056,8 +1056,7 @@ public class RepositoryBrowserDialog extends DialogWrapper {
return;
}
Project p = myProject;
CheckoutOptionsDialog dialog = new CheckoutOptionsDialog(p, url, dir, SvnUtil.getVirtualFile(dir.getAbsolutePath()), relativePath);
CheckoutOptionsDialog dialog = new CheckoutOptionsDialog(myProject, url, dir, SvnUtil.getVirtualFile(dir.getAbsolutePath()), relativePath);
dialog.show();
dir = dialog.getTarget();
if (dialog.isOK() && dir != null) {
@@ -357,8 +357,7 @@ public class SvnInfoHandler extends DefaultHandler {
protected void updateInfo(Attributes attributes, SvnInfoStructure structure) throws SAXException {
final String revision = attributes.getValue("revision");
try {
final long number = Long.parseLong(revision);
structure.myCommittedRevision = number;
structure.myCommittedRevision = Long.parseLong(revision);
} catch (NumberFormatException e) {
throw new SAXException(e);
}
@@ -510,8 +509,7 @@ public class SvnInfoHandler extends DefaultHandler {
@Override
public void characters(String s, SvnInfoStructure structure) throws SAXException {
try {
final long number = Long.parseLong(s);
structure.myCopyFromRevision = number;
structure.myCopyFromRevision = Long.parseLong(s);
} catch (NumberFormatException e) {
throw new SAXException(e);
}
@@ -706,8 +704,7 @@ public class SvnInfoHandler extends DefaultHandler {
final String revision = attributes.getValue("revision");
assertSAX(! StringUtil.isEmptyOrSpaces(revision));
try {
final long number = Long.parseLong(revision);
structure.myRevision = number;
structure.myRevision = Long.parseLong(revision);
} catch (NumberFormatException e) {
structure.myRevision = -1;
//throw new SAXException(e);
@@ -118,8 +118,7 @@ public abstract class AbstractSyntheticBlock implements Block {
}
public boolean isTagDescription() {
final ASTNode startTreeNode = myStartTreeNode;
return isTagDescription(startTreeNode);
return isTagDescription(myStartTreeNode);
}
private static boolean isTagDescription(final ASTNode startTreeNode) {