Merge remote-tracking branch 'origin/master'

This commit is contained in:
Alexander Koshevoy
2016-03-01 15:20:22 +03:00
24 changed files with 191 additions and 75 deletions
+30 -11
View File
@@ -467,17 +467,6 @@ FunctionEnd
Function uninstallOldVersion
;check if the uninstalled application is running
remove_previous_installation:
;prepare a copy of launcher
CopyFiles "$3\bin\${PRODUCT_EXE_FILE}" "$3\bin\${PRODUCT_EXE_FILE}_copy"
ClearErrors
;copy launcher to itself
CopyFiles "$3\bin\${PRODUCT_EXE_FILE}_copy" "$3\bin\${PRODUCT_EXE_FILE}"
Delete "$3\bin\${PRODUCT_EXE_FILE}_copy"
IfErrors 0 +3
MessageBox MB_OKCANCEL|MB_ICONQUESTION|MB_TOPMOST "$(application_running)" IDOK remove_previous_installation IDCANCEL complete
goto complete
; uninstallation mode
!insertmacro INSTALLOPTIONS_READ $9 "UninstallOldVersions.ini" "Field 2" "State"
${If} $9 == "1"
@@ -1035,8 +1024,38 @@ complete:
${UnStrRep} $2 $2 "/" "\"
FunctionEnd
Function un.isIDEInUse
IfFileExists $R0 0 done
CopyFiles $R0 "$R0_copy"
ClearErrors
Delete $R0"
IfFileExists $R0 done
CopyFiles "$R0_copy" $R0
done:
Delete "$R0_copy"
FunctionEnd
Function un.checkIfIDEInUse
remove_previous_installation:
StrCpy $R0 "$INSTDIR\IdeaWin32.dll"
Call un.isIDEInUse
IfErrors remove_dialog 0
StrCpy $R0 "$INSTDIR\IdeaWin64.dll"
Call un.isIDEInUse
IfErrors remove_dialog done
remove_dialog:
MessageBox MB_OKCANCEL|MB_ICONQUESTION|MB_TOPMOST "$(application_running)" IDOK remove_previous_installation IDCANCEL cancel
cancel:
StrCpy $R0 "cancel"
done:
FunctionEnd
Section "Uninstall"
;check if the uninstalled application is running
Call un.checkIfIDEInUse
StrCmp $R0 "cancel" end_of_uninstall 0
; Uninstaller is in the \bin directory, we need upper level dir
StrCpy $productDir $INSTDIR
StrCpy $INSTDIR $INSTDIR\..
@@ -186,7 +186,7 @@ public class DebugProcessEvents extends DebugProcessImpl {
// check if there is already one request with policy SUSPEND_ALL
for (SuspendContextImpl context : getSuspendManager().getEventContexts()) {
if (context.getSuspendPolicy() == EventRequest.SUSPEND_ALL) {
if (isResumeOnlyCurrentThread() && locatableEvent != null) {
if (isResumeOnlyCurrentThread() && locatableEvent != null && !context.isEvaluating()) {
// if step event is present - switch context
getSuspendManager().resume(context);
//((SuspendManagerImpl)getSuspendManager()).popContext(context);
@@ -69,7 +69,7 @@ public class SameParameterValueInspection extends SameParameterValueInspectionBa
@Override
@NotNull
public String getFamilyName() {
return getName();
return InspectionsBundle.message("inspection.same.parameter.fix.family.name");
}
@Override
@@ -119,7 +119,8 @@ public class AssignableFromFilter implements ElementFilter{
expectedType,
false,
PsiUtil.getLanguageLevel(place));
if (substitutionForParameter != PsiType.NULL && !(substitutionForParameter instanceof PsiIntersectionType)) {
if (substitutionForParameter != PsiType.NULL && !(substitutionForParameter instanceof PsiIntersectionType) &&
PsiUtil.resolveClassInClassTypeOnly(substitutionForParameter) != parameter) {
return true;
}
}
@@ -0,0 +1,13 @@
class A {
{
Func2<String,String> f = ge<caret>x
}
<T,V> Func1<T,V> get1() {}
<T,V> Func2<T,V> get2() {}
}
interface Func1<T, V> {}
interface Func2<T, V> {}
@@ -175,4 +175,9 @@ public void testConvertToObjectStream() {
}
checkResultByFile("/" + getTestName(false) + "-out.java");
}
public void testOnlyCompatibleTypes() {
configureByTestName();
assertOrderedEquals(myFixture.getLookupElementStrings(), "get2");
}
}
@@ -1232,4 +1232,9 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
private CommonCodeStyleSettings getCodeStyleSettings() {
return CodeStyleSettingsManager.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE);
}
public void testOnlyCompatibleTypes() {
configureByTestName();
assertOrderedEquals(myFixture.getLookupElementStrings(), "get2");
}
}
@@ -71,7 +71,6 @@ import javax.swing.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.MutableTreeNode;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.event.InputEvent;
@@ -399,16 +398,16 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren
TreePath pathSelected = myTree.getSelectionModel().getLeadSelectionPath();
if (pathSelected != null) {
final InspectionTreeNode node = (InspectionTreeNode)pathSelected.getLastPathComponent();
if (node instanceof RefElementNode) {
final RefElementNode refElementNode = (RefElementNode)node;
final RefEntity refSelected = refElementNode.getElement();
showInRightPanel(refSelected);
}
else if (node instanceof ProblemDescriptionNode) {
if (node instanceof ProblemDescriptionNode) {
final ProblemDescriptionNode problemNode = (ProblemDescriptionNode)node;
showInRightPanel(problemNode.getElement());
}
else if (node instanceof InspectionNode || node instanceof InspectionPackageNode || node instanceof InspectionModuleNode) {
else if (node instanceof InspectionPackageNode ||
node instanceof InspectionModuleNode ||
node instanceof RefElementNode) {
showInRightPanel(node.getContainingFileLocalEntity());
}
else if (node instanceof InspectionNode) {
showInRightPanel(null);
}
else if (node instanceof InspectionRootNode || node instanceof InspectionGroupNode || node instanceof InspectionSeverityGroupNode) {
@@ -499,7 +498,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren
myPreviewEditor.getCaretModel().moveToOffset(finalSelectedElement.getTextOffset());
myPreviewEditor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
}
}, ModalityState.NON_MODAL);
}, ModalityState.any());
}
return myPreviewEditor.getComponent();
}
@@ -16,6 +16,7 @@
package com.intellij.codeInspection.ui;
import com.intellij.codeInspection.reference.RefEntity;
import com.intellij.openapi.vcs.FileStatus;
import org.jetbrains.annotations.Nullable;
@@ -109,4 +110,17 @@ public abstract class InspectionTreeNode extends DefaultMutableTreeNode {
}
}
public RefEntity getContainingFileLocalEntity() {
final Enumeration children = children();
RefEntity current = null;
while (children.hasMoreElements()) {
InspectionTreeNode child = (InspectionTreeNode)children.nextElement();
final RefEntity entity = child.getContainingFileLocalEntity();
if (entity == null || current != null) {
return null;
}
current = entity;
}
return current;
}
}
@@ -18,6 +18,7 @@ package com.intellij.codeInspection.ui;
import com.intellij.codeInspection.CommonProblemDescriptor;
import com.intellij.codeInspection.InspectionsBundle;
import com.intellij.codeInspection.reference.RefDirectory;
import com.intellij.codeInspection.reference.RefElement;
import com.intellij.codeInspection.reference.RefEntity;
import com.intellij.openapi.util.Computable;
@@ -124,4 +125,11 @@ public class RefElementNode extends InspectionTreeNode {
return mySingleDescriptor;
}
@Override
public RefEntity getContainingFileLocalEntity() {
final RefEntity element = getElement();
return element instanceof RefElement && !(element instanceof RefDirectory)
? element
: super.getContainingFileLocalEntity();
}
}
@@ -37,9 +37,6 @@ public interface DirectoryProjectGenerator<T> {
@Nls
String getName();
@Nullable
T showGenerationSettings(final VirtualFile baseDir) throws ProcessCanceledException;
/**
* @return 16x16 icon or null, if no icon is available
*/
@@ -57,18 +57,6 @@ public abstract class WebProjectGenerator<T> implements DirectoryProjectGenerato
return null;
}
@Override
@NotNull
public final T showGenerationSettings(VirtualFile baseDir) throws ProcessCanceledException {
GeneratorPeer<T> peer = createPeer();
DialogWrapper dialog = new MyDialogWrapper(peer);
dialog.show();
if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
throw new ProcessCanceledException();
}
return peer.getSettings();
}
@Override
public abstract void generateProject(@NotNull Project project, @NotNull VirtualFile baseDir, @NotNull T settings, @NotNull Module module);
@@ -672,6 +672,7 @@ unused.library.roots.problem.descriptor=Unused roots {0} from library ''{1}''
unused.library.backward.analysis.job.description=Perform backward analysis
inspection.duplicates.option.report.propertykey.expressions=&Ignore @PropertyKey expressions
inspection.same.parameter.fix.name=Inline value ''{1}'' for parameter ''{0}''
inspection.same.parameter.fix.family.name=Inline parameter as constant value
fix.all.inspection.problems.in.file=Fix all ''{0}'' problems in file
cleanup.in.file=Cleanup code
cleanup.in.scope=Cleanup code on...
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* 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.
@@ -18,6 +18,7 @@ package com.intellij.util.ui;
import com.intellij.ui.Gray;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
/**
@@ -27,7 +28,7 @@ public class ColorIcon extends EmptyIcon {
private final Color myColor;
private boolean myBorder;
private int myColorSize;
private ColorIcon myScaledCache;
public ColorIcon(int size, int colorSize, @NotNull Color color, final boolean border) {
super(size, size);
@@ -53,18 +54,36 @@ public class ColorIcon extends EmptyIcon {
final int iconWidth = getIconWidth();
final int iconHeight = getIconHeight();
g.setColor(getIconColor());
final int size = getColorSize();
final int x = i + (iconWidth - size) / 2;
final int y = j + (iconHeight - size) / 2;
final int x = i + (iconWidth - myColorSize) / 2;
final int y = j + (iconHeight - myColorSize) / 2;
g.fillRect(x, y, myColorSize, myColorSize);
g.fillRect(x, y, size, size);
if (myBorder) {
g.setColor(Gray.x00.withAlpha(40));
g.drawRect(x, y, myColorSize, myColorSize);
g.drawRect(x, y, size, size);
}
}
protected int getColorSize() {
return scale == 1f ? myColorSize : (int)(myColorSize * scale);
}
@Override
public Icon scale(float scaleFactor) {
if (scale == scaleFactor) {
return this;
}
if (myScaledCache != null && myScaledCache.scale == scaleFactor) {
return myScaledCache;
}
myScaledCache = new ColorIcon(getIconWidth(), myColorSize, myColor, myBorder);
myScaledCache.scale = scaleFactor;
return myScaledCache;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -41,7 +41,7 @@ public class EmptyIcon implements Icon, ScalableIcon {
private final int width;
private final int height;
private float scale = 1f;
protected float scale = 1f;
public static Icon create(int size) {
Icon icon = cache.get(size);
@@ -88,13 +88,20 @@ public class OptionalGetWithoutIsPresentInspection extends BaseInspection {
final PsiIfStatement ifStatement = (PsiIfStatement)sibling;
final PsiExpression condition = ifStatement.getCondition();
if (condition != null) {
if (!ControlFlowUtils.statementMayCompleteNormally(ifStatement.getThenBranch())) {
final PsiElement target = optionalReference.resolve();
if (!(target instanceof PsiVariable)) {
return true;
}
final PsiVariable variable = (PsiVariable)target;
final PsiStatement thenBranch = ifStatement.getThenBranch();
if (!ControlFlowUtils.statementMayCompleteNormally(thenBranch) || VariableAccessUtils.variableIsAssigned(variable, thenBranch)) {
checker.negate = true;
if (checker.checkExpression(condition)) {
return true;
}
}
else if (!ControlFlowUtils.statementMayCompleteNormally(ifStatement.getElseBranch())) {
final PsiStatement elseBranch = ifStatement.getElseBranch();
if (!ControlFlowUtils.statementMayCompleteNormally(elseBranch) || VariableAccessUtils.variableIsAssigned(variable, elseBranch)) {
checker.negate = false;
if (checker.checkExpression(condition)) {
return true;
@@ -50,4 +50,14 @@ class OptionalWithoutIsPresent {
org.testng.Assert.assertTrue(o3.isPresent());
System.out.println(o3.get());
}
public static String demo() {
Optional<String> holder = Optional.empty();
if (! holder.isPresent()) {
holder = Optional.of("hello world");
}
return holder.get();
}
}
@@ -79,6 +79,9 @@ public class OptionalGetWithoutIsPresentInspectionTest extends LightInspectionTe
" public static<T> Optional<T> empty() {" +
" return new Optional<>();" +
" }" +
" public static <T> Optional<T> of(T value) {" +
" return new Optional<>(value);" +
" }" +
"}",
"package java.util;" +
@@ -259,17 +259,17 @@ public class GrInplaceFieldIntroducer extends GrAbstractInplaceIntroducer<GrIntr
boolean replaceAllOccurrences) {
EnumSet<GrIntroduceFieldSettings.Init> result = EnumSet.noneOf(GrIntroduceFieldSettings.Init.class);
if (context.getExpression() != null ||
context.getVar() != null && context.getVar().getInitializerGroovy() != null ||
context.getStringPart() != null) {
result.add(GrIntroduceFieldSettings.Init.FIELD_DECLARATION);
}
if (!(context.getScope() instanceof GroovyScriptClass || context.getScope() instanceof GroovyFileBase)) {
if (context.getExpression() != null ||
context.getVar() != null && context.getVar().getInitializerGroovy() != null ||
context.getStringPart() != null) {
result.add(GrIntroduceFieldSettings.Init.FIELD_DECLARATION);
}
result.add(GrIntroduceFieldSettings.Init.CONSTRUCTOR);
}
PsiElement scope = context.getScope();
if (scope instanceof GroovyScriptClass) scope = scope.getContainingFile();
if (replaceAllOccurrences || context.getExpression() != null) {
PsiElement[] occurrences = replaceAllOccurrences ? context.getOccurrences() : new PsiElement[]{context.getExpression()};
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* 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.
@@ -366,7 +366,7 @@ public class GrIntroduceFieldProcessor {
private static GrReferenceExpression createRefExpression(@NotNull GrVariable field,
@NotNull PsiElement place,
@NotNull PsiClass containingClass) {
final String qname = containingClass.getQualifiedName();
final String qname = containingClass instanceof GroovyScriptClass ? null : containingClass.getQualifiedName();
final String prefix = qname != null ? qname + "." : "";
final String refText;
if (field.hasModifierProperty(PsiModifier.STATIC)) {
@@ -544,6 +544,24 @@ class TestClass {
''', false, false, false, CONSTRUCTOR
}
void 'test introduce field in script with invalid class name'() {
myFixture.configureByText "abcd-efgh.groovy", '''\
def aaa = "foo"
def bbb = "bar"
println(<selection>aaa + bbb</selection>)
'''
performRefactoring(null, false, false, false, CUR_METHOD, false)
myFixture.checkResult '''\
import groovy.transform.Field
@Field f
def aaa = "foo"
def bbb = "bar"
f = aaa + bbb
println(f)
'''
}
void 'test cannot initialize in current method when introducing from field initializer'() {
doTestInitInTarget '''
class A {
@@ -596,6 +614,34 @@ class A {
''', EnumSet.of(CONSTRUCTOR, FIELD_DECLARATION, CUR_METHOD), ReplaceChoice.NO
}
void 'test can initialize script field in current method only'() {
doTestInitInTarget '''
def a = 1
def b = 2
println(<selection>a + b</selection>)
''', EnumSet.of(CUR_METHOD)
doTestInitInTarget '''
def a = 1
def b = 2
println(<selection>a + b</selection>)
''', EnumSet.of(CUR_METHOD), ReplaceChoice.NO
doTestInitInTarget '''
def a = 1
def b = 2
def c = a + b
println(<selection>a + b</selection>)
''', EnumSet.of(CUR_METHOD)
doTestInitInTarget '''
def a = 1
def b = 2
def c = a + b
println(<selection>a + b</selection>)
''', EnumSet.of(CUR_METHOD), ReplaceChoice.NO
}
private void doTest(final boolean isStatic,
final boolean removeLocal,
final boolean declareFinal,
@@ -620,7 +666,6 @@ class A {
myFixture.checkResult(textAfter);
}
private void performRefactoring(String selectedType, boolean isStatic, boolean removeLocal, boolean declareFinal, GrIntroduceFieldSettings.Init initIn, boolean replaceAll) {
final PsiType type = selectedType == null ? null : JavaPsiFacade.getElementFactory(project).createTypeFromText(selectedType, myFixture.file)
def accessToken = WriteAction.start()
@@ -39,12 +39,6 @@ public class PyCCProjectGenerator extends PythonProjectGenerator implements Dire
return "Course creation";
}
@Nullable
@Override
public Object showGenerationSettings(VirtualFile baseDir) throws ProcessCanceledException {
return null;
}
@Nullable
@Override
public Icon getLogo() {
@@ -49,12 +49,6 @@ public class PyStudyDirectoryProjectGenerator extends PythonProjectGenerator imp
return "Educational";
}
@Nullable
@Override
public Object showGenerationSettings(VirtualFile baseDir) throws ProcessCanceledException {
return null;
}
@Nullable
@Override
public Icon getLogo() {
@@ -42,12 +42,6 @@ public class PythonBaseProjectGenerator extends PythonProjectGenerator implement
return "Pure Python";
}
@Nullable
@Override
public Object showGenerationSettings(VirtualFile baseDir) throws ProcessCanceledException {
return null;
}
@Override
@Nullable
public JComponent getSettingsPanel(File baseDir) throws ProcessCanceledException {