Cleanup (warnings; typos; default methods)

GitOrigin-RevId: 1ef5c5f7ff16c454feeb76b861bba719dd1e1289
This commit is contained in:
Roman Shevchenko
2019-10-08 16:33:06 +00:00
committed by intellij-monorepo-bot
parent c087d60437
commit 7913cc6dac
16 changed files with 65 additions and 228 deletions
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInspection.inferNullity;
import com.intellij.codeInsight.NullableNotNullManager;
@@ -38,10 +24,6 @@ class AnnotateTask implements SequentialTask {
myTotal = infos.length;
}
@Override
public void prepare() {
}
@Override
public boolean isDone() {
return myCount > myTotal - 1;
@@ -58,8 +40,4 @@ class AnnotateTask implements SequentialTask {
return isDone();
}
@Override
public void stop() {
}
}
@@ -111,10 +111,6 @@ class OptimizeImportsTask implements SequentialTask {
myPointers = pointers.iterator();
}
@Override
public void prepare() {
}
@Override
public boolean isDone() {
return !myPointers.hasNext();
@@ -157,8 +153,4 @@ class OptimizeImportsTask implements SequentialTask {
return isDone();
}
@Override
public void stop() {
}
}
@@ -30,32 +30,24 @@ public interface FileSystemInterface {
void setWritable(@NotNull VirtualFile file, boolean writableFlag) throws IOException;
boolean isSymLink(@NotNull VirtualFile file);
@Nullable
String resolveSymLink(@NotNull VirtualFile file);
@Nullable String resolveSymLink(@NotNull VirtualFile file);
@NotNull
VirtualFile createChildDirectory(@Nullable Object requestor, @NotNull VirtualFile parent, @NotNull String dir) throws IOException;
@NotNull VirtualFile createChildDirectory(@Nullable Object requestor, @NotNull VirtualFile parent, @NotNull String dir) throws IOException;
@NotNull VirtualFile createChildFile(@Nullable Object requestor, @NotNull VirtualFile parent, @NotNull String file) throws IOException;
@NotNull
VirtualFile createChildFile(@Nullable Object requestor, @NotNull VirtualFile parent, @NotNull String file) throws IOException;
void deleteFile(Object requestor, @NotNull VirtualFile file) throws IOException;
void moveFile(Object requestor, @NotNull VirtualFile file, @NotNull VirtualFile newParent) throws IOException;
void renameFile(Object requestor, @NotNull VirtualFile file, @NotNull String newName) throws IOException;
void deleteFile(final Object requestor, @NotNull VirtualFile file) throws IOException;
void moveFile(final Object requestor, @NotNull VirtualFile file, @NotNull VirtualFile newParent) throws IOException;
void renameFile(final Object requestor, @NotNull VirtualFile file, @NotNull String newName) throws IOException;
@NotNull VirtualFile copyFile(Object requestor, @NotNull VirtualFile file, @NotNull VirtualFile newParent, @NotNull String copyName) throws IOException;
@NotNull
VirtualFile copyFile(final Object requestor, @NotNull VirtualFile file, @NotNull VirtualFile newParent, @NotNull String copyName) throws IOException;
@NotNull
byte[] contentsToByteArray(@NotNull VirtualFile file) throws IOException;
@NotNull byte[] contentsToByteArray(@NotNull VirtualFile file) throws IOException;
/** Does NOT strip the BOM from the beginning of the stream, unlike the {@link VirtualFile#getInputStream()} */
@NotNull
InputStream getInputStream(@NotNull VirtualFile file) throws IOException;
@NotNull InputStream getInputStream(@NotNull VirtualFile file) throws IOException;
/** Does NOT add the BOM to the beginning of the stream, unlike the {@link VirtualFile#getOutputStream(Object)} */
@NotNull
OutputStream getOutputStream(@NotNull VirtualFile file, final Object requestor, final long modStamp, final long timeStamp) throws IOException;
@NotNull OutputStream getOutputStream(@NotNull VirtualFile file, Object requestor, long modStamp, long timeStamp) throws IOException;
long getLength(@NotNull VirtualFile file);
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util;
import com.intellij.openapi.progress.ProgressIndicator;
@@ -21,25 +7,24 @@ import org.jetbrains.annotations.NotNull;
/**
* Defines general contract for processing that may be executed by parts, i.e. it remembers the state after every iteration
* and allows to resume the processing any time.
*
*
* @author Denis Zhdanov
*/
public interface SequentialTask {
/**
* Callback method that is assumed to be called before the processing.
*/
void prepare();
default void prepare() { }
/**
* @return {@code true} if the processing is complete; {@code false} otherwise
* Returns {@code true} if the processing is complete, {@code false} otherwise.
*/
boolean isDone();
/**
* Asks current task to perform one more processing iteration.
*
* @return {@code true} if the processing is done; {@code false} otherwise
* Asks the current task to perform one more processing iteration.
*
* @return {@code true} if the processing is done, {@code false} otherwise.
*/
boolean iteration();
@@ -48,7 +33,7 @@ public interface SequentialTask {
}
/**
* Asks current task to stop the processing (if any).
* Asks the current task to stop the processing (if any).
*/
void stop();
}
default void stop() { }
}
@@ -452,10 +452,6 @@ public abstract class AbstractLayoutCodeProcessor {
myProgressIndicator = indicator;
}
@Override
public void prepare() {
}
@Override
public boolean isDone() {
return myStopFormatting;
@@ -44,10 +44,6 @@ public abstract class PerformFixesModalTask implements SequentialTask {
myReformattingAspect = PostprocessReformattingAspect.getInstance(myProject);
}
@Override
public void prepare() {
}
@Override
public boolean isDone() {
return myPackIdx > myDescriptorPacks.size() - 1;
@@ -112,9 +108,6 @@ public abstract class PerformFixesModalTask implements SequentialTask {
return isDone();
}
@Override
public void stop() {}
protected abstract void applyFix(Project project, CommonProblemDescriptor descriptor);
private Pair<CommonProblemDescriptor, Boolean> nextDescriptor() {
@@ -128,4 +121,4 @@ public abstract class PerformFixesModalTask implements SequentialTask {
}
return Pair.create(descriptor, shouldDoPostponedOperations);
}
}
}
@@ -77,10 +77,6 @@ public class SuppressActionSequentialTask implements SequentialTask {
return myCount > myNodesToSuppress.length - 1;
}
@Override
public void stop() {
}
@Override
public void prepare() {
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
@@ -133,4 +129,4 @@ public class SuppressActionSequentialTask implements SequentialTask {
node.removeSuppressActionFromAvailable(mySuppressAction);
}
}
}
@@ -1,19 +1,4 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.ide.util;
import com.intellij.CommonBundle;
@@ -62,8 +47,7 @@ import java.util.Collection;
import java.util.List;
public class DeleteHandler {
private DeleteHandler() {
}
private DeleteHandler() { }
public static class DefaultDeleteProvider implements DeleteProvider {
@Override
@@ -201,19 +185,19 @@ public class DeleteHandler {
private static void deleteInCommand(Project project, PsiElement[] elements) {
CommandProcessor.getInstance().executeCommand(project, () -> NonProjectFileWritingAccessProvider.disableChecksDuring(() -> {
SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(project);
List<SmartPsiElementPointer> pointers = ContainerUtil.map(elements, smartPointerManager::createSmartPsiElementPointer);
List<SmartPsiElementPointer<?>> pointers = ContainerUtil.map(elements, smartPointerManager::createSmartPsiElementPointer);
if (!makeWritable(project, elements)) return;
// deleted from project view or something like that.
if (CommonDataKeys.EDITOR.getData(DataManager.getInstance().getDataContext()) == null) {
@SuppressWarnings("deprecation") DataContext context = DataManager.getInstance().getDataContext();
if (CommonDataKeys.EDITOR.getData(context) == null) {
CommandProcessor.getInstance().markCurrentCommandAsGlobal(project);
}
for (SmartPsiElementPointer pointer : pointers) {
for (SmartPsiElementPointer<?> pointer : pointers) {
PsiElement elementToDelete = pointer.getElement();
if (elementToDelete == null) continue; //was already deleted
doDelete(project, elementToDelete);
}
}), RefactoringBundle.message("safe.delete.command", RefactoringUIUtil.calculatePsiElementDescriptionList(elements)), null);
@@ -223,7 +207,7 @@ public class DeleteHandler {
if (elementToDelete instanceof PsiDirectory) {
VirtualFile virtualFile = ((PsiDirectory)elementToDelete).getVirtualFile();
if (virtualFile.isInLocalFileSystem() && !virtualFile.is(VFileProperty.SYMLINK)) {
ArrayList<VirtualFile> readOnlyFiles = new ArrayList<>();
List<VirtualFile> readOnlyFiles = new ArrayList<>();
CommonRefactoringUtil.collectReadOnlyFiles(virtualFile, readOnlyFiles);
if (!readOnlyFiles.isEmpty()) {
@@ -264,6 +248,7 @@ public class DeleteHandler {
if (!clearFileReadOnlyFlags(project, element)) return;
try {
//noinspection deprecation
element.checkDelete();
}
catch (IncorrectOperationException ex) {
@@ -275,7 +260,7 @@ public class DeleteHandler {
try {
element.delete();
}
catch (final IncorrectOperationException ex) {
catch (IncorrectOperationException ex) {
ApplicationManager.getApplication().invokeLater(
() -> Messages.showMessageDialog(project, ex.getMessage(), CommonBundle.getErrorTitle(), Messages.getErrorIcon()));
}
@@ -312,4 +297,4 @@ public class DeleteHandler {
}
return true;
}
}
}
@@ -239,10 +239,6 @@ public class CodeStyleSettingsCodeFragmentFilter {
return oldValue;
}
@Override
public void prepare() {
}
}
public interface CodeStyleSettingsToShow {
@@ -319,10 +315,6 @@ class CompositeSequentialTask implements SequentialTask {
}
}
@Override
public void prepare() {
}
@Override
public void stop() {
if (myCurrentTask != null) myCurrentTask.stop();
@@ -1,19 +1,4 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.refactoring.util;
import com.intellij.codeInsight.lookup.LookupManager;
@@ -32,7 +17,6 @@ import com.intellij.usageView.UsageViewUtil;
import com.intellij.util.Function;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
@@ -41,31 +25,27 @@ import java.util.Arrays;
* @author yole
*/
public class RefactoringUIUtil {
private RefactoringUIUtil() {
}
private RefactoringUIUtil() { }
public static String getDescription(@NotNull PsiElement element, boolean includeParent) {
return ElementDescriptionUtil.getElementDescription(element, includeParent
? RefactoringDescriptionLocation.WITH_PARENT
: RefactoringDescriptionLocation.WITHOUT_PARENT);
RefactoringDescriptionLocation location = includeParent ? RefactoringDescriptionLocation.WITH_PARENT : RefactoringDescriptionLocation.WITHOUT_PARENT;
return ElementDescriptionUtil.getElementDescription(element, location);
}
public static void processIncorrectOperation(final Project project, IncorrectOperationException e) {
@NonNls String message = e.getMessage();
final int index = message != null ? message.indexOf("java.io.IOException") : -1;
public static void processIncorrectOperation(Project project, IncorrectOperationException e) {
String message = e.getMessage();
int index = message != null ? message.indexOf("java.io.IOException") : -1;
if (index > 0) {
message = message.substring(index + "java.io.IOException".length());
}
final String s = message;
String s = message;
ApplicationManager.getApplication().invokeLater(
() -> Messages.showMessageDialog(project, s, RefactoringBundle.message("error.title"), Messages.getErrorIcon()));
}
public static String calculatePsiElementDescriptionList(PsiElement[] elements) {
final Function<PsiElement, String> presentationFun = element -> UsageViewUtil.getType(element) +
" " +
DescriptiveNameUtil.getDescriptiveName(element);
Function<PsiElement, String> presentationFun = e -> UsageViewUtil.getType(e) + ' ' + DescriptiveNameUtil.getDescriptiveName(e);
return StringUtil.join(ContainerUtil.map2LinkedSet(Arrays.asList(elements), presentationFun), ", ");
}
@@ -76,9 +56,5 @@ public class RefactoringUIUtil {
editor.getSelectionModel().setSelection(0, editor.getDocument().getTextLength());
}
}
@Override
public void focusLost(@NotNull Editor editor) {
}
});
}
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util;
import com.intellij.openapi.application.ApplicationManager;
@@ -23,16 +9,14 @@ import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.InvocationTargetException;
/**
* Allows to execute {@link SequentialTask} under modal progress.
*
* Allows executing {@link SequentialTask} under modal progress.
*
* @author Denis Zhdanov
*/
public class SequentialModalProgressTask extends Task.Modal {
private static final Logger LOG = Logger.getInstance(SequentialModalProgressTask.class);
private static final long DEFAULT_MIN_ITERATION_MIN_TIME = 500;
/**
@@ -69,17 +53,17 @@ public class SequentialModalProgressTask extends Task.Modal {
}
}
public void doRun(@NotNull ProgressIndicator indicator) throws InvocationTargetException, InterruptedException {
public void doRun(@NotNull ProgressIndicator indicator) {
final SequentialTask task = myTask;
if (task == null) {
return;
}
myIndicator = indicator;
indicator.setIndeterminate(false);
prepare(task);
// We need to sync background thread and EDT here in order to avoid situation when event queue is full of processing requests.
// We need to sync background thread and EDT here in order to avoid a situation when event queue is full of processing requests.
while (!task.isDone()) {
if (indicator.isCanceled()) {
task.stop();
@@ -107,36 +91,17 @@ public class SequentialModalProgressTask extends Task.Modal {
public void setTask(@Nullable SequentialTask task) {
myTask = task;
}
public ProgressIndicator getIndicator() {
return myIndicator;
}
/**
* Executes preliminary jobs prior to the target sequential task processing ({@link SequentialTask#prepare()} by default).
*
* @param task task to be executed
*
* @param task task to be executed
*/
protected void prepare(@NotNull SequentialTask task) {
task.prepare();
}
public abstract static class Adapter extends SequentialModalProgressTask implements SequentialTask {
public Adapter(@Nullable Project project, @NotNull String title) {
super(project, title);
setTask(this);
}
public Adapter(@Nullable Project project, @NotNull String title, boolean canBeCancelled) {
super(project, title, canBeCancelled);
}
@Override
public void prepare() {
}
@Override
public void stop() {
}
}
}
}
@@ -12,8 +12,7 @@ import java.util.EventListener;
*/
public interface FocusChangeListener extends EventListener {
void focusGained(@NotNull Editor editor);
default void focusLost(@NotNull Editor editor) {
}
default void focusLost(@NotNull Editor editor) { }
default void focusLost(@NotNull Editor editor, @SuppressWarnings("unused") @NotNull FocusEvent event) {
focusLost(editor);
@@ -21,4 +20,4 @@ public interface FocusChangeListener extends EventListener {
default void focusGained(@NotNull Editor editor, @SuppressWarnings("unused") @NotNull FocusEvent event) {
focusGained(editor);
}
}
}
@@ -58,12 +58,14 @@ public class PotemkinProgress extends ProgressWindow implements PingProgress {
}
private static boolean isUrgentInvocationEvent(AWTEvent event) {
// LWCToolkit does invokeAndWait which blocks native event processing until finished. The OS considers that blockage to be
// LWCToolkit does 'invokeAndWait', which blocks native event processing until finished. The OS considers that blockage to be
// app freeze, stops rendering UI and shows beach-ball cursor. We want the UI to act (almost) normally in write-action progresses,
// so we let these specific events to be dispatched, hoping they wouldn't access project/code model.
// problem (IDEA-192282): LWCToolkit event might be posted before PotemkinProgress appears,
// and it then just sits in the queue blocking the whole UI until the progress is finished.
//noinspection SpellCheckingInspection
return event.toString().contains(",runnable=sun.lwawt.macosx.LWCToolkit") ||
event instanceof MyInvocationEvent;
}
@@ -171,7 +173,7 @@ public class PotemkinProgress extends ProgressWindow implements PingProgress {
/**
* Repaint just the dialog panel. We must not call custom paint methods during write action,
* because they might access the model which might be inconsistent at that moment.
* because they might access the model, which might be inconsistent at that moment.
*/
private void paintProgress() {
getDialog().myRepaintRunnable.run();
@@ -228,8 +230,8 @@ public class PotemkinProgress extends ProgressWindow implements PingProgress {
}
private static class MyInvocationEvent extends InvocationEvent {
public MyInvocationEvent(Object source, Runnable runnable) {
MyInvocationEvent(Object source, Runnable runnable) {
super(source, runnable);
}
}
}
}
@@ -731,12 +731,10 @@ public abstract class LocalFileSystemBase extends LocalFileSystem {
@Override
public boolean hasChildren(@NotNull VirtualFile file) {
if (file.getParent() == null) {
// assume roots always have children
return true;
return true; // assume roots always have children
}
// make sure to not load all children
try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(file.getPath()))) {
return stream.iterator().hasNext();
return stream.iterator().hasNext(); // make sure to not load all children
}
catch (InvalidPathException | IOException | SecurityException e) {
return true;
@@ -169,9 +169,6 @@ public class UpdateCopyrightAction extends BaseAnalysisAction {
mySize = runnables.size();
}
@Override
public void prepare() {}
@Override
public boolean isDone() {
return myIdx > mySize - 1;
@@ -110,10 +110,6 @@ public class ConvertSchemaPrefixToDefaultIntention extends PsiElementBaseIntenti
int tagIndex = 0;
int attrIndex = 0;
@Override
public void prepare() {
}
@Override
public boolean isDone() {
return tagIndex + attrIndex >= totalCount;
@@ -139,11 +135,6 @@ public class ConvertSchemaPrefixToDefaultIntention extends PsiElementBaseIntenti
return isDone();
}
@Override
public void stop() {
}
});
ProgressManager.getInstance().run(progressTask);
}