This commit is contained in:
Alexey Kudravtsev
2016-05-18 15:26:10 +03:00
parent 6b24b7902b
commit 416c1c5e47
11 changed files with 30 additions and 67 deletions
@@ -251,20 +251,13 @@ public class JavacOutputParser extends OutputParser {
else if (JavacResourcesReader.MSG_WARNING.equals(category)) {
WARNING_PREFIX = resourceBundleValue;
}
else if (JavacResourcesReader.MSG_STATISTICS.equals(category)) {
else if (JavacResourcesReader.MSG_STATISTICS.equals(category) || JavacResourcesReader.MSG_IGNORED.equals(category)) {
myParserActions.add(new JavacParserAction(createMatcher(resourceBundleValue)) {
protected void doExecute(final String line, @Nullable String parsedData, final Callback callback) {
// empty
}
});
}
else if (JavacResourcesReader.MSG_IGNORED.equals(category)) {
myParserActions.add(new JavacParserAction(createMatcher(resourceBundleValue)) {
protected void doExecute(final String line, @Nullable String parsedData, final Callback callback) {
// ignored
}
});
}
}
@@ -424,9 +424,6 @@ public class CompilerTask extends Task.Backgroundable {
}
private void updateProgressText() {
if (isHeadlessMode()) {
return;
}
}
// error tree view initialization must be invoked from event dispatch thread
@@ -65,7 +65,6 @@ import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.proximity.PsiProximityComparator;
import com.intellij.refactoring.util.RefactoringUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.Processor;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -738,10 +737,7 @@ public class CreateFromUsageUtils {
@Override
@Nullable
public PsiType visitType(PsiType type) {
if (PsiType.NULL.equals(type)) {
type = PsiType.getJavaLangObject(manager, resolveScope);
}
else if (PsiType.VOID.equals(type) && !allowVoidType) {
if (PsiType.NULL.equals(type) || PsiType.VOID.equals(type) && !allowVoidType) {
type = PsiType.getJavaLangObject(manager, resolveScope);
}
@@ -19,7 +19,6 @@ import com.intellij.codeInsight.FileModificationService;
import com.intellij.codeInsight.daemon.QuickFixBundle;
import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
@@ -77,11 +76,7 @@ public class SuperMethodReturnFix implements IntentionAction {
mySuperMethod.getName(),
mySuperMethodType,
ParameterInfoImpl.fromMethod(mySuperMethod));
if (ApplicationManager.getApplication().isUnitTestMode()) {
processor.run();
} else {
processor.run();
}
processor.run();
}
@Override
@@ -117,7 +117,7 @@ public class JavaProjectDataService extends AbstractProjectDataService<JavaProje
if (v == version) {
return sdk;
}
else if (candidate == null && v != null && version.getMaxLanguageLevel().isAtLeast(version.getMaxLanguageLevel())) {
if (candidate == null && v != null && version.getMaxLanguageLevel().isAtLeast(version.getMaxLanguageLevel())) {
candidate = sdk;
}
}
@@ -428,9 +428,6 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
}
return createAlignment(mySettings.ALIGN_MULTILINE_BINARY_OPERATION, defaultAlignment);
}
if (nodeType == JavaElementType.CLASS || nodeType == JavaElementType.METHOD) {
return null;
}
return null;
}
@@ -876,10 +876,7 @@ public class LambdaUtil {
private boolean check(PsiTypeParameter check) {
final PsiTypeParameterListOwner owner = check.getOwner();
if (owner == myMethod) {
return true;
}
else if (owner == myClass) {
if (owner == myMethod || owner == myClass) {
return true;
}
return false;
@@ -1367,10 +1367,8 @@ public class TypeConversionUtil {
public static Object computeCastTo(final Object operand, final PsiType castType) {
if (operand == null || castType == null) return null;
Object value;
if (operand instanceof String && castType.equalsToText(JAVA_LANG_STRING)) {
value = operand;
}
else if (operand instanceof Boolean && PsiType.BOOLEAN.equals(castType)) {
if (operand instanceof String && castType.equalsToText(JAVA_LANG_STRING) ||
operand instanceof Boolean && PsiType.BOOLEAN.equals(castType)) {
value = operand;
}
else {
@@ -103,10 +103,7 @@ public class SuperTypesGrouper implements Grouper{
private static boolean methodOverridesSuper(PsiMethod method, PsiMethod superMethod) {
boolean overrides = false;
if (method.hasModifierProperty(PsiModifier.ABSTRACT)){
overrides = true;
}
else if (!superMethod.hasModifierProperty(PsiModifier.ABSTRACT)){
if (method.hasModifierProperty(PsiModifier.ABSTRACT) || !superMethod.hasModifierProperty(PsiModifier.ABSTRACT)){
overrides = true;
}
return overrides;
@@ -64,18 +64,14 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass");
private static final String PRESENTABLE_NAME = DaemonBundle.message("pass.syntax");
private static final Key<Boolean> HAS_ERROR_ELEMENT = Key.create("HAS_ERROR_ELEMENT");
static final Condition<PsiFile> SHOULD_HIGHLIGHT_FILTER = new Condition<PsiFile>() {
@Override
public boolean value(@NotNull PsiFile file) {
return HighlightingLevelManager.getInstance(file.getProject()).shouldHighlight(file);
}
};
static final Condition<PsiFile> SHOULD_HIGHLIGHT_FILTER =
file -> HighlightingLevelManager.getInstance(file.getProject()).shouldHighlight(file);
private static final Random RESTART_DAEMON_RANDOM = new Random();
protected final boolean myUpdateAll;
protected final ProperTextRange myPriorityRange;
protected final List<HighlightInfo> myHighlights = new ArrayList<HighlightInfo>();
protected final List<HighlightInfo> myHighlights = new ArrayList<>();
protected volatile boolean myHasErrorElement;
private volatile boolean myErrorFound;
@@ -120,7 +116,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
return super.getDocument();
}
private static final Key<AtomicInteger> HIGHLIGHT_VISITOR_INSTANCE_COUNT = new Key<AtomicInteger>("HIGHLIGHT_VISITOR_INSTANCE_COUNT");
private static final Key<AtomicInteger> HIGHLIGHT_VISITOR_INSTANCE_COUNT = new Key<>("HIGHLIGHT_VISITOR_INSTANCE_COUNT");
@NotNull
private HighlightVisitor[] cloneHighlightVisitors() {
int oldCount = incVisitorUsageCount(1);
@@ -140,7 +136,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
@NotNull
private HighlightVisitor[] filterVisitors(@NotNull HighlightVisitor[] highlightVisitors, @NotNull PsiFile psiFile) {
final List<HighlightVisitor> visitors = new ArrayList<HighlightVisitor>(highlightVisitors.length);
final List<HighlightVisitor> visitors = new ArrayList<>(highlightVisitors.length);
List<HighlightVisitor> list = Arrays.asList(highlightVisitors);
for (HighlightVisitor visitor : DumbService.getInstance(myProject).filterByDumbAwareness(list)) {
if (visitor.suitableForFile(psiFile)) {
@@ -167,7 +163,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
}
// returns old value
public int incVisitorUsageCount(int delta) {
int incVisitorUsageCount(int delta) {
AtomicInteger count = myProject.getUserData(HIGHLIGHT_VISITOR_INSTANCE_COUNT);
if (count == null) {
count = ((UserDataHolderEx)myProject).putUserDataIfAbsent(HIGHLIGHT_VISITOR_INSTANCE_COUNT, new AtomicInteger(0));
@@ -179,16 +175,16 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
@Override
protected void collectInformationWithProgress(@NotNull final ProgressIndicator progress) {
final List<HighlightInfo> outsideResult = new ArrayList<HighlightInfo>(100);
final List<HighlightInfo> insideResult = new ArrayList<HighlightInfo>(100);
final List<HighlightInfo> outsideResult = new ArrayList<>(100);
final List<HighlightInfo> insideResult = new ArrayList<>(100);
final DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject);
final HighlightVisitor[] filteredVisitors = getHighlightVisitors(getFile());
final List<PsiElement> insideElements = new ArrayList<PsiElement>();
final List<PsiElement> outsideElements = new ArrayList<PsiElement>();
try {
List<ProperTextRange> insideRanges = new ArrayList<ProperTextRange>();
List<ProperTextRange> outsideRanges = new ArrayList<ProperTextRange>();
List<ProperTextRange> insideRanges = new ArrayList<>();
List<ProperTextRange> outsideRanges = new ArrayList<>();
final List<PsiElement> insideElements = new ArrayList<>();
final List<PsiElement> outsideElements = new ArrayList<>();
Divider.divideInsideAndOutside(getFile(), myRestrictRange.getStartOffset(), myRestrictRange.getEndOffset(), myPriorityRange, insideElements, insideRanges, outsideElements,
outsideRanges, false, SHOULD_HIGHLIGHT_FILTER);
// put file element always in outsideElements (except file fragments where they have crazy element ranges: an expression might be an immediate child of a file there)
@@ -250,7 +246,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
@Override
@NotNull
public List<HighlightInfo> getInfos() {
return new ArrayList<HighlightInfo>(myHighlights);
return new ArrayList<>(myHighlights);
}
private boolean collectHighlights(@NotNull final List<PsiElement> elements1,
@@ -262,7 +258,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
@NotNull final List<HighlightInfo> insideResult,
@NotNull final List<HighlightInfo> outsideResult,
final boolean forceHighlightParents) {
final Set<PsiElement> skipParentsSet = new THashSet<PsiElement>();
final Set<PsiElement> skipParentsSet = new THashSet<>();
// TODO - add color scheme to holder
final HighlightInfoHolder holder = createInfoHolder(getFile());
@@ -277,7 +273,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
}
runVisitors(elements2, ranges2, chunkSize, progress, skipParentsSet, holder, insideResult, outsideResult, forceHighlightParents, visitors);
});
List<HighlightInfo> postInfos = new ArrayList<HighlightInfo>(holder.size());
List<HighlightInfo> postInfos = new ArrayList<>(holder.size());
// there can be extra highlights generated in PostHighlightVisitor
for (int j = 0; j < holder.size(); j++) {
final HighlightInfo info = holder.get(j);
@@ -314,8 +310,8 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
@NotNull List<HighlightInfo> outsideResult,
boolean forceHighlightParents,
@NotNull HighlightVisitor[] visitors) {
Stack<TextRange> nestedRange = new Stack<TextRange>();
Stack<List<HighlightInfo>> nestedInfos = new Stack<List<HighlightInfo>>();
Stack<TextRange> nestedRange = new Stack<>();
Stack<List<HighlightInfo>> nestedInfos = new Stack<>();
boolean failed = false;
int nextLimit = chunkSize;
for (int i = 0; i < elements.size(); i++) {
@@ -337,10 +333,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
try {
visitor.visit(element);
}
catch (ProcessCanceledException e) {
throw e;
}
catch (IndexNotReadyException e) {
catch (ProcessCanceledException | IndexNotReadyException e) {
throw e;
}
catch (Exception e) {
@@ -357,7 +350,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
}
TextRange elementRange = ranges.get(i);
List<HighlightInfo> infosForThisRange = holder.size() == 0 ? null : new ArrayList<HighlightInfo>(holder.size());
List<HighlightInfo> infosForThisRange = holder.size() == 0 ? null : new ArrayList<>(holder.size());
for (int j = 0; j < holder.size(); j++) {
final HighlightInfo info = holder.get(j);
@@ -415,7 +408,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
private static void cancelAndRestartDaemonLater(@NotNull ProgressIndicator progress,
@NotNull final Project project) throws ProcessCanceledException {
progress.cancel();
EdtExecutorService.getScheduledExecutorInstance().schedule((Runnable)() -> {
EdtExecutorService.getScheduledExecutorInstance().schedule(() -> {
Application application = ApplicationManager.getApplication();
if (!project.isDisposed() && !application.isDisposed() && !application.isUnitTestMode()) {
DaemonCodeAnalyzer.getInstance(project).restart();
@@ -495,7 +488,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
private static List<Problem> convertToProblems(@NotNull Collection<HighlightInfo> infos,
@NotNull VirtualFile file,
final boolean hasErrorElement) {
List<Problem> problems = new SmartList<Problem>();
List<Problem> problems = new SmartList<>();
for (HighlightInfo info : infos) {
if (info.getSeverity() == HighlightSeverity.ERROR) {
Problem problem = new ProblemImpl(file, info, hasErrorElement);
@@ -349,7 +349,7 @@ public interface Application extends ComponentManager {
/**
* Requests pooled thread to execute the action.
* This pool is<ul>
* This pool is an<ul>
* <li>Unbounded.</li>
* <li>Application-wide, always active, non-shutdownable singleton.</li>
* </ul>