Skip to content

Commit 9a066e9

Browse files
committed
Cosmetic changes, unused code removed
1 parent c80b99c commit 9a066e9

File tree

9 files changed

+39
-253
lines changed

9 files changed

+39
-253
lines changed

src/main/java/org/jetbrains/plugins/spotbugs/common/util/GuiUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private GuiUtil() {
9191

9292
public static void navigateToElement(final PsiElement psiElement) {
9393
final PsiElement navigationElement = psiElement.getNavigationElement();
94-
if (navigationElement != null && navigationElement instanceof Navigatable && ((Navigatable) navigationElement).canNavigate()) {
94+
if (navigationElement instanceof Navigatable && ((Navigatable) navigationElement).canNavigate()) {
9595
((Navigatable) navigationElement).navigate(true);
9696
}
9797
}

src/main/java/org/jetbrains/plugins/spotbugs/common/util/IdeaUtilImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ public static FileType getFileTypeByName(@NotNull final String filename) {
433433
@Nullable
434434
private static PsiFile getPsiFile(@NotNull final Project project, @NotNull final ExtendedProblemDescriptor problem) {
435435
final PsiFile file = problem.getPsiFile();
436-
return file == null ? null : PsiManager.getInstance(project).findFile(file.getVirtualFile());
436+
return PsiManager.getInstance(project).findFile(file.getVirtualFile());
437437
}
438438

439439

@@ -466,7 +466,7 @@ public static PsiElement findAnonymousClassPsiElement(@Nullable final PsiFileSys
466466
@Nullable
467467
public static String getFirstProjectRootPath(final Project project) {
468468
final ProjectRootManager projectManager = ProjectRootManager.getInstance(project);
469-
final VirtualFile rootFiles[] = projectManager.getContentRoots();
469+
final VirtualFile[] rootFiles = projectManager.getContentRoots();
470470
if (rootFiles.length == 0) {
471471
return null;
472472
}

src/main/java/org/jetbrains/plugins/spotbugs/core/FindBugsProjects.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public boolean addFile(@NotNull final VirtualFile file, final boolean checkCompi
101101
return false;
102102
}
103103
final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
104-
if (psiFile != null && psiFile instanceof PsiJavaFile) { // think of scala, groovy, aj etc
104+
if (psiFile instanceof PsiJavaFile) { // think of scala, groovy, aj etc
105105
final PsiJavaFile javaFile = (PsiJavaFile) psiFile;
106106
String fileName = javaFile.getName();
107107
if (fileName.endsWith(".java")) {

src/main/java/org/jetbrains/plugins/spotbugs/core/FindBugsResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
public final class FindBugsResult {
3333
@NotNull
34-
private Map<Project, SortedBugCollection> results;
34+
private final Map<Project, SortedBugCollection> results;
3535

3636
public FindBugsResult() {
3737
this.results = New.map();

src/main/java/org/jetbrains/plugins/spotbugs/gui/common/CheckThreadViolationRepaintManager.java

Lines changed: 0 additions & 173 deletions
This file was deleted.

src/main/java/org/jetbrains/plugins/spotbugs/gui/common/NDockLayout.java

Lines changed: 21 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,9 @@
2929
* @since 0.9.29-dev
3030
*/
3131

32-
import javax.swing.JSeparator;
33-
import javax.swing.JToolBar;
34-
import javax.swing.SwingConstants;
35-
import java.awt.AWTError;
36-
import java.awt.BorderLayout;
37-
import java.awt.Component;
38-
import java.awt.Container;
39-
import java.awt.Dimension;
40-
import java.awt.Insets;
41-
import java.awt.Rectangle;
32+
import javax.swing.*;
33+
import java.awt.*;
4234
import java.util.ArrayList;
43-
import java.util.Collection;
4435

4536

4637
public class NDockLayout extends BorderLayout {
@@ -256,35 +247,33 @@ private void layoutComponents(final Container target, final ArrayList<Component>
256247

257248

258249
private static void flipSeparators(final Component c, final int orientation) {
259-
if (c != null && c instanceof JToolBar/* && UIManager.getLookAndFeel().getName().toLowerCase().contains("windows")*/) {
250+
if (c instanceof JToolBar) {
260251
final JToolBar jtb = (JToolBar) c;
261252

262253
final Component[] comps = jtb.getComponents();
263254
if (comps != null && comps.length > 0) {
264255
for (int i = 0; i < comps.length; i++) {
265256
try {
266257
final Component component = comps[i];
267-
if (component != null) {
268-
if (component instanceof JSeparator) {
269-
final boolean isVisible = component.isVisible();
270-
jtb.remove(component);
271-
final JSeparator separ = new JSeparator();
272-
separ.setVisible(isVisible);
273-
if (orientation == SwingConstants.VERTICAL) {
274-
jtb.setOrientation(SwingConstants.VERTICAL);
275-
separ.setOrientation(SwingConstants.VERTICAL);
276-
separ.setMinimumSize(new Dimension(2, 6));
277-
separ.setPreferredSize(new Dimension(2, 6));
278-
separ.setMaximumSize(new Dimension(2, 100));
279-
} else {
280-
jtb.setOrientation(SwingConstants.HORIZONTAL);
281-
separ.setOrientation(SwingConstants.HORIZONTAL);
282-
separ.setMinimumSize(new Dimension(6, 20));
283-
separ.setPreferredSize(new Dimension(6, 20));
284-
separ.setMaximumSize(new Dimension(100, 20));
285-
}
286-
jtb.add(separ, i);
258+
if (component instanceof JSeparator) {
259+
final boolean isVisible = component.isVisible();
260+
jtb.remove(component);
261+
final JSeparator separ = new JSeparator();
262+
separ.setVisible(isVisible);
263+
if (orientation == SwingConstants.VERTICAL) {
264+
jtb.setOrientation(SwingConstants.VERTICAL);
265+
separ.setOrientation(SwingConstants.VERTICAL);
266+
separ.setMinimumSize(new Dimension(2, 6));
267+
separ.setPreferredSize(new Dimension(2, 6));
268+
separ.setMaximumSize(new Dimension(2, 100));
269+
} else {
270+
jtb.setOrientation(SwingConstants.HORIZONTAL);
271+
separ.setOrientation(SwingConstants.HORIZONTAL);
272+
separ.setMinimumSize(new Dimension(6, 20));
273+
separ.setPreferredSize(new Dimension(6, 20));
274+
separ.setMaximumSize(new Dimension(100, 20));
287275
}
276+
jtb.add(separ, i);
288277
}
289278
} catch (final Exception e) {
290279
throw new AWTError(e.getMessage());
@@ -293,31 +282,4 @@ private static void flipSeparators(final Component c, final int orientation) {
293282
}
294283
}
295284
}
296-
297-
298-
public boolean containsImbeddedComp(final Component component) {
299-
for (final Object curImbeddedTBR : _embeddedComponents) {
300-
//noinspection unchecked
301-
if (((Collection<Component>) curImbeddedTBR).contains(component)) {
302-
return true;
303-
}
304-
}
305-
return false;
306-
}
307-
308-
309-
/**
310-
* Description:
311-
* (SwingConstants top,left,bottom,right):
312-
* top:1, left:2, bottom:3, right:4
313-
*
314-
* @param component
315-
* @param inx
316-
* @return
317-
*/
318-
public boolean containsEmbeddedComp(final Component component, final int inx) {
319-
//noinspection unchecked
320-
return inx > 0 && inx < 5 && ((Collection<Component>) _embeddedComponents[inx + 1]).contains(component);
321-
}
322-
323285
}

src/main/java/org/jetbrains/plugins/spotbugs/gui/editor/BugAnnotator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void annotate(@NotNull final PsiElement psiElement, @NotNull final Annota
7474

7575
final PsiFile psiFile = psiElement.getContainingFile();
7676
if (problems.containsKey(psiFile)) {
77-
addAnnotation(psiElement, new ArrayList<ExtendedProblemDescriptor>(problems.get(psiFile)), annotationHolder);
77+
addAnnotation(psiElement, new ArrayList<>(problems.get(psiFile)), annotationHolder);
7878
}
7979
}
8080

src/main/java/org/jetbrains/plugins/spotbugs/gui/settings/ShareTab.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ final class ShareTab extends JPanel implements SettingsOwner<WorkspaceSettings>,
6666
@Nullable
6767
private final String importFilePathKey;
6868

69-
private JLabel description;
70-
private HyperlinkLabel link;
71-
private LabeledComponent<TextFieldWithBrowseButton> importPathLabel;
69+
private final JLabel description;
70+
private final HyperlinkLabel link;
71+
private final LabeledComponent<TextFieldWithBrowseButton> importPathLabel;
7272

7373
ShareTab(@NotNull final Project project, @Nullable final Module module) {
7474
super(new VerticalFlowLayout(HAlignment.Left, VAlignment.Top, 0, 0, true, false));
@@ -97,7 +97,7 @@ final class ShareTab extends JPanel implements SettingsOwner<WorkspaceSettings>,
9797
null,
9898
descriptor
9999
);
100-
importPathLabel = new LabeledComponent<TextFieldWithBrowseButton>();
100+
importPathLabel = new LabeledComponent<>();
101101
importPathLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
102102
importPathLabel.setComponent(importPath);
103103
importPathLabel.setLabelLocation(BorderLayout.WEST);
@@ -163,11 +163,12 @@ private void removeOrphanEntries(@NotNull final Map<String, String> importFilePa
163163
for (final Module module : ModuleManager.getInstance(project).getModules()) {
164164
moduleNames.add(module.getName());
165165
}
166-
for (final String moduleName : new HashSet<String>(importFilePath.keySet())) {
166+
for (final String moduleName : new HashSet<>(importFilePath.keySet())) {
167167
if (!StringUtil.equals(WorkspaceSettings.PROJECT_IMPORT_FILE_PATH_KEY, moduleName)) {
168168
if (!moduleNames.contains(moduleName)) {
169-
LOGGER.warn(String.format("Remove importFilePath (%s) from settings because module with name '%s' does not exist", importFilePath.get(moduleName), moduleName));
170-
importFilePath.remove(moduleName);
169+
String path = importFilePath.remove(moduleName);
170+
LOGGER.warn(String.format(
171+
"Remove importFilePath (%s) from settings because module with name '%s' does not exist", path, moduleName));
171172
}
172173
}
173174
}
@@ -178,12 +179,8 @@ public void dispose() {
178179
}
179180

180181
void requestFocusOnImportFile() {
181-
IdeFocusManager.findInstance().doWhenFocusSettlesDown(new Runnable() {
182-
@Override
183-
public void run() {
184-
IdeFocusManager.findInstance().requestFocus(importPathLabel.getComponent().getTextField(), true);
185-
}
186-
});
182+
IdeFocusManager.findInstance().doWhenFocusSettlesDown(
183+
() -> IdeFocusManager.findInstance().requestFocus(importPathLabel.getComponent().getTextField(), true));
187184
}
188185

189186
@NotNull

0 commit comments

Comments
 (0)