five or six bug fixes, haven't two extra hours to push them separately

This commit is contained in:
Alexey Kudravtsev
2009-10-05 19:05:09 +04:00
parent c53a1f794b
commit 5c5b53d342
18 changed files with 46 additions and 31 deletions
@@ -300,8 +300,10 @@ public class JavaFileManagerImpl implements JavaFileManager {
PsiClass aClass = (PsiClass)found;
final boolean valid = aClass.isValid();
LOG.assertTrue(valid);
if (!valid) continue;
if (!valid) {
LOG.error("Invalid class "+aClass+"; "+aClass.getContainingFile());
continue;
}
final String qualifiedName = aClass.getQualifiedName();
if (qualifiedName == null || !qualifiedName.equals(qName)) continue;
@@ -60,13 +60,13 @@ public class ProblemsHolder {
myProblems = new ArrayList<ProblemDescriptor>(1);
}
PsiElement element = problemDescriptor.getPsiElement();
if (!isInPsiFile(element)) {
if (element != null && !isInPsiFile(element)) {
LOG.error("Reported element " + element + " is not from the file '" + myFile + "' the inspection was invoked for. Message:" + problemDescriptor.getDescriptionTemplate());
}
myProblems.add(problemDescriptor);
}
private boolean isInPsiFile(PsiElement element) {
private boolean isInPsiFile(@NotNull PsiElement element) {
PsiFile file = element.getContainingFile();
return ArrayUtil.indexOf(myFile.getPsiRoots(), file) != -1;
}
@@ -94,7 +94,7 @@ public class TypedHandler implements TypedActionHandler {
quoteHandlers.put(fileType, quoteHandler);
}
public void execute(Editor editor, char charTyped, DataContext dataContext) {
public void execute(@NotNull Editor editor, char charTyped, @NotNull DataContext dataContext) {
Project project = PlatformDataKeys.PROJECT.getData(dataContext);
if (project == null || editor.isColumnMode()){
if (myOriginalHandler != null){
@@ -13,6 +13,7 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorModificationUtil;
import com.intellij.openapi.editor.actionSystem.TypedActionHandler;
import com.intellij.openapi.extensions.Extensions;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
@@ -23,7 +24,7 @@ public class TypedHandler implements TypedActionHandler {
myOriginalHandler = originalHandler;
}
public void execute(final Editor editor, final char charTyped, DataContext dataContext){
public void execute(@NotNull final Editor editor, final char charTyped, @NotNull DataContext dataContext){
final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(editor);
if (lookup == null){
myOriginalHandler.execute(editor, charTyped, dataContext);
@@ -27,6 +27,7 @@ import com.intellij.ui.LightweightHint;
import com.intellij.util.text.StringSearcher;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@@ -355,7 +356,7 @@ public class IncrementalSearchHandler {
myOriginalHandler = originalAction;
}
public void execute(Editor editor, char charTyped, DataContext dataContext) {
public void execute(@NotNull Editor editor, char charTyped, @NotNull DataContext dataContext) {
PerEditorSearchData data = editor.getUserData(SEARCH_DATA_IN_EDITOR_VIEW_KEY);
if (data == null || data.hint == null){
myOriginalHandler.execute(editor, charTyped, dataContext);
@@ -7,6 +7,7 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
import com.intellij.codeInsight.template.impl.TemplateSettings;
import org.jetbrains.annotations.NotNull;
public class SpaceHandler implements TypedActionHandler {
private final TypedActionHandler myOriginalHandler;
@@ -15,7 +16,7 @@ public class SpaceHandler implements TypedActionHandler {
myOriginalHandler = originalHandler;
}
public void execute(Editor editor, char charTyped, DataContext dataContext) {
public void execute(@NotNull Editor editor, char charTyped, @NotNull DataContext dataContext) {
if (charTyped != ' ') {
myOriginalHandler.execute(editor, charTyped, dataContext);
return;
@@ -922,7 +922,7 @@ public final class ConsoleViewImpl extends JPanel implements ConsoleView, Observ
myOriginalHandler = originalAction;
}
public void execute(final Editor editor, final char charTyped, final DataContext dataContext) {
public void execute(@NotNull final Editor editor, final char charTyped, @NotNull final DataContext dataContext) {
final ConsoleViewImpl consoleView = editor.getUserData(CONSOLE_VIEW_IN_EDITOR_VIEW);
if (consoleView == null || !consoleView.myState.isRunning() || consoleView.isViewer){
myOriginalHandler.execute(editor, charTyped, dataContext);
@@ -155,7 +155,8 @@ public class IndexPatternSearcher implements QueryExecutor<IndexPatternOccurrenc
int start = lexer.getTokenStart() + startDelta;
int end = lexer.getTokenEnd() - endDelta;
assert start <= end : "Invalid comment range: " + new TextRange(start, end) + "; lexer token range="+new TextRange(lexer.getTokenStart(), lexer.getTokenEnd())+"; delta="+new TextRange(startDelta, endDelta)+"; lexer="+lexer+"; builder="+builderForFile;
assert start <= end : "Invalid comment range: " + new TextRange(start, end) + "; lexer token range="+new TextRange(lexer.getTokenStart(), lexer.getTokenEnd())+"; delta="+new TextRange(startDelta, endDelta)+"; lexer="+lexer+"; builder="+builderForFile+"; chars length:"+chars.length();
assert end < chars.length(): "Invalid comment end: " + new TextRange(start, end) + "; lexer token range="+new TextRange(lexer.getTokenStart(), lexer.getTokenEnd())+"; delta="+new TextRange(startDelta, endDelta)+"; lexer="+lexer+"; builder="+builderForFile+"; chars length:"+chars.length();
commentStarts.add(start);
commentEnds.add(end);
}
@@ -23,10 +23,11 @@
package com.intellij.openapi.actionSystem;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Map;
import java.util.HashMap;
import java.util.Map;
/**
* @param <T>
@@ -37,11 +38,11 @@ public class DataKey<T> {
private final String myName;
private DataKey(final String name) {
private DataKey(@NotNull String name) {
myName = name;
}
public static <T> DataKey<T> create(@NonNls String name) {
public static <T> DataKey<T> create(@NotNull @NonNls String name) {
if (ourDataKeyIndex.containsKey(name)) {
//noinspection unchecked
return ourDataKeyIndex.get(name);
@@ -56,7 +57,7 @@ public class DataKey<T> {
}
@Nullable
public T getData(DataContext dataContext) {
public T getData(@NotNull DataContext dataContext) {
//noinspection unchecked
return (T) dataContext.getData(myName);
}
@@ -15,10 +15,12 @@
*/
package com.intellij.openapi.editor;
import org.jetbrains.annotations.NotNull;
public class ReadOnlyModificationException extends RuntimeException {
private final Document myDocument;
public ReadOnlyModificationException(Document document) {
public ReadOnlyModificationException(@NotNull Document document) {
super(EditorBundle.message("attempt.to.modify.read.only.document.error.message"));
myDocument = document;
}
@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.*;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
/**
* Provides services for registering actions which are activated by typing in the editor.
@@ -48,15 +49,13 @@ public class TypedAction {
}
private static class Handler implements TypedActionHandler {
public void execute(Editor editor, char charTyped, DataContext dataContext) {
public void execute(@NotNull Editor editor, char charTyped, @NotNull DataContext dataContext) {
if (editor.isViewer()) return;
Document doc = editor.getDocument();
if (dataContext != null) {
Project project = PlatformDataKeys.PROJECT.getData(dataContext);
if (project != null && !FileDocumentManager.getInstance().requestWriting(doc, project)) {
return;
}
Project project = PlatformDataKeys.PROJECT.getData(dataContext);
if (!FileDocumentManager.getInstance().requestWriting(doc, project)) {
return;
}
doc.startGuardedBlockChecking();
@@ -17,6 +17,7 @@ package com.intellij.openapi.editor.actionSystem;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import org.jetbrains.annotations.NotNull;
/**
* Interface for actions activated by typing in the editor.
@@ -32,5 +33,5 @@ public interface TypedActionHandler {
* @param charTyped the typed character.
* @param dataContext the current data context.
*/
void execute(Editor editor, char charTyped, DataContext dataContext);
void execute(@NotNull Editor editor, char charTyped, @NotNull DataContext dataContext);
}
@@ -70,7 +70,7 @@ public abstract class FileDocumentManager {
*/
public abstract boolean requestWriting(@NotNull Document document, Project project);
public static boolean fileForDocumentCheckedOutSuccessfully(@NotNull Document document, Project project) {
public static boolean fileForDocumentCheckedOutSuccessfully(@NotNull Document document, @NotNull Project project) {
return getInstance().requestWriting(document, project);
}
@@ -17,26 +17,28 @@ package com.intellij.openapi.vfs;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
public abstract class ReadonlyStatusHandler {
public static boolean ensureFilesWritable(Project project, VirtualFile... files) {
public static boolean ensureFilesWritable(@NotNull Project project, @NotNull VirtualFile... files) {
return !getInstance(project).ensureFilesWritable(files).hasReadonlyFiles();
}
public abstract static class OperationStatus {
@NotNull
public abstract VirtualFile[] getReadonlyFiles();
public abstract boolean hasReadonlyFiles();
@NotNull
public abstract String getReadonlyFilesMessage();
}
public abstract OperationStatus ensureFilesWritable(VirtualFile... files);
public abstract OperationStatus ensureFilesWritable(@NotNull VirtualFile... files);
public OperationStatus ensureFilesWritable(final Collection<VirtualFile> files) {
public OperationStatus ensureFilesWritable(@NotNull Collection<VirtualFile> files) {
return ensureFilesWritable(files.toArray(new VirtualFile[files.size()]));
}
@@ -87,7 +87,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
private boolean myDoNotSave = false;
private volatile boolean myDisposeInProgress = false;
private AtomicBoolean mySaveSettingsIsInProgress = new AtomicBoolean(false);
private final AtomicBoolean mySaveSettingsIsInProgress = new AtomicBoolean(false);
private final ExecutorService ourThreadExecutorsService = new ThreadPoolExecutor(
3,
@@ -304,7 +304,7 @@ public class FileDocumentManagerImpl extends FileDocumentManager implements Appl
@Override
public boolean requestWriting(@NotNull Document document, Project project) {
final VirtualFile file = getInstance().getFile(document);
if (file != null && file.isValid()) {
if (project != null && file != null && file.isValid()) {
return ReadonlyStatusHandler.ensureFilesWritable(project, file);
}
if (document.isWritable()) {
@@ -44,6 +44,7 @@ import com.intellij.openapi.util.MultiValuesMap;
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
import com.intellij.openapi.vfs.VirtualFile;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -78,7 +79,7 @@ public class ReadonlyStatusHandlerImpl extends ReadonlyStatusHandler implements
myState = state;
}
public OperationStatus ensureFilesWritable(VirtualFile... files) {
public OperationStatus ensureFilesWritable(@NotNull VirtualFile... files) {
if (files.length == 0) {
return new OperationStatusImpl(VirtualFile.EMPTY_ARRAY);
}
@@ -173,6 +174,7 @@ public class ReadonlyStatusHandlerImpl extends ReadonlyStatusHandler implements
myReadonlyFiles = readonlyFiles;
}
@NotNull
public VirtualFile[] getReadonlyFiles() {
return myReadonlyFiles;
}
@@ -181,6 +183,7 @@ public class ReadonlyStatusHandlerImpl extends ReadonlyStatusHandler implements
return myReadonlyFiles.length > 0;
}
@NotNull
public String getReadonlyFilesMessage() {
if (hasReadonlyFiles()) {
StringBuffer buf = new StringBuffer();
@@ -114,7 +114,8 @@ public class UsagePreviewPanel extends JPanel implements Disposable {
TextRange elementRange = psiElement.getTextRange();
TextRange infoRange = info.getRange();
TextRange textRange = elementRange.contains(infoRange) ? elementRange.cutOut(infoRange) : elementRange;
TextRange textRange = elementRange.intersection(infoRange);
if (textRange == null) textRange = elementRange;
// hack to determine element range to highlight
if (psiElement instanceof PsiNamedElement && !(psiElement instanceof PsiFile)) {
PsiFile psiFile = psiElement.getContainingFile();