Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Trofimov
2013-05-28 13:41:44 +02:00
21 changed files with 187 additions and 79 deletions
@@ -25,6 +25,7 @@ import com.intellij.openapi.editor.event.DocumentEvent;
import com.intellij.openapi.help.HelpManager;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Pass;
@@ -32,6 +33,8 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.search.ProjectScope;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.refactoring.*;
import com.intellij.refactoring.move.MoveCallback;
import com.intellij.refactoring.move.MoveClassesOrPackagesCallback;
@@ -47,6 +50,7 @@ import com.intellij.ui.ReferenceEditorComboWithBrowseButton;
import com.intellij.ui.ReferenceEditorWithBrowseButton;
import com.intellij.usageView.UsageViewUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.hash.HashSet;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -56,6 +60,7 @@ import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Set;
public class MoveClassesOrPackagesDialog extends RefactoringDialog {
@NonNls private static final String RECENTS_KEY = "MoveClassesOrPackagesDialog.RECENTS_KEY";
@@ -270,7 +275,12 @@ public class MoveClassesOrPackagesDialog extends RefactoringDialog {
if (initialTargetDirectory != null &&
JavaMoveClassesOrPackagesHandler.packageHasMultipleDirectoriesInModule(myProject, initialTargetDirectory)) {
initialTargetDirectory = null;
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
final Set<VirtualFile> initialRoots = new HashSet<VirtualFile>();
collectSourceRoots(psiElements, fileIndex, initialRoots);
if (initialRoots.size() > 1) {
initialTargetDirectory = null;
}
}
((DestinationFolderComboBox)myDestinationFolderCB).setData(myProject, initialTargetDirectory,
new Pass<String>() {
@@ -284,6 +294,20 @@ public class MoveClassesOrPackagesDialog extends RefactoringDialog {
myHelpID = helpID;
}
private static void collectSourceRoots(PsiElement[] psiElements, ProjectFileIndex fileIndex, Set<VirtualFile> initialRoots) {
for (PsiElement element : psiElements) {
final VirtualFile file = PsiUtilCore.getVirtualFile(element);
if (file != null) {
final VirtualFile sourceRootForFile = fileIndex.getSourceRootForFile(file);
if (sourceRootForFile != null) {
initialRoots.add(sourceRootForFile);
}
} else if (element instanceof PsiDirectoryContainer) {
collectSourceRoots(((PsiDirectoryContainer)element).getDirectories(), fileIndex, initialRoots);
}
}
}
protected void doHelpAction() {
HelpManager.getInstance().invokeHelp(myHelpID);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 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.
@@ -15,6 +15,7 @@
*/
package com.intellij.ui.mac;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileChooser.PathChooserDialog;
@@ -25,11 +26,13 @@ import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.impl.IdeMenuBar;
import com.intellij.projectImport.ProjectOpenProcessor;
import com.intellij.ui.mac.foundation.Foundation;
import com.intellij.ui.mac.foundation.ID;
import com.intellij.ui.mac.foundation.MacUtil;
import com.intellij.util.Consumer;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
import com.sun.jna.Callback;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -271,6 +274,9 @@ public class MacFileChooserDialogImpl implements PathChooserDialog {
@Override
public void choose(@Nullable final VirtualFile toSelect, @NotNull final Consumer<List<VirtualFile>> callback) {
ExtensionsInitializer.initialize();
myCallback = callback;
final VirtualFile lastOpenedFile = FileChooserUtil.getLastOpenedFile(myProject);
@@ -333,4 +339,22 @@ public class MacFileChooserDialogImpl implements PathChooserDialog {
private static ID invoke(@NotNull final ID id, @NotNull final String selector, Object... args) {
return Foundation.invoke(id, Foundation.createSelector(selector), args);
}
/** This class is intended to force extensions initialization on EDT thread (IDEA-107271)
*/
private static class ExtensionsInitializer {
private ExtensionsInitializer() {}
private static boolean initialized;
private static void initialize () {
if (initialized) return;
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
Extensions.getExtensions(ProjectOpenProcessor.EXTENSION_POINT_NAME);
}
});
initialized = true;
}
}
}
@@ -130,7 +130,7 @@ ide.mac.hide.cursor.when.typing=true
ide.mac.show.native.help=true
ide.mac.useNativeClipboard=false
ide.mac.boldEditorTabs=false
ide.mac.modalDialogsOnFullscreen=false
ide.mac.modalDialogsOnFullscreen=true
# suppress inspection "UnusedProperty"
ide.mac.modalDialogsOnFullscreen.description=New modality approach. All dialogs are DOCUMENT_MODAL expect ide-wide dialogs
@@ -40,6 +40,7 @@ import com.intellij.util.xmlb.XmlSerializer;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.*;
/**
@@ -152,7 +153,11 @@ public class ChangelistConflictTracker {
}
private void checkOneFile(VirtualFile file, LocalChangeList defaultList) {
if (file == null || Comparing.equal(myChangeListManager.getChangeList(file), defaultList) || ChangesUtil.isInternalOperation(file)) {
if (file == null) {
return;
}
LocalChangeList changeList = myChangeListManager.getChangeList(file);
if (changeList == null || Comparing.equal(changeList, defaultList) || ChangesUtil.isInternalOperation(file)) {
return;
}
@@ -167,8 +172,6 @@ public class ChangelistConflictTracker {
newConflict = true;
}
}
conflict.timestamp = System.currentTimeMillis();
conflict.changelistId = defaultList.getId();
if (newConflict && myOptions.HIGHLIGHT_CONFLICTS) {
myFileStatusManager.fileStatusChanged(file);
@@ -217,11 +220,6 @@ public class ChangelistConflictTracker {
for (Map.Entry<String,Conflict> entry : myConflicts.entrySet()) {
Element fileElement = new Element("file");
fileElement.setAttribute("path", entry.getKey());
String id = entry.getValue().changelistId;
if (id != null) {
fileElement.setAttribute("changelist", id);
}
fileElement.setAttribute("time", Long.toString(entry.getValue().timestamp));
fileElement.setAttribute("ignored", Boolean.toString(entry.getValue().ignored));
to.addContent(fileElement);
}
@@ -234,18 +232,16 @@ public class ChangelistConflictTracker {
for (Object file : files) {
Element element = (Element)file;
String path = element.getAttributeValue("path");
if (path != null) {
Conflict conflict = new Conflict();
conflict.changelistId = element.getAttributeValue("changelist");
try {
conflict.timestamp = Long.parseLong(element.getAttributeValue("time"));
}
catch (NumberFormatException e) {
// do nothing
}
conflict.ignored = Boolean.parseBoolean(element.getAttributeValue("ignored"));
myConflicts.put(path, conflict);
if (path == null) {
continue;
}
VirtualFile vf = LocalFileSystem.getInstance().findFileByIoFile(new File(path));
if (vf == null || myChangeListManager.getChangeList(vf) == null) {
continue;
}
Conflict conflict = new Conflict();
conflict.ignored = Boolean.parseBoolean(element.getAttributeValue("ignored"));
myConflicts.put(path, conflict);
}
XmlSerializer.deserializeInto(myOptions, from);
}
@@ -273,8 +269,6 @@ public class ChangelistConflictTracker {
}
public static class Conflict {
long timestamp;
String changelistId;
boolean ignored;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2013 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.
@@ -17,6 +17,8 @@ package org.jetbrains.plugins.groovy.codeInspection.assignment;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.diagnostic.LogMessageEx;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiType;
@@ -25,6 +27,10 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.codeInspection.GroovyFix;
import org.jetbrains.plugins.groovy.lang.GrReferenceAdjuster;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrThrowStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrAssignmentExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrSafeCastExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
@@ -33,6 +39,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
* @author Maxim.Medvedev
*/
public class GrCastFix extends GroovyFix implements LocalQuickFix {
private static final Logger LOG = Logger.getInstance(GrCastFix.class);
private PsiType myExpectedType;
public GrCastFix(PsiType expectedType) {
@@ -41,16 +48,37 @@ public class GrCastFix extends GroovyFix implements LocalQuickFix {
@Override
protected void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
doCast(project, myExpectedType, descriptor.getPsiElement());
final GrExpression cast = findExpressionToCast(descriptor);
if (cast == null) return;
doCast(project, myExpectedType, cast);
}
static void doCast(Project project, PsiType type, PsiElement element) {
private static GrExpression findExpressionToCast(ProblemDescriptor descriptor) {
final PsiElement element = descriptor.getPsiElement();
final PsiElement parent = element.getParent();
if (parent instanceof GrVariable) {
return ((GrVariable)parent).getInitializerGroovy();
}
else if (parent instanceof GrAssignmentExpression) {
return ((GrAssignmentExpression)parent).getRValue();
}
else if (parent instanceof GrThrowStatement) {
return ((GrThrowStatement)parent).getException();
}
else if (parent instanceof GrReturnStatement) {
return ((GrReturnStatement)parent).getReturnValue();
}
else if (element instanceof GrExpression) {
return (GrExpression)element;
}
LogMessageEx.error(LOG, "can't find expression to cast at position " + element.getTextRange(), element.getContainingFile().getText());
return null;
}
static void doCast(@NotNull Project project, @NotNull PsiType type, @NotNull GrExpression expr) {
if (!type.isValid()) return;
if (!(element instanceof GrExpression)) return;
final GrExpression expr = (GrExpression)element;
final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(project);
final GrSafeCastExpression cast = (GrSafeCastExpression)factory.createExpressionFromText("foo as String");
final GrTypeElement typeElement = factory.createTypeElement(type);
@@ -122,7 +122,7 @@ public class GroovyAssignabilityCheckInspection extends BaseInspection {
}
private static class MyVisitor extends BaseInspectionVisitor {
private void checkAssignability(@NotNull PsiType expectedType, @NotNull GrExpression expression) {
private void checkAssignability(@NotNull PsiType expectedType, @NotNull GrExpression expression, PsiElement toHightlight) {
if (PsiUtil.isRawClassMemberAccess(expression)) return;
if (checkForImplicitEnumAssigning(expectedType, expression, expression)) return;
final PsiType rType = expression.getType();
@@ -131,7 +131,7 @@ public class GroovyAssignabilityCheckInspection extends BaseInspection {
if (!TypesUtil.isAssignable(expectedType, rType, expression)) {
final LocalQuickFix[] fixes = {new GrCastFix(expectedType)};
final String message = GroovyBundle.message("cannot.assign", rType.getPresentableText(), expectedType.getPresentableText());
registerError(expression, message, fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
registerError(toHightlight, message, fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
}
@@ -172,7 +172,7 @@ public class GroovyAssignabilityCheckInspection extends BaseInspection {
final PsiType returnType = PsiImplUtil.inferReturnType(returnStatement);
if (returnType != null) {
checkAssignability(returnType, value);
checkAssignability(returnType, value, returnStatement.getReturnWord());
}
}
@@ -184,7 +184,7 @@ public class GroovyAssignabilityCheckInspection extends BaseInspection {
final GrControlFlowOwner flowOwner = ControlFlowUtils.findControlFlowOwner(expression);
if (flowOwner != null && returnType != null && returnType != PsiType.VOID) {
if (ControlFlowUtils.isReturnValue(expression, flowOwner) && !isNewInstanceInitialingByTuple(expression)) {
checkAssignability(returnType, expression);
checkAssignability(returnType, expression, getExpressionPartToHighlight(expression));
}
}
}
@@ -240,7 +240,7 @@ public class GroovyAssignabilityCheckInspection extends BaseInspection {
if (clazz != null && CommonClassNames.JAVA_UTIL_LIST.equals(clazz.getQualifiedName())) {
final PsiType[] types = pct.getParameters();
if (types.length == 1 && types[0] != null && rType != null) {
checkAssignability(types[0], rType, tupleExpression, lValue);
checkAssignability(types[0], rType, tupleExpression, getExpressionPartToHighlight(lValue));
}
}
return;
@@ -251,7 +251,7 @@ public class GroovyAssignabilityCheckInspection extends BaseInspection {
}
if (lType != null && rType != null) {
checkAssignability(lType, rType, tupleExpression, lValue);
checkAssignability(lType, rType, tupleExpression, getExpressionPartToHighlight(lValue));
}
}
}
@@ -267,7 +267,7 @@ public class GroovyAssignabilityCheckInspection extends BaseInspection {
if (clazz != null && CommonClassNames.JAVA_UTIL_LIST.equals(clazz.getQualifiedName())) {
final PsiType[] types = pct.getParameters();
if (types.length == 1 && types[0] != null && rType != null) {
checkAssignability(types[0], rValue);
checkAssignability(types[0], rValue, getExpressionPartToHighlight(lValue));
}
}
return;
@@ -283,7 +283,7 @@ public class GroovyAssignabilityCheckInspection extends BaseInspection {
}
if (lType != null && rType != null) {
checkAssignability(lType, rValue);
checkAssignability(lType, rValue, getExpressionPartToHighlight(lValue));
}
}
@@ -341,11 +341,11 @@ public class GroovyAssignabilityCheckInspection extends BaseInspection {
}
}
PsiSubstitutor substitutor = PsiSubstitutorImpl.createSubstitutor(map);
checkAssignability(substitutor.substitute(varType), initializer);
checkAssignability(substitutor.substitute(varType), initializer, variable.getNameIdentifierGroovy());
return;
}
checkAssignability(varType, initializer);
checkAssignability(varType, initializer, variable.getNameIdentifierGroovy());
}
private void checkAssignability(@NotNull PsiType lType,
@@ -434,6 +434,15 @@ public class GroovyAssignabilityCheckInspection extends BaseInspection {
return elementToHighlight;
}
@NotNull
private static PsiElement getExpressionPartToHighlight(@NotNull GrExpression expr) {
if (expr instanceof GrClosableBlock) {
return ((GrClosableBlock)expr).getLBrace();
}
return expr;
}
@Override
public void visitListOrMap(GrListOrMap listOrMap) {
super.visitListOrMap(listOrMap);
@@ -473,8 +482,8 @@ public class GroovyAssignabilityCheckInspection extends BaseInspection {
final GrExpression exception = throwStatement.getException();
if (exception != null) {
checkAssignability(PsiType.getJavaLangThrowable(throwStatement.getManager(), throwStatement.getResolveScope()), exception
);
final PsiElement throwWord = throwStatement.getFirstChild();
checkAssignability(PsiType.getJavaLangThrowable(throwStatement.getManager(), throwStatement.getResolveScope()), exception, throwWord);
}
}
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2013 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.
*/
package org.jetbrains.plugins.groovy.lang
import com.intellij.codeInsight.generation.OverrideImplementUtil
@@ -10,6 +25,7 @@ import com.intellij.openapi.roots.ModifiableRootModel
import com.intellij.openapi.roots.OrderRootType
import com.intellij.openapi.roots.libraries.Library
import com.intellij.openapi.vfs.JarFileSystem
import com.intellij.psi.*
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.testFramework.LightProjectDescriptor
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor
@@ -22,8 +38,6 @@ import org.jetbrains.plugins.groovy.codeInspection.unassignedVariable.Unassigned
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod
import org.jetbrains.plugins.groovy.util.TestUtils
import com.intellij.psi.*
/**
* @author peter
*/
@@ -74,7 +88,7 @@ Y y = <warning descr="Constructor 'Y' in 'Y' cannot be applied to '(['a':java.la
def x = new Object() {
def foo() {
HashMap<String, File> m1 = ['a':['b']]
HashMap<String, File> m2 = <warning descr="Cannot assign 'File' to 'HashMap<String, File>'">new File('aaa')</warning>
HashMap<String, File> <warning descr="Cannot assign 'File' to 'HashMap<String, File>'">m2</warning> = new File('aaa')
}
}
"""
@@ -181,10 +195,10 @@ public interface Action {
"""
testAssignability """
Foo f = <warning descr="Cannot assign 'Closure' to 'Foo'">{ println it }</warning>
Foo <warning descr="Cannot assign 'Closure' to 'Foo'">f</warning> = { println it }
Function1<String, Object> f1 = { println it }
Function1<String, Object> f2 = { x=42 -> println x }
Function1<String, Object> f3 = <warning descr="Cannot assign 'Closure' to 'Function1<String, Object>'">{ int x -> println x }</warning>
Function1<String, Object> <warning descr="Cannot assign 'Closure' to 'Function1<String, Object>'">f3</warning> = { int x -> println x }
Runnable r = { println it }
Action a = { println it }
Action a1 = { a2 = 2 -> println a2 }
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2013 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.
*/
package org.jetbrains.plugins.groovy.lang
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
@@ -30,7 +45,7 @@ class A {
if ("aaa" =~ /aaa/ ? 1 : 2)
// Erorrs
int x = <warning descr="Cannot assign 'Matcher' to 'int'">"aaa" =~ /aaa/</warning>
int <warning descr="Cannot assign 'Matcher' to 'int'">x</warning> = "aaa" =~ /aaa/
xxx<warning descr="'xxx' in 'A' cannot be applied to '(java.util.regex.Matcher)'">("aaa" =~ /aaa/)</warning>
}
}
@@ -231,9 +231,9 @@ class A {
def foo = new A().&foo
int i = foo()
int i2 = <warning descr="Cannot assign 'Date' to 'int'">foo(2)</warning>
int <warning descr="Cannot assign 'Date' to 'int'">i2</warning> = foo(2)
Date d = foo(2)
Date d2 = <warning descr="Cannot assign 'Integer' to 'Date'">foo()</warning>
Date <warning descr="Cannot assign 'Integer' to 'Date'">d2</warning> = foo()
''')
}
@@ -247,7 +247,7 @@ class Bar {
def cl = new Bar<error descr="'(' expected">.</error>&foo
cl = cl.curry(1)
String s = cl("2")
int s2 = <warning descr="Cannot assign 'String' to 'int'">cl("2")</warning>
int <warning descr="Cannot assign 'String' to 'int'">s2</warning> = cl("2")
int i = cl(3)
String i2 = cl(3)
''')
@@ -259,7 +259,7 @@ def foo() {
throw new RuntimeException()
}
def bar () {
throw <warning descr="Cannot assign 'Object' to 'Throwable'">new Object()</warning>
<warning descr="Cannot assign 'Object' to 'Throwable'">throw</warning> new Object()
}
def test() {
@@ -305,12 +305,12 @@ import groovy.transform.CompileStatic
class A {
def foo(String s) {
int x = <warning descr="Cannot assign 'Date' to 'int'">new Date()</warning>
int <warning descr="Cannot assign 'Date' to 'int'">x</warning> = new Date()
}
@CompileStatic
def bar() {
int x = <error descr="Cannot assign 'Date' to 'int'">new Date()</error>
int <error descr="Cannot assign 'Date' to 'int'">x</error> = new Date()
}
}
''')
@@ -395,7 +395,7 @@ private int getObjects() {
//...
}
return <warning descr="Cannot assign 'String' to 'int'">''</warning>;
<warning descr="Cannot assign 'String' to 'int'">return</warning> '';
}
''')
}
@@ -445,17 +445,17 @@ String[] foox() {
}
int[] bar() {
return <warning descr="Cannot assign 'String' to 'int[]'">'ab'</warning>
<warning descr="Cannot assign 'String' to 'int[]'">return</warning> 'ab'
}
''')
}
void testAssignNullToPrimitiveTypesAndWrappers() {
testHighlighting('''\
int x = <warning descr="Cannot assign 'null' to 'int'">null</warning>
double y = <warning descr="Cannot assign 'null' to 'double'">null</warning>
int <warning descr="Cannot assign 'null' to 'int'">x</warning> = null
double <warning descr="Cannot assign 'null' to 'double'">y</warning> = null
Integer z = null
boolean a = <warning descr="Cannot assign 'null' to 'boolean'">null</warning>
boolean <warning descr="Cannot assign 'null' to 'boolean'">a</warning> = null
Boolean b = null
''')
}
@@ -506,7 +506,7 @@ Money d = [amount: 100, currency:'USA']
void testBooleanIsAssignableToAny() {
testHighlighting('''\
boolean b1 = new Object()
boolean b2 = <warning descr="Cannot assign 'null' to 'boolean'">null</warning>
boolean <warning descr="Cannot assign 'null' to 'boolean'">b2</warning> = null
Boolean b3 = new Object()
Boolean b4 = null
''')
@@ -686,10 +686,10 @@ class Foo extends PsiElement implements I {}
interface I {}
def <T extends PsiElement> T foo1(Class<T> x = <warning descr="Cannot assign 'Class<String>' to 'Class<? extends PsiElement>'">String</warning> ) {}
def <T extends PsiElement> T foo1(Class<T> <warning descr="Cannot assign 'Class<String>' to 'Class<? extends PsiElement>'">x</warning> = String ) {}
def <T extends PsiElement> T foo2(Class<T> x = PsiElement ) {}
def <T> T foo3(Class<T> x = PsiElement ) {}
def <T extends PsiElement & I> T foo4(Class<T> x = <warning descr="Cannot assign 'Class<PsiElement>' to 'Class<? extends PsiElement>'">PsiElement</warning> ) {}
def <T extends PsiElement & I> T foo4(Class<T> <warning descr="Cannot assign 'Class<PsiElement>' to 'Class<? extends PsiElement>'">x</warning> = PsiElement ) {}
def <T extends PsiElement & I> T foo5(Class<T> x = Foo ) {}
''')
}
@@ -568,7 +568,7 @@ int method(x, y, z) {
42
}
else if (z) {
return <error descr="Cannot assign 'String' to 'int'">'abc'</error>
<error descr="Cannot assign 'String' to 'int'">return</error> 'abc'
}
else {
return 43
@@ -3,4 +3,4 @@ class Foo {
def bar
}
new Foo().get
new Foo().get<caret>
@@ -15,4 +15,4 @@
*/
def a = 5
List<? extends Abc> l = <caret>a
List<? extends Abc> <caret>l = a
@@ -15,4 +15,4 @@
*/
def a = 5
List<? extends Abc> l = <caret>a as List<? extends Abc>
List<? extends Abc> <caret>l = a as List<? extends Abc>
@@ -1,4 +1,4 @@
class Pair {}
List<Pair> otherPairs = new ArrayList<Pair>();
List<Pair> pairs = otherPairs.findAll({it != null})
List<Date> pairs2 = <warning descr="Cannot assign 'ArrayList<Pair>' to 'List<Date>'">otherPairs.findAll({it != null})</warning>
List<Date> <warning descr="Cannot assign 'ArrayList<Pair>' to 'List<Date>'">pairs2</warning> = otherPairs.findAll({it != null})
@@ -2,4 +2,4 @@ enum My {
foo, bar
}
My var = <warning descr="Cannot assign 'String' to 'My'">'foo'</warning>
My <warning descr="Cannot assign 'String' to 'My'">var</warning> = 'foo'
@@ -1,6 +1,6 @@
class X{
int method1(Date date) {
return <warning descr="Cannot assign 'Date' to 'int'">date</warning>;
<warning descr="Cannot assign 'Date' to 'int'">return</warning> date;
}
int method2(Date date) {
@@ -8,8 +8,8 @@ class X{
}
}
X x=<warning descr="Cannot assign 'Date' to 'X'">new Date()</warning>;
x=<warning descr="Cannot assign 'Date' to 'X'">new Date()</warning>;
X <warning descr="Cannot assign 'Date' to 'X'">x</warning>=new Date();
<warning descr="Cannot assign 'Date' to 'X'">x</warning>=new Date();
class Y<T> {
T y;
@@ -20,5 +20,5 @@ y.y="abc";
String s=y.y;
print y;
int xxx = <warning descr="Cannot assign 'null' to 'int'">null</warning>
char ccc = <warning descr="Cannot assign 'null' to 'char'">null</warning>
int <warning descr="Cannot assign 'null' to 'int'">xxx</warning> = null
char <warning descr="Cannot assign 'null' to 'char'">ccc</warning> = null
@@ -17,4 +17,4 @@ class Foo implements I {
X foo = new Foo()
A foo2 = <warning descr="Cannot assign 'Foo' to 'A'">new Foo()</warning>
A <warning descr="Cannot assign 'Foo' to 'A'">foo2</warning> = new Foo()
@@ -15,4 +15,4 @@
*/
Map<Integer, Double> map3
map3 = [].collectEntries {}
int map4 = <warning descr="Cannot assign 'Map' to 'int'">[].collectEntries {}</warning>
int <warning descr="Cannot assign 'Map' to 'int'">map4</warning> = [].collectEntries {}
@@ -3,7 +3,7 @@ File foo() {
if (ints.empty) {
print {return 42}
for (x in ints) {
return <warning descr="Cannot assign 'Integer' to 'File'">43</warning>
<warning descr="Cannot assign 'Integer' to 'File'">return</warning> 43
}
}
<warning descr="Cannot assign 'Integer' to 'File'">67</warning>
@@ -1,3 +1,3 @@
def a='string text'
char ch = a //here should not be inspection warning
int x = <warning descr="Cannot assign 'String' to 'int'">a</warning> //check that assignability inspection is on.
int <warning descr="Cannot assign 'String' to 'int'">x</warning> = a //check that assignability inspection is on.
@@ -1,5 +1,5 @@
def foo = [1, 2, 3]
Double d = <warning descr="Constructor 'Double' in 'java.lang.Double' cannot be applied to '(java.lang.Integer, java.lang.Integer, java.lang.Integer)'">[1, 2, 3]</warning>
List<Double> list = <warning descr="Cannot assign 'ArrayList<String>' to 'List<Double>'">["1", "2"]</warning>
List<Double> <warning descr="Cannot assign 'ArrayList<String>' to 'List<Double>'">list</warning> = ["1", "2"]
List<Double> doubleList = [1, 2]
List<Double> secondDoubleList = [1.2, 2.5]