Merge remote-tracking branch 'origin/master'
@@ -1,11 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="winp">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/winp-1.16-patched.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/winp-1.17-patched.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/winp-1.16-patched-src.zip!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/winp-1.17-patched-src.zip!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@@ -235,7 +235,7 @@ libraryLicense(name: "TestNG", version: "5.7 snapshot", license: "Apache 2.0", u
|
||||
libraryLicense(name: "Trilead SSH", libraryName: "trilead-ssh2", version: "build 213", license: "BSD style (see LICENSE.txt in trilead.jar)", url: "http://www.trilead.com/SSH_Library/")
|
||||
libraryLicense(name: "Trove4j", version: "1.1 (with patches by JetBrains)", license: "LGPL", url: "http://trove4j.sourceforge.net/", licenseUrl: "http://trove4j.sourceforge.net/html/license.html")
|
||||
libraryLicense(name: "Velocity", version: "1.7", license: "Apache 2.0", url: "http://velocity.apache.org/", licenseUrl: "http://velocity.apache.org/index.html")
|
||||
libraryLicense(name: "winp", version: "1.16 (patched)", license: "MIT", url: "http://java.net/projects/winp", licenseUrl: "http://opensource.org/licenses/mit-license.php")
|
||||
libraryLicense(name: "winp", version: "1.17 (patched)", license: "MIT", url: "http://java.net/projects/winp", licenseUrl: "http://opensource.org/licenses/mit-license.php")
|
||||
libraryLicense(name: "Xalan", libraryName:"Xalan-2.7.1", version: "2.7.1", license: "Apache 2.0", url: "http://xml.apache.org/xalan-j/", licenseUrl: "http://xml.apache.org/xalan-j/")
|
||||
libraryLicense(name: "Xerces", version: "2.9.1", license: "Apache 2.0", url: "http://xerces.apache.org/xerces2-j/", licenseUrl: "http://xerces.apache.org/xerces2-j/")
|
||||
libraryLicense(name: "XML Commons (xml-apis.jar, resolver.jar)", version: "", license: "Apache 2.0, W3C Software License , public domain", url: "http://xml.apache.org/commons/", licenseUrl: "http://xml.apache.org/commons/licenses.html")
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<option name="FILESTATUS_changelistConflict" value="d5756c" />
|
||||
<option name="FILESTATUS_modifiedOutside" value="6897bb" />
|
||||
<option name="GUTTER_BACKGROUND" value="313335" />
|
||||
<option name="INDENT_GUIDE" value="4d4d4d" />
|
||||
<option name="INDENT_GUIDE" value="373737" />
|
||||
<option name="LINE_NUMBERS_COLOR" value="888888" />
|
||||
<option name="METHOD_SEPARATORS_COLOR" value="4d4d4d" />
|
||||
<option name="MODIFIED_LINES_COLOR" value="7180" />
|
||||
@@ -35,10 +35,11 @@
|
||||
<option name="RECURSIVE_CALL_ATTRIBUTES" value="574300" />
|
||||
<option name="REMOTE_HOST_MAPPED_BACKGROUND_KEY" value="164716" />
|
||||
<option name="RIGHT_MARGIN_COLOR" value="4d4d4d" />
|
||||
<option name="SELECTED_TEARLINE_COLOR" value="ffffff" />
|
||||
<option name="SELECTED_INDENT_GUIDE" value="505050" />
|
||||
<option name="SELECTED_TEARLINE_COLOR" value="787878" />
|
||||
<option name="SELECTION_BACKGROUND" value="214283" />
|
||||
<option name="SELECTION_FOREGROUND" value="" />
|
||||
<option name="TEARLINE_COLOR" value="909090" />
|
||||
<option name="TEARLINE_COLOR" value="555555" />
|
||||
<option name="WHITESPACES" value="404040" />
|
||||
</colors>
|
||||
<attributes>
|
||||
@@ -1615,7 +1616,7 @@
|
||||
</option>
|
||||
<option name="XML_ATTRIBUTE_NAME">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="d0d0ff" />
|
||||
<option name="FOREGROUND" value="bababa" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="XML_ATTRIBUTE_VALUE">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.compiler.options.CompilerUIConfigurable">
|
||||
<grid id="1663f" binding="myPanel" layout-manager="GridLayoutManager" row-count="10" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="1663f" binding="myPanel" layout-manager="GridLayoutManager" row-count="11" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="28" y="24" width="883" height="379"/>
|
||||
@@ -10,7 +10,7 @@
|
||||
<children>
|
||||
<vspacer id="67edf">
|
||||
<constraints>
|
||||
<grid row="9" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<grid row="10" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<grid id="b341d" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="1">
|
||||
@@ -95,7 +95,7 @@
|
||||
</component>
|
||||
<component id="17126" class="javax.swing.JLabel" binding="myHeapSizeLabel">
|
||||
<constraints>
|
||||
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Compiler process heap size (Mbytes):"/>
|
||||
@@ -103,7 +103,7 @@
|
||||
</component>
|
||||
<component id="a28b8" class="javax.swing.JTextField" binding="myHeapSizeField">
|
||||
<constraints>
|
||||
<grid row="7" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||
<grid row="8" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="50" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -111,7 +111,7 @@
|
||||
</component>
|
||||
<component id="5b86a" class="javax.swing.JLabel" binding="myVMOptionsLabel">
|
||||
<constraints>
|
||||
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Additional compiler process VM options:"/>
|
||||
@@ -119,7 +119,7 @@
|
||||
</component>
|
||||
<component id="b5547" class="javax.swing.JTextField" binding="myVMOptionsField">
|
||||
<constraints>
|
||||
<grid row="8" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<grid row="9" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -149,6 +149,14 @@
|
||||
<text value="(only works while not running / debugging)"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="4b44" class="javax.swing.JCheckBox" binding="myCbRebuildOnDependencyChange" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Rebuild module on dependency change"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
@@ -55,6 +55,7 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
|
||||
private JTextField myVMOptionsField;
|
||||
private JLabel myHeapSizeLabel;
|
||||
private JLabel myVMOptionsLabel;
|
||||
private JCheckBox myCbRebuildOnDependencyChange;
|
||||
|
||||
public CompilerUIConfigurable(final Project project) {
|
||||
myProject = project;
|
||||
@@ -84,6 +85,7 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
|
||||
myCbUseExternalBuild.setSelected(workspaceConfiguration.USE_COMPILE_SERVER);
|
||||
myCbEnableAutomake.setSelected(workspaceConfiguration.MAKE_PROJECT_ON_SAVE);
|
||||
myCbParallelCompilation.setSelected(workspaceConfiguration.PARALLEL_COMPILATION);
|
||||
myCbRebuildOnDependencyChange.setSelected(workspaceConfiguration.REBUILD_ON_DEPENDENCY_CHANGE);
|
||||
myHeapSizeField.setText(String.valueOf(workspaceConfiguration.COMPILER_PROCESS_HEAP_SIZE));
|
||||
final String options = workspaceConfiguration.COMPILER_PROCESS_ADDITIONAL_VM_OPTIONS;
|
||||
myVMOptionsField.setText(options == null? "" : options.trim());
|
||||
@@ -115,6 +117,7 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
|
||||
workspaceConfiguration.USE_COMPILE_SERVER = myCbUseExternalBuild.isSelected();
|
||||
workspaceConfiguration.MAKE_PROJECT_ON_SAVE = myCbEnableAutomake.isSelected();
|
||||
workspaceConfiguration.PARALLEL_COMPILATION = myCbParallelCompilation.isSelected();
|
||||
workspaceConfiguration.REBUILD_ON_DEPENDENCY_CHANGE = myCbRebuildOnDependencyChange.isSelected();
|
||||
try {
|
||||
workspaceConfiguration.COMPILER_PROCESS_HEAP_SIZE = Integer.parseInt(myHeapSizeField.getText().trim());
|
||||
}
|
||||
@@ -173,6 +176,7 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
|
||||
isModified |= ComparingUtils.isModified(myCbUseExternalBuild, workspaceConfiguration.USE_COMPILE_SERVER);
|
||||
isModified |= ComparingUtils.isModified(myCbEnableAutomake, workspaceConfiguration.MAKE_PROJECT_ON_SAVE);
|
||||
isModified |= ComparingUtils.isModified(myCbParallelCompilation, workspaceConfiguration.PARALLEL_COMPILATION);
|
||||
isModified |= ComparingUtils.isModified(myCbRebuildOnDependencyChange, workspaceConfiguration.REBUILD_ON_DEPENDENCY_CHANGE);
|
||||
isModified |= ComparingUtils.isModified(myHeapSizeField, workspaceConfiguration.COMPILER_PROCESS_HEAP_SIZE);
|
||||
isModified |= ComparingUtils.isModified(myVMOptionsField, workspaceConfiguration.COMPILER_PROCESS_ADDITIONAL_VM_OPTIONS);
|
||||
|
||||
@@ -211,6 +215,7 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
|
||||
private void updateExternalMakeOptionControls(boolean enabled) {
|
||||
myCbEnableAutomake.setEnabled(enabled);
|
||||
myCbParallelCompilation.setEnabled(enabled);
|
||||
myCbRebuildOnDependencyChange.setEnabled(enabled);
|
||||
myHeapSizeField.setEnabled(enabled);
|
||||
myVMOptionsField.setEnabled(enabled);
|
||||
myHeapSizeLabel.setEnabled(enabled);
|
||||
|
||||
@@ -827,6 +827,7 @@ public class BuildManager implements ApplicationComponent{
|
||||
cmdLine.addParameter("-D"+ GlobalOptions.GENERATE_CLASSPATH_INDEX_OPTION +"=" + shouldGenerateIndex);
|
||||
}
|
||||
cmdLine.addParameter("-D"+ GlobalOptions.COMPILE_PARALLEL_OPTION +"=" + Boolean.toString(config.PARALLEL_COMPILATION));
|
||||
cmdLine.addParameter("-D"+ GlobalOptions.REBUILD_ON_DEPENDENCY_CHANGE_OPTION + "=" + Boolean.toString(config.REBUILD_ON_DEPENDENCY_CHANGE));
|
||||
|
||||
if (Boolean.TRUE.equals(Boolean.valueOf(System.getProperty("java.net.preferIPv4Stack", "false")))) {
|
||||
cmdLine.addParameter("-Djava.net.preferIPv4Stack=true");
|
||||
|
||||
@@ -42,6 +42,7 @@ public class CompilerWorkspaceConfiguration implements PersistentStateComponent<
|
||||
public boolean PARALLEL_COMPILATION = false;
|
||||
public int COMPILER_PROCESS_HEAP_SIZE = DEFAULT_COMPILE_PROCESS_HEAP_SIZE;
|
||||
public String COMPILER_PROCESS_ADDITIONAL_VM_OPTIONS = DEFAULT_COMPILE_PROCESS_VM_OPTIONS;
|
||||
public boolean REBUILD_ON_DEPENDENCY_CHANGE = true;
|
||||
|
||||
public static CompilerWorkspaceConfiguration getInstance(Project project) {
|
||||
return ServiceManager.getService(project, CompilerWorkspaceConfiguration.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -616,6 +616,11 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
|
||||
return myDescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Alignment getAlignment() {
|
||||
return Alignment.RIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnAction getClickAction() {
|
||||
return new AnAction() {
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.intellij.patterns.ElementPattern;
|
||||
import com.intellij.patterns.PsiJavaPatterns;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.SuggestedNameInfo;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
@@ -366,46 +365,36 @@ public class JavaMemberNameCompletionContributor extends CompletionContributor {
|
||||
final boolean staticContext,
|
||||
final PsiType varType,
|
||||
final PsiElement element) {
|
||||
class Change implements Runnable {
|
||||
private String[] result;
|
||||
final List<String> propertyHandlers = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final List<String> propertyHandlers = new ArrayList<String>();
|
||||
final PsiField[] fields = psiClass.getFields();
|
||||
for (final PsiField field : psiClass.getFields()) {
|
||||
if (field == element) continue;
|
||||
|
||||
for (final PsiField field : fields) {
|
||||
if (field == element) continue;
|
||||
assert field.isValid() : "invalid field: " + field;
|
||||
PsiType fieldType = field.getType();
|
||||
assert fieldType.isValid() : "invalid field type: " + field + "; " + fieldType + " of " + fieldType.getClass();
|
||||
|
||||
assert field.isValid() : "invalid field: " + field;
|
||||
PsiType fieldType = field.getType();
|
||||
assert fieldType.isValid() : "invalid field type: " + field + "; " + fieldType + " of " + fieldType.getClass();
|
||||
final PsiModifierList modifierList = field.getModifierList();
|
||||
if (staticContext && (modifierList != null && !modifierList.hasModifierProperty(PsiModifier.STATIC))) continue;
|
||||
|
||||
final PsiModifierList modifierList = field.getModifierList();
|
||||
if (staticContext && (modifierList != null && !modifierList.hasModifierProperty(PsiModifier.STATIC))) continue;
|
||||
if (fieldType.equals(varType)) {
|
||||
final String getterName = PropertyUtil.suggestGetterName(field.getProject(), field);
|
||||
if ((psiClass.findMethodsByName(getterName, true).length == 0 ||
|
||||
psiClass.findMethodBySignature(PropertyUtil.generateGetterPrototype(field), true) == null)) {
|
||||
propertyHandlers.add(getterName);
|
||||
}
|
||||
}
|
||||
|
||||
if (fieldType.equals(varType)) {
|
||||
final String getterName = PropertyUtil.suggestGetterName(field.getProject(), field);
|
||||
if ((psiClass.findMethodsByName(getterName, true).length == 0 ||
|
||||
psiClass.findMethodBySignature(PropertyUtil.generateGetterPrototype(field), true) == null)) {
|
||||
propertyHandlers.add(getterName);
|
||||
}
|
||||
}
|
||||
|
||||
if (PsiType.VOID.equals(varType)) {
|
||||
final String setterName = PropertyUtil.suggestSetterName(field.getProject(), field);
|
||||
if ((psiClass.findMethodsByName(setterName, true).length == 0 ||
|
||||
psiClass.findMethodBySignature(PropertyUtil.generateSetterPrototype(field), true) == null)) {
|
||||
propertyHandlers.add(setterName);
|
||||
}
|
||||
}
|
||||
if (PsiType.VOID.equals(varType)) {
|
||||
final String setterName = PropertyUtil.suggestSetterName(field.getProject(), field);
|
||||
if ((psiClass.findMethodsByName(setterName, true).length == 0 ||
|
||||
psiClass.findMethodBySignature(PropertyUtil.generateSetterPrototype(field), true) == null)) {
|
||||
propertyHandlers.add(setterName);
|
||||
}
|
||||
result = ArrayUtil.toStringArray(propertyHandlers);
|
||||
}
|
||||
}
|
||||
final Change result = new Change();
|
||||
CodeStyleManager.getInstance(element.getProject()).performActionWithFormatterDisabled(result);
|
||||
return result.result;
|
||||
|
||||
return ArrayUtil.toStringArray(propertyHandlers);
|
||||
}
|
||||
|
||||
private static void addLookupItems(Set<LookupElement> lookupElements, @Nullable final SuggestedNameInfo callback, PrefixMatcher matcher, Project project, String... strings) {
|
||||
|
||||
@@ -431,7 +431,13 @@ public class MethodParameterInfoHandler implements ParameterInfoHandlerWithTabAc
|
||||
public void updateUI(final Object p, final ParameterInfoUIContext context) {
|
||||
if (p instanceof CandidateInfo) {
|
||||
CandidateInfo info = (CandidateInfo)p;
|
||||
updateMethodPresentation((PsiMethod)info.getElement(), getCandidateInfoSubstitutor(info), context);
|
||||
PsiMethod method = (PsiMethod)info.getElement();
|
||||
if (!method.isValid()) {
|
||||
context.setUIComponentEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
updateMethodPresentation(method, getCandidateInfoSubstitutor(info), context);
|
||||
}
|
||||
else {
|
||||
updateMethodPresentation((PsiMethod)p, null, context);
|
||||
|
||||
@@ -76,7 +76,7 @@ public class AnnotateMethodFix implements LocalQuickFix {
|
||||
if (annotateOverriddenMethods()) {
|
||||
PsiMethod[] methods = OverridingMethodsSearch.search(method, GlobalSearchScope.allScope(project), true).toArray(PsiMethod.EMPTY_ARRAY);
|
||||
for (PsiMethod psiMethod : methods) {
|
||||
if (!AnnotationUtil.isAnnotated(psiMethod, myAnnotation, false, false) && psiMethod.getManager().isInProject(psiMethod)) {
|
||||
if (AnnotationUtil.isAnnotatingApplicable(psiMethod, myAnnotation) && !AnnotationUtil.isAnnotated(psiMethod, myAnnotation, false, false) && psiMethod.getManager().isInProject(psiMethod)) {
|
||||
toAnnotate.add(psiMethod);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1218,7 +1218,7 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
ConditionalGotoInstruction cond = new ConditionalGotoInstruction(NOT_FOUND, false, null);
|
||||
addInstruction(cond);
|
||||
addInstruction(new EmptyStackInstruction());
|
||||
addInstruction(new PushInstruction(myFactory.getTypeFactory().create(ref), null));
|
||||
addInstruction(new PushInstruction(myFactory.getNotNullFactory().create(ref), null));
|
||||
addThrowCode(ref);
|
||||
cond.setOffset(myCurrentFlow.getInstructionCount());
|
||||
}
|
||||
@@ -1305,7 +1305,8 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if ("junit.framework.Assert".equals(className) || "org.junit.Assert".equals(className) || "org.testng.Assert".equals(className)) {
|
||||
else if ("junit.framework.Assert".equals(className) || "org.junit.Assert".equals(className) ||
|
||||
"junit.framework.TestCase".equals(className) || "org.testng.Assert".equals(className)) {
|
||||
boolean testng = "org.testng.Assert".equals(className);
|
||||
if ("fail".equals(methodName)) {
|
||||
pushParameters(params, false, !testng);
|
||||
|
||||
@@ -46,7 +46,7 @@ import java.util.*;
|
||||
|
||||
public class DataFlowRunner {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.dataFlow.DataFlowRunner");
|
||||
private static final Key<Integer> TOO_EXPENSIVE_SIZE = Key.create("TOO_EXPENSIVE_SIZE");
|
||||
private static final Key<Integer> TOO_EXPENSIVE_HASH = Key.create("TOO_EXPENSIVE_HASH");
|
||||
public static final long ourTimeLimit = 1000 * 1000 * 1000; //1 sec in nanoseconds
|
||||
|
||||
private Instruction[] myInstructions;
|
||||
@@ -103,14 +103,16 @@ public class DataFlowRunner {
|
||||
myFields = flow.getFields();
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Analyzing code block: " + psiBlock.getText());
|
||||
for (int i = 0; i < myInstructions.length; i++) {
|
||||
Instruction instruction = myInstructions[i];
|
||||
LOG.debug(i + ": " + instruction.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Integer tooExpensiveSize = psiBlock.getUserData(TOO_EXPENSIVE_SIZE);
|
||||
if (tooExpensiveSize != null && tooExpensiveSize == psiBlock.getText().hashCode()) {
|
||||
Integer tooExpensiveHash = psiBlock.getUserData(TOO_EXPENSIVE_HASH);
|
||||
if (tooExpensiveHash != null && tooExpensiveHash == psiBlock.getText().hashCode()) {
|
||||
LOG.debug("Too complex because hasn't changed since being too complex already");
|
||||
return RunnerResult.TOO_COMPLEX;
|
||||
}
|
||||
|
||||
@@ -125,7 +127,8 @@ public class DataFlowRunner {
|
||||
int count = 0;
|
||||
while (!queue.isEmpty()) {
|
||||
if (count % 50 == 0 && !unitTestMode && measurer.isTimeOver()) {
|
||||
psiBlock.putUserData(TOO_EXPENSIVE_SIZE, psiBlock.getText().hashCode());
|
||||
LOG.debug("Too complex because the analysis took too long");
|
||||
psiBlock.putUserData(TOO_EXPENSIVE_HASH, psiBlock.getText().hashCode());
|
||||
return RunnerResult.TOO_COMPLEX;
|
||||
}
|
||||
ProgressManager.checkCanceled();
|
||||
@@ -140,11 +143,14 @@ public class DataFlowRunner {
|
||||
|
||||
if (instruction instanceof BranchingInstruction) {
|
||||
if (!instruction.setMemoryStateProcessed(instructionState.getMemoryState().createCopy())) {
|
||||
LOG.debug("Too complex because too many different possible states");
|
||||
return RunnerResult.TOO_COMPLEX; // Too complex :(
|
||||
}
|
||||
}
|
||||
|
||||
//System.out.println(instructionState);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(instructionState.toString());
|
||||
}
|
||||
|
||||
DfaInstructionState[] after = instruction.accept(this, instructionState.getMemoryState(), visitor);
|
||||
if (after != null) {
|
||||
@@ -160,15 +166,18 @@ public class DataFlowRunner {
|
||||
count++;
|
||||
}
|
||||
|
||||
psiBlock.putUserData(TOO_EXPENSIVE_SIZE, null);
|
||||
psiBlock.putUserData(TOO_EXPENSIVE_HASH, null);
|
||||
LOG.debug("Analysis ok");
|
||||
return RunnerResult.OK;
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e) {
|
||||
LOG.error(psiBlock.getText(), e); /* TODO[max] !!! hack (of 18186). Please fix in better times. */
|
||||
LOG.error(psiBlock.getText(), e); // TODO fix in better times
|
||||
return RunnerResult.ABORTED;
|
||||
}
|
||||
catch (EmptyStackException e) {
|
||||
//LOG.error(psiBlock.getText(), e); /* TODO[max] !!! hack (of 18186). Please fix in better times. */
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.error(e); // TODO fix in better times
|
||||
}
|
||||
return RunnerResult.ABORTED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,9 @@ public class AnnotateOverriddenMethodParameterFix implements LocalQuickFix {
|
||||
for (PsiParameter psiParam : toAnnotate) {
|
||||
try {
|
||||
assert psiParam != null : toAnnotate;
|
||||
new AddAnnotationFix(myAnnotation, psiParam, myAnnosToRemove).invoke(project, null, psiParam.getContainingFile());
|
||||
if (AnnotationUtil.isAnnotatingApplicable(psiParam, myAnnotation)) {
|
||||
new AddAnnotationFix(myAnnotation, psiParam, myAnnosToRemove).invoke(project, null, psiParam.getContainingFile());
|
||||
}
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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 com.intellij.codeInspection.nullable;
|
||||
|
||||
import com.intellij.codeInsight.NullableNotNullManager;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiAnnotation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
* Date: 2/22/13
|
||||
*/
|
||||
class ChangeNullableDefaultsFix implements LocalQuickFix {
|
||||
private final NullableNotNullManager myManager;
|
||||
private final String myNotNullName;
|
||||
private final String myNullableName;
|
||||
|
||||
public ChangeNullableDefaultsFix(PsiAnnotation notNull, PsiAnnotation nullable, NullableNotNullManager manager) {
|
||||
myNotNullName = notNull != null ? notNull.getQualifiedName() : null;
|
||||
myNullableName = nullable != null ? nullable.getQualifiedName() : null;
|
||||
myManager = manager;
|
||||
}
|
||||
|
||||
ChangeNullableDefaultsFix(String notNull, String nullable, NullableNotNullManager manager) {
|
||||
myManager = manager;
|
||||
myNotNullName = notNull;
|
||||
myNullableName = nullable;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Make \"" + (myNotNullName != null ? myNotNullName : myNullableName) + "\" default annotation";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
if (myNotNullName != null) {
|
||||
myManager.setDefaultNotNull(myNotNullName);
|
||||
} else {
|
||||
myManager.setDefaultNullable(myNullableName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,14 @@ public class NullableStuffInspection extends BaseLocalInspectionTool {
|
||||
final String anno = annotated.isDeclaredNotNull ? manager.getDefaultNotNull() : manager.getDefaultNullable();
|
||||
final List<String> annoToRemove = annotated.isDeclaredNotNull ? manager.getNullables() : manager.getNotNulls();
|
||||
|
||||
if (!AnnotationUtil.isAnnotatingApplicable(field, anno)) {
|
||||
final PsiAnnotation notNull = AnnotationUtil.findAnnotation(field, manager.getNotNulls());
|
||||
final PsiAnnotation nullable = AnnotationUtil.findAnnotation(field, manager.getNullables());
|
||||
holder.registerProblem(field.getNameIdentifier(), "Nullable/NotNull defaults are not accessible in current context",
|
||||
new ChangeNullableDefaultsFix(notNull, nullable, manager));
|
||||
return;
|
||||
}
|
||||
|
||||
String propName = JavaCodeStyleManager.getInstance(project).variableNameToPropertyName(field.getName(), VariableKind.FIELD);
|
||||
final boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC);
|
||||
final PsiMethod getter = PropertyUtil.findPropertyGetter(field.getContainingClass(), propName, isStatic, false);
|
||||
@@ -289,9 +297,13 @@ public class NullableStuffInspection extends BaseLocalInspectionTool {
|
||||
reported_not_annotated_method_overrides_notnull = true;
|
||||
final String defaultNotNull = nullableManager.getDefaultNotNull();
|
||||
final String[] annotationsToRemove = ArrayUtil.toStringArray(nullableManager.getNullables());
|
||||
final LocalQuickFix fix = AnnotationUtil.isAnnotatingApplicable(method, defaultNotNull)
|
||||
? createAnnotateMethodFix(defaultNotNull, annotationsToRemove)
|
||||
: createChangeDefaultNotNullFix(nullableManager, superMethod);
|
||||
holder.registerProblem(method.getNameIdentifier(),
|
||||
InspectionsBundle.message("inspection.nullable.problems.method.overrides.NotNull"),
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, createAnnotateMethodFix(defaultNotNull, annotationsToRemove));
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
|
||||
wrapFix(fix));
|
||||
}
|
||||
if (REPORT_NOTNULL_PARAMETER_OVERRIDES_NULLABLE || REPORT_NOT_ANNOTATED_METHOD_OVERRIDES_NOTNULL) {
|
||||
PsiParameter[] superParameters = superMethod.getParameterList().getParameters();
|
||||
@@ -313,10 +325,13 @@ public class NullableStuffInspection extends BaseLocalInspectionTool {
|
||||
if (!AnnotationUtil.isAnnotated(parameter, nullableManager.getAllAnnotations(), false, false) &&
|
||||
nullableManager.isNotNull(superParameter, false)) {
|
||||
reported_not_annotated_parameter_overrides_notnull[i] = true;
|
||||
final LocalQuickFix fix = AnnotationUtil.isAnnotatingApplicable(parameter, nullableManager.getDefaultNotNull())
|
||||
? new AddNotNullAnnotationFix(parameter)
|
||||
: createChangeDefaultNotNullFix(nullableManager, superParameter);
|
||||
holder.registerProblem(parameter.getNameIdentifier(),
|
||||
InspectionsBundle.message("inspection.nullable.problems.parameter.overrides.NotNull"),
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
|
||||
new AddNotNullAnnotationFix(parameter));
|
||||
wrapFix(fix));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -334,22 +349,34 @@ public class NullableStuffInspection extends BaseLocalInspectionTool {
|
||||
}
|
||||
if (hasAnnotatedParameter || annotated.isDeclaredNotNull) {
|
||||
PsiManager manager = method.getManager();
|
||||
final String defaultNotNull = nullableManager.getDefaultNotNull();
|
||||
final boolean superMethodApplicable = AnnotationUtil.isAnnotatingApplicable(method, defaultNotNull);
|
||||
PsiMethod[] overridings =
|
||||
OverridingMethodsSearch.search(method, GlobalSearchScope.allScope(manager.getProject()), true).toArray(PsiMethod.EMPTY_ARRAY);
|
||||
boolean methodQuickFixSuggested = false;
|
||||
for (PsiMethod overriding : overridings) {
|
||||
if (!manager.isInProject(overriding)) continue;
|
||||
|
||||
final boolean applicable = AnnotationUtil.isAnnotatingApplicable(overriding, defaultNotNull);
|
||||
if (!methodQuickFixSuggested
|
||||
&& annotated.isDeclaredNotNull
|
||||
&& !nullableManager.isNotNull(overriding, false)
|
||||
&& (nullableManager.isNullable(overriding, false) || !nullableManager.isNullable(overriding, true))) {
|
||||
method.getNameIdentifier(); //load tree
|
||||
PsiAnnotation annotation = AnnotationUtil.findAnnotation(method, nullableManager.getNotNulls());
|
||||
final String defaultNotNull = nullableManager.getDefaultNotNull();
|
||||
PsiAnnotation annotation = AnnotationUtil.findAnnotation(method, nullableManager.getNotNulls());
|
||||
final String[] annotationsToRemove = ArrayUtil.toStringArray(nullableManager.getNullables());
|
||||
|
||||
final LocalQuickFix fix;
|
||||
if (applicable) {
|
||||
fix = new MyAnnotateMethodFix(defaultNotNull, annotationsToRemove);
|
||||
}
|
||||
else {
|
||||
fix = superMethodApplicable ? null : createChangeDefaultNotNullFix(nullableManager, method);
|
||||
}
|
||||
|
||||
holder.registerProblem(annotation, InspectionsBundle.message("nullable.stuff.problems.overridden.methods.are.not.annotated"),
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
|
||||
new MyAnnotateMethodFix(defaultNotNull, annotationsToRemove));
|
||||
wrapFix(fix));
|
||||
methodQuickFixSuggested = true;
|
||||
}
|
||||
if (hasAnnotatedParameter) {
|
||||
@@ -363,7 +390,7 @@ public class NullableStuffInspection extends BaseLocalInspectionTool {
|
||||
holder.registerProblem(annotation,
|
||||
InspectionsBundle.message("nullable.stuff.problems.overridden.method.parameters.are.not.annotated"),
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
|
||||
new AnnotateOverriddenMethodParameterFix(nullableManager.getDefaultNotNull(), nullableManager.getDefaultNullable()));
|
||||
wrapFix(!applicable ? createChangeDefaultNotNullFix(nullableManager, parameters[i]) : new AnnotateOverriddenMethodParameterFix(defaultNotNull, nullableManager.getDefaultNullable())));
|
||||
parameterQuickFixSuggested[i] = true;
|
||||
}
|
||||
}
|
||||
@@ -373,6 +400,19 @@ public class NullableStuffInspection extends BaseLocalInspectionTool {
|
||||
}
|
||||
}
|
||||
|
||||
private static LocalQuickFix[] wrapFix(LocalQuickFix fix) {
|
||||
if (fix == null) return LocalQuickFix.EMPTY_ARRAY;
|
||||
return new LocalQuickFix[]{fix};
|
||||
}
|
||||
|
||||
private static LocalQuickFix createChangeDefaultNotNullFix(NullableNotNullManager nullableManager, PsiModifierListOwner modifierListOwner) {
|
||||
final PsiAnnotation annotation = AnnotationUtil.findAnnotation(modifierListOwner, nullableManager.getNotNulls());
|
||||
if (annotation != null) {
|
||||
return new ChangeNullableDefaultsFix(annotation.getQualifiedName(), null, nullableManager);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected AnnotateMethodFix createAnnotateMethodFix(final String defaultNotNull, final String[] annotationsToRemove) {
|
||||
return new AnnotateMethodFix(defaultNotNull, annotationsToRemove);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class BasePackageParameterFactory extends ProjectTemplateParameterFactory
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "Base package:";
|
||||
return "Base \u001Bpackage:";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -78,63 +78,10 @@ public class ImportHelper{
|
||||
}
|
||||
});
|
||||
|
||||
int[] entryForName = ArrayUtil.newIntArray(names.size());
|
||||
PackageEntry[] entries = mySettings.IMPORT_LAYOUT_TABLE.getEntries();
|
||||
for(int i = 0; i < names.size(); i++){
|
||||
Pair<String, Boolean> pair = names.get(i);
|
||||
String packageName = pair.getFirst();
|
||||
Boolean isStatic = pair.getSecond();
|
||||
entryForName[i] = findEntryIndex(packageName, isStatic, entries);
|
||||
}
|
||||
|
||||
List<Pair<String, Boolean>> resultList = new ArrayList<Pair<String, Boolean>>(names.size());
|
||||
for(int i = 0; i < entries.length; i++){
|
||||
for(int j = 0; j < names.size(); j++){
|
||||
if (entryForName[j] == i){
|
||||
resultList.add(names.get(j));
|
||||
names.set(j, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Pair<String, Boolean> name : names) {
|
||||
if (name != null) resultList.add(name);
|
||||
}
|
||||
|
||||
TObjectIntHashMap<String> packageToCountMap = new TObjectIntHashMap<String>();
|
||||
TObjectIntHashMap<String> classToCountMap = new TObjectIntHashMap<String>();
|
||||
for (Pair<String, Boolean> pair : resultList) {
|
||||
String name = pair.getFirst();
|
||||
Boolean isStatic = pair.getSecond();
|
||||
String packageOrClassName = getPackageOrClassName(name);
|
||||
if (packageOrClassName.length() == 0) continue;
|
||||
if (isStatic) {
|
||||
int count = classToCountMap.get(packageOrClassName);
|
||||
classToCountMap.put(packageOrClassName, count + 1);
|
||||
}
|
||||
else {
|
||||
int count = packageToCountMap.get(packageOrClassName);
|
||||
packageToCountMap.put(packageOrClassName, count + 1);
|
||||
}
|
||||
}
|
||||
List<Pair<String, Boolean>> resultList = sortItemsAccordingToSettings(names, mySettings);
|
||||
|
||||
final Set<String> classesOrPackagesToImportOnDemand = new THashSet<String>();
|
||||
class MyVisitorProcedure implements TObjectIntProcedure<String> {
|
||||
private final boolean myIsVisitingPackages;
|
||||
|
||||
MyVisitorProcedure(boolean isVisitingPackages) {
|
||||
myIsVisitingPackages = isVisitingPackages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(final String packageOrClassName, final int count) {
|
||||
if (isToUseImportOnDemand(packageOrClassName, count, !myIsVisitingPackages)){
|
||||
classesOrPackagesToImportOnDemand.add(packageOrClassName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
classToCountMap.forEachEntry(new MyVisitorProcedure(false));
|
||||
packageToCountMap.forEachEntry(new MyVisitorProcedure(true));
|
||||
collectOnDemandImports(resultList, classesOrPackagesToImportOnDemand, ImportHelper.this.mySettings);
|
||||
|
||||
Set<String> classesToUseSingle = findSingleImports(file, resultList, classesOrPackagesToImportOnDemand);
|
||||
Set<String> toReimport = new THashSet<String>();
|
||||
@@ -176,6 +123,71 @@ public class ImportHelper{
|
||||
}
|
||||
}
|
||||
|
||||
public static void collectOnDemandImports(List<Pair<String, Boolean>> resultList,
|
||||
final Set<String> classesOrPackagesToImportOnDemand,
|
||||
final CodeStyleSettings settings) {
|
||||
TObjectIntHashMap<String> packageToCountMap = new TObjectIntHashMap<String>();
|
||||
TObjectIntHashMap<String> classToCountMap = new TObjectIntHashMap<String>();
|
||||
for (Pair<String, Boolean> pair : resultList) {
|
||||
String name = pair.getFirst();
|
||||
Boolean isStatic = pair.getSecond();
|
||||
String packageOrClassName = getPackageOrClassName(name);
|
||||
if (packageOrClassName.length() == 0) continue;
|
||||
if (isStatic) {
|
||||
int count = classToCountMap.get(packageOrClassName);
|
||||
classToCountMap.put(packageOrClassName, count + 1);
|
||||
}
|
||||
else {
|
||||
int count = packageToCountMap.get(packageOrClassName);
|
||||
packageToCountMap.put(packageOrClassName, count + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class MyVisitorProcedure implements TObjectIntProcedure<String> {
|
||||
private final boolean myIsVisitingPackages;
|
||||
|
||||
MyVisitorProcedure(boolean isVisitingPackages) {
|
||||
myIsVisitingPackages = isVisitingPackages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(final String packageOrClassName, final int count) {
|
||||
if (isToUseImportOnDemand(packageOrClassName, count, !myIsVisitingPackages, settings)){
|
||||
classesOrPackagesToImportOnDemand.add(packageOrClassName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
classToCountMap.forEachEntry(new MyVisitorProcedure(false));
|
||||
packageToCountMap.forEachEntry(new MyVisitorProcedure(true));
|
||||
}
|
||||
|
||||
public static List<Pair<String, Boolean>> sortItemsAccordingToSettings(List<Pair<String, Boolean>> names, final CodeStyleSettings settings) {
|
||||
int[] entryForName = ArrayUtil.newIntArray(names.size());
|
||||
PackageEntry[] entries = settings.IMPORT_LAYOUT_TABLE.getEntries();
|
||||
for(int i = 0; i < names.size(); i++){
|
||||
Pair<String, Boolean> pair = names.get(i);
|
||||
String packageName = pair.getFirst();
|
||||
Boolean isStatic = pair.getSecond();
|
||||
entryForName[i] = findEntryIndex(packageName, isStatic, entries);
|
||||
}
|
||||
|
||||
List<Pair<String, Boolean>> resultList = new ArrayList<Pair<String, Boolean>>(names.size());
|
||||
for(int i = 0; i < entries.length; i++){
|
||||
for(int j = 0; j < names.size(); j++){
|
||||
if (entryForName[j] == i){
|
||||
resultList.add(names.get(j));
|
||||
names.set(j, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Pair<String, Boolean> name : names) {
|
||||
if (name != null) resultList.add(name);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Set<String> findSingleImports(@NotNull final PsiJavaFile file,
|
||||
@NotNull List<Pair<String,Boolean>> names,
|
||||
@@ -620,13 +632,16 @@ public class ImportHelper{
|
||||
return maxSpace;
|
||||
}
|
||||
|
||||
private boolean isToUseImportOnDemand(@NotNull String packageName, int classCount, boolean isStaticImportNeeded){
|
||||
if (!mySettings.USE_SINGLE_CLASS_IMPORTS) return true;
|
||||
int limitCount = isStaticImportNeeded ? mySettings.NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND :
|
||||
mySettings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND;
|
||||
private static boolean isToUseImportOnDemand(@NotNull String packageName,
|
||||
int classCount,
|
||||
boolean isStaticImportNeeded,
|
||||
final CodeStyleSettings settings){
|
||||
if (!settings.USE_SINGLE_CLASS_IMPORTS) return true;
|
||||
int limitCount = isStaticImportNeeded ? settings.NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND :
|
||||
settings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND;
|
||||
if (classCount >= limitCount) return true;
|
||||
if (packageName.length() == 0) return false;
|
||||
PackageEntryTable table = mySettings.PACKAGES_TO_USE_IMPORT_ON_DEMAND;
|
||||
PackageEntryTable table = settings.PACKAGES_TO_USE_IMPORT_ON_DEMAND;
|
||||
return table != null && table.contains(packageName);
|
||||
}
|
||||
|
||||
|
||||
@@ -293,9 +293,13 @@ public class AnnotationUtil {
|
||||
}
|
||||
|
||||
public static boolean isAnnotatingApplicable(@NotNull PsiElement elt) {
|
||||
return isAnnotatingApplicable(elt, NullableNotNullManager.getInstance(elt.getProject()).getDefaultNullable());
|
||||
}
|
||||
|
||||
public static boolean isAnnotatingApplicable(@NotNull PsiElement elt, final String annotationFQN) {
|
||||
final Project project = elt.getProject();
|
||||
return PsiUtil.isLanguageLevel5OrHigher(elt) &&
|
||||
JavaPsiFacade.getInstance(project).findClass(NullableNotNullManager.getInstance(project).getDefaultNullable(), elt.getResolveScope()) != null;
|
||||
JavaPsiFacade.getInstance(project).findClass(annotationFQN, elt.getResolveScope()) != null;
|
||||
}
|
||||
|
||||
public static boolean isJetbrainsAnnotation(@NonNls final String simpleName) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -20,8 +20,10 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.impl.java.stubs.PsiImportListStub;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.util.ArrayFactory;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -63,17 +65,19 @@ public class PsiImportListImpl extends JavaStubPsiElement<PsiImportListStub> imp
|
||||
super.subtreeChanged();
|
||||
}
|
||||
|
||||
private static final TokenSet IMPORT_STATEMENT_BIT_SET = TokenSet.create(JavaElementType.IMPORT_STATEMENT);
|
||||
private static final TokenSet IMPORT_STATIC_STATEMENT_BIT_SET = TokenSet.create(JavaElementType.IMPORT_STATIC_STATEMENT);
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiImportStatement[] getImportStatements() {
|
||||
return getStubOrPsiChildren(ElementType.IMPORT_STATEMENT_BIT_SET, PsiImportStatementImpl.ARRAY_FACTORY);
|
||||
return getStubOrPsiChildren(IMPORT_STATEMENT_BIT_SET, PsiImportStatementImpl.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiImportStaticStatement[] getImportStaticStatements() {
|
||||
return getStubOrPsiChildren(ElementType.IMPORT_STATIC_STATEMENT_BIT_SET, PsiImportStaticStatementImpl.ARRAY_FACTORY);
|
||||
|
||||
return getStubOrPsiChildren(IMPORT_STATIC_STATEMENT_BIT_SET, PsiImportStaticStatementImpl.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -205,6 +205,7 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
|
||||
sortLambdaExpressionsLast(paramTypes, argTypes);
|
||||
boolean rawType = false;
|
||||
boolean nullPassed = false;
|
||||
boolean lambdaRaw = false;
|
||||
for (int j = 0; j < argTypes.length; j++) {
|
||||
PsiType argumentType = argTypes[j];
|
||||
if (argumentType == null) continue;
|
||||
@@ -228,6 +229,12 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
|
||||
if (currentSubstitution == FAILED_INFERENCE || (currentSubstitution == null && lowerBound == PsiType.NULL)) return RAW_INFERENCE;
|
||||
}
|
||||
if (nullPassed && currentSubstitution == null) return RAW_INFERENCE;
|
||||
if (currentSubstitution != null && currentSubstitution.first == null) {
|
||||
lambdaRaw = true;
|
||||
}
|
||||
if (currentSubstitution == null && lambdaRaw) {
|
||||
return new Pair<PsiType, ConstraintType>(PsiType.getJavaLangObject(typeParameter.getManager(), typeParameter.getResolveScope()), ConstraintType.EQUALS);
|
||||
}
|
||||
} else if (argumentType instanceof PsiMethodReferenceType) {
|
||||
final PsiMethodReferenceExpression referenceExpression = ((PsiMethodReferenceType)argumentType).getExpression();
|
||||
currentSubstitution = inferConstraintFromFunctionalInterfaceMethod(typeParameter, referenceExpression, partialSubstitutor.substitute(parameterType), partialSubstitutor, policy);
|
||||
@@ -998,7 +1005,7 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Pair<PsiType, ConstraintType> inferMethodTypeParameterFromParent(PsiElement parent,
|
||||
private static Pair<PsiType, ConstraintType> inferMethodTypeParameterFromParent(final PsiElement parent,
|
||||
PsiExpression methodCall,
|
||||
final PsiTypeParameter typeParameter,
|
||||
PsiSubstitutor substitutor,
|
||||
@@ -1065,16 +1072,24 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
|
||||
}
|
||||
}
|
||||
} else if (parent instanceof PsiLambdaExpression) {
|
||||
expectedType = LambdaUtil.getFunctionalInterfaceReturnType(((PsiLambdaExpression)parent).getFunctionalInterfaceType());
|
||||
expectedType = ourGraphGuard.doPreventingRecursion(methodCall, true, new Computable<PsiType>() {
|
||||
@Override
|
||||
public PsiType compute() {
|
||||
return LambdaUtil.getFunctionalInterfaceReturnType(((PsiLambdaExpression)parent).getFunctionalInterfaceType());
|
||||
}
|
||||
});
|
||||
if (expectedType == null) {
|
||||
return getFailedInferenceConstraint(typeParameter);
|
||||
return null;
|
||||
}
|
||||
} else if (parent instanceof PsiTypeCastExpression) {
|
||||
expectedType = ((PsiTypeCastExpression)parent).getType();
|
||||
} else if (parent instanceof PsiConditionalExpression) {
|
||||
if (PsiUtil.isLanguageLevel8OrHigher(parent)) {
|
||||
try {
|
||||
return inferMethodTypeParameterFromParent(PsiUtil.skipParenthesizedExprUp(parent.getParent()), (PsiExpression)parent, typeParameter, substitutor, policy);
|
||||
final Pair<PsiType, ConstraintType> pair = inferFromConditionalExpression(parent, methodCall, typeParameter, substitutor, policy);
|
||||
if (pair != null) {
|
||||
return pair;
|
||||
}
|
||||
}
|
||||
finally {
|
||||
GraphInferencePolicy.forget(parent);
|
||||
@@ -1175,6 +1190,42 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Pair<PsiType, ConstraintType> inferFromConditionalExpression(PsiElement parent,
|
||||
PsiExpression methodCall,
|
||||
PsiTypeParameter typeParameter,
|
||||
PsiSubstitutor substitutor,
|
||||
ParameterTypeInferencePolicy policy) {
|
||||
Pair<PsiType, ConstraintType> pair =
|
||||
inferMethodTypeParameterFromParent(PsiUtil.skipParenthesizedExprUp(parent.getParent()), (PsiExpression)parent, typeParameter, substitutor, policy);
|
||||
if (pair == null) {
|
||||
final PsiExpression thenExpression = ((PsiConditionalExpression)parent).getThenExpression();
|
||||
final PsiExpression elseExpression = ((PsiConditionalExpression)parent).getElseExpression();
|
||||
final PsiType[] paramTypes = {((PsiMethod)typeParameter.getOwner()).getReturnType()};
|
||||
if (methodCall.equals(PsiUtil.skipParenthesizedExprDown(elseExpression)) && thenExpression != null) {
|
||||
final PsiType thenType = ourGraphGuard.doPreventingRecursion(thenExpression, true, new Computable<PsiType>() {
|
||||
@Override
|
||||
public PsiType compute() {
|
||||
return thenExpression.getType();
|
||||
}
|
||||
});
|
||||
if (thenType != null) {
|
||||
pair = inferTypeForMethodTypeParameterInner(typeParameter, paramTypes, new PsiType[] {thenType}, substitutor, null, policy);
|
||||
}
|
||||
} else if (methodCall.equals(PsiUtil.skipParenthesizedExprDown(thenExpression)) && elseExpression != null) {
|
||||
final PsiType elseType = ourGraphGuard.doPreventingRecursion(elseExpression, true, new Computable<PsiType>() {
|
||||
@Override
|
||||
public PsiType compute() {
|
||||
return elseExpression.getType();
|
||||
}
|
||||
});
|
||||
if (elseType != null) {
|
||||
pair = inferTypeForMethodTypeParameterInner(typeParameter, paramTypes, new PsiType[] {elseType}, substitutor, null, policy);
|
||||
}
|
||||
}
|
||||
}
|
||||
return pair;
|
||||
}
|
||||
|
||||
private static final ProcessCandidateParameterTypeInferencePolicy GRAPH_INFERENCE_POLICY = new GraphInferencePolicy();
|
||||
|
||||
private static Pair<PsiType, ConstraintType> graphInferenceFromCallContext(@NotNull final PsiExpression methodCall,
|
||||
|
||||
@@ -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.
|
||||
@@ -70,12 +70,8 @@ public interface ElementType extends JavaTokenType, JavaDocTokenType, JavaElemen
|
||||
WHILE_STATEMENT, FOR_STATEMENT, FOREACH_STATEMENT, DO_WHILE_STATEMENT, SWITCH_STATEMENT, SWITCH_LABEL_STATEMENT, BREAK_STATEMENT,
|
||||
CONTINUE_STATEMENT, RETURN_STATEMENT, THROW_STATEMENT, SYNCHRONIZED_STATEMENT, TRY_STATEMENT, LABELED_STATEMENT, ASSERT_STATEMENT);
|
||||
|
||||
TokenSet TYPES_BIT_SET = TokenSet.create(TYPE);
|
||||
TokenSet IMPORT_STATEMENT_BIT_SET = TokenSet.create(IMPORT_STATEMENT);
|
||||
TokenSet IMPORT_STATIC_STATEMENT_BIT_SET = TokenSet.create(IMPORT_STATIC_STATEMENT);
|
||||
TokenSet IMPORT_STATEMENT_BASE_BIT_SET = TokenSet.create(IMPORT_STATEMENT, IMPORT_STATIC_STATEMENT);
|
||||
TokenSet CLASS_KEYWORD_BIT_SET = TokenSet.create(CLASS_KEYWORD, INTERFACE_KEYWORD, ENUM_KEYWORD);
|
||||
TokenSet MEMBER_BIT_SET = TokenSet.create(CLASS, FIELD, ENUM_CONSTANT, METHOD, ANNOTATION_METHOD);
|
||||
TokenSet FULL_MEMBER_BIT_SET = TokenSet.orSet(MEMBER_BIT_SET, TokenSet.create(CLASS_INITIALIZER));
|
||||
TokenSet ANNOTATIONS = TokenSet.create(ANNOTATION);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -214,7 +214,7 @@ public class ClassElement extends CompositeElement implements Constants {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
super.deleteChildInternal(child);
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ public class ClassElement extends CompositeElement implements Constants {
|
||||
else if (i == JavaDocElementType.DOC_COMMENT) {
|
||||
return getChildRole(child, ChildRole.DOC_COMMENT);
|
||||
}
|
||||
else if (i == C_STYLE_COMMENT || i == END_OF_LINE_COMMENT) {
|
||||
else if (ElementType.JAVA_PLAIN_COMMENT_BIT_SET.contains(i)) {
|
||||
return ChildRoleBase.NONE;
|
||||
}
|
||||
else if (i == MODIFIER_LIST) {
|
||||
@@ -376,7 +376,7 @@ public class ClassElement extends CompositeElement implements Constants {
|
||||
else if (i == IMPLEMENTS_LIST) {
|
||||
return ChildRole.IMPLEMENTS_LIST;
|
||||
}
|
||||
else if (i == CLASS_KEYWORD || i == INTERFACE_KEYWORD || i == ENUM_KEYWORD) {
|
||||
else if (ElementType.CLASS_KEYWORD_BIT_SET.contains(i)) {
|
||||
return getChildRole(child, ChildRole.CLASS_OR_INTERFACE_KEYWORD);
|
||||
}
|
||||
else if (i == IDENTIFIER) {
|
||||
@@ -403,5 +403,4 @@ public class ClassElement extends CompositeElement implements Constants {
|
||||
protected boolean isVisibilitySupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -38,7 +38,7 @@ public class PsiReferenceParameterListImpl extends CompositePsiElement implement
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiTypeElement[] getTypeParameterElements() {
|
||||
return getChildrenAsPsiElements(ElementType.TYPES_BIT_SET, PsiTypeElement.ARRAY_FACTORY);
|
||||
return getChildrenAsPsiElements(JavaElementType.TYPE, PsiTypeElement.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -28,8 +28,6 @@ import com.intellij.psi.impl.java.stubs.PsiTypeParameterStub;
|
||||
import com.intellij.psi.impl.light.LightEmptyImplementsList;
|
||||
import com.intellij.psi.impl.meta.MetaRegistry;
|
||||
import com.intellij.psi.impl.source.JavaStubPsiElement;
|
||||
import com.intellij.psi.impl.source.tree.ChildRole;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.meta.PsiMetaData;
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
@@ -44,7 +42,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dsl
|
||||
* @author dsl
|
||||
*/
|
||||
public class PsiTypeParameterImpl extends JavaStubPsiElement<PsiTypeParameterStub> implements PsiTypeParameter {
|
||||
private final LightEmptyImplementsList myLightEmptyImplementsList = new LightEmptyImplementsList(null) {
|
||||
@@ -169,7 +167,7 @@ public class PsiTypeParameterImpl extends JavaStubPsiElement<PsiTypeParameterStu
|
||||
return PsiTreeUtil.getParentOfType(this, PsiTypeParameterListOwner.class);
|
||||
}
|
||||
|
||||
return (PsiTypeParameterListOwner) parentParent;
|
||||
return (PsiTypeParameterListOwner)parentParent;
|
||||
}
|
||||
|
||||
|
||||
@@ -183,9 +181,10 @@ public class PsiTypeParameterImpl extends JavaStubPsiElement<PsiTypeParameterStu
|
||||
|
||||
int ret = 0;
|
||||
PsiElement element = getPrevSibling();
|
||||
while(element != null){
|
||||
if(element instanceof PsiTypeParameter)
|
||||
while (element != null) {
|
||||
if (element instanceof PsiTypeParameter) {
|
||||
ret++;
|
||||
}
|
||||
element = element.getPrevSibling();
|
||||
}
|
||||
return ret;
|
||||
@@ -194,11 +193,14 @@ public class PsiTypeParameterImpl extends JavaStubPsiElement<PsiTypeParameterStu
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiIdentifier getNameIdentifier() {
|
||||
return (PsiIdentifier) calcTreeElement().findChildByRole(ChildRole.NAME);
|
||||
return PsiTreeUtil.getRequiredChildOfType(this, PsiIdentifier.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place){
|
||||
public boolean processDeclarations(@NotNull PsiScopeProcessor processor,
|
||||
@NotNull ResolveState state,
|
||||
PsiElement lastParent,
|
||||
@NotNull PsiElement place) {
|
||||
return PsiClassImplUtil.processDeclarationsInClass(this, processor, state, null, lastParent, place, false);
|
||||
}
|
||||
|
||||
@@ -361,7 +363,7 @@ public class PsiTypeParameterImpl extends JavaStubPsiElement<PsiTypeParameterStu
|
||||
return "PsiTypeParameter:" + getName();
|
||||
}
|
||||
|
||||
public PsiMetaData getMetaData(){
|
||||
public PsiMetaData getMetaData() {
|
||||
return MetaRegistry.getMeta(this);
|
||||
}
|
||||
|
||||
@@ -384,7 +386,7 @@ public class PsiTypeParameterImpl extends JavaStubPsiElement<PsiTypeParameterStu
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiAnnotation[] getAnnotations() {
|
||||
return getStubOrPsiChildren(ElementType.ANNOTATIONS, PsiAnnotation.ARRAY_FACTORY);
|
||||
return getStubOrPsiChildren(JavaStubElementTypes.ANNOTATION, PsiAnnotation.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -397,6 +399,7 @@ public class PsiTypeParameterImpl extends JavaStubPsiElement<PsiTypeParameterStu
|
||||
public PsiAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) {
|
||||
throw new IncorrectOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiAnnotation[] getApplicableAnnotations() {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
public class Foo {
|
||||
|
||||
Zoo foo() {
|
||||
return r<caret>
|
||||
}
|
||||
|
||||
void rMethod() {}
|
||||
}
|
||||
|
||||
enum Zoo {
|
||||
LEFT, RIGHT
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
public class CyclicReferenceTest {
|
||||
void test(Match<String, Integer> match) {
|
||||
Match<String, Integer> matcher = match.or(s -> Optional.empty(), i -> 2);
|
||||
Match<String, Integer> matcher1 = match.or(s -> s.startsWith("_") ? Optional.of(1) : Optional.empty(), i -> 2);
|
||||
}
|
||||
}
|
||||
|
||||
class Match<T, V> {
|
||||
public <W> Match<T, V> or(Extractor<T, W> e, Function<W, V> c) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
interface Extractor<T, W> {
|
||||
Optional<W> unapply(T t);
|
||||
}
|
||||
|
||||
interface Function<W, V> {
|
||||
public V apply(W t);
|
||||
}
|
||||
|
||||
class Optional<W> {
|
||||
public static <T> Optional<T> empty() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> Optional<T> of(T value) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
class MyException extends Exception {}
|
||||
|
||||
class Foo {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
bar();
|
||||
} catch (Exception e) {
|
||||
if (e instanceof MyException) {
|
||||
return;
|
||||
}
|
||||
if (<warning descr="Condition 'e instanceof RuntimeException' is always 'true'">e instanceof RuntimeException</warning>) {
|
||||
return;
|
||||
}
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void bar() throws MyException {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -98,11 +98,11 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
}
|
||||
|
||||
public void testDispreferDeclared() throws Throwable {
|
||||
checkPreferredItems(0, "aabbb", "aaa");
|
||||
checkPreferredItems(0, "aabbb", "Aaaaaaa", "aaa");
|
||||
}
|
||||
|
||||
public void testDispreferDeclaredOfExpectedType() throws Throwable {
|
||||
checkPreferredItems(0, "aabbb", "aaa");
|
||||
checkPreferredItems(0, "aabbb", "Aaaaaaa", "aaa");
|
||||
}
|
||||
|
||||
public void testDispreferImpls() throws Throwable {
|
||||
@@ -596,4 +596,12 @@ import java.lang.annotation.Target;
|
||||
assertPreferredItems 0, 'setText', 'setOurText'
|
||||
}
|
||||
|
||||
public void testEnumConstantStartMatching() {
|
||||
checkPreferredItems(0, 'rMethod', 'Zoo.RIGHT')
|
||||
myFixture.type('i\n;\nreturn r')
|
||||
myFixture.completeBasic()
|
||||
assertPreferredItems 0, 'Zoo.RIGHT', 'rMethod'
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -216,6 +216,10 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAcceptRawSubstForLambda() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testCheckFunctionalInterfaceAccess() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testReturningNullFromVoidMethod() throws Throwable { doTest(); }
|
||||
|
||||
public void testCatchRuntimeException() throws Throwable { doTest(); }
|
||||
public void testNotNullCatchParameter() { doTest(); }
|
||||
|
||||
public void testAssertFailInCatch() throws Throwable {
|
||||
myFixture.addClass("package org.junit; public class Assert { public static void fail() {}}");
|
||||
|
||||
@@ -38,10 +38,10 @@ public class JavaFileStructureFilteringTest extends JavaFileStructureTestCase {
|
||||
public void testSelectLeafFirst3() throws Exception {checkTree("clear");}
|
||||
public void testSelectLeafFirst4() throws Exception {checkTree("clear");}
|
||||
|
||||
@Bombed(user = "peter", month = Calendar.MARCH, day = 1)
|
||||
@Bombed(user = "peter", month = Calendar.MAY, day = 10)
|
||||
public void testMatcher1() throws Exception {checkTree("ico");}
|
||||
@Bombed(user = "peter", month = Calendar.MARCH, day = 1)
|
||||
@Bombed(user = "peter", month = Calendar.MAY, day = 10)
|
||||
public void testMatcher2() throws Exception {checkTree("ico");}
|
||||
@Bombed(user = "peter", month = Calendar.MARCH, day = 1)
|
||||
@Bombed(user = "peter", month = Calendar.MAY, day = 10)
|
||||
public void testAnonymousMatcher2() throws Exception {checkTree("ico");}
|
||||
}
|
||||
|
||||
@@ -25,4 +25,5 @@ public interface GlobalOptions {
|
||||
String GENERATE_CLASSPATH_INDEX_OPTION = "generate.classpath.index";
|
||||
String COMPILE_PARALLEL_OPTION = "compile.parallel";
|
||||
String COMPILE_PARALLEL_MAX_THREADS_OPTION = "compile.parallel.max.threads";
|
||||
String REBUILD_ON_DEPENDENCY_CHANGE_OPTION = "rebuild.on.dependency.change";
|
||||
}
|
||||
|
||||
@@ -22,10 +22,13 @@ import org.jetbrains.jps.builders.*;
|
||||
import org.jetbrains.jps.builders.impl.BuildOutputConsumerImpl;
|
||||
import org.jetbrains.jps.builders.impl.BuildTargetChunk;
|
||||
import org.jetbrains.jps.builders.impl.DirtyFilesHolderBase;
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||
import org.jetbrains.jps.builders.logging.ProjectBuilderLogger;
|
||||
import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.cmdline.ProjectDescriptor;
|
||||
import org.jetbrains.jps.incremental.fs.BuildFSState;
|
||||
import org.jetbrains.jps.incremental.messages.BuildMessage;
|
||||
import org.jetbrains.jps.incremental.messages.CompilerMessage;
|
||||
import org.jetbrains.jps.incremental.messages.DoneSomethingNotification;
|
||||
import org.jetbrains.jps.incremental.messages.FileDeletedEvent;
|
||||
import org.jetbrains.jps.incremental.storage.BuildDataManager;
|
||||
@@ -48,17 +51,25 @@ public class BuildOperations {
|
||||
final ProjectDescriptor pd = context.getProjectDescriptor();
|
||||
final Timestamps timestamps = pd.timestamps.getStorage();
|
||||
final BuildTargetConfiguration configuration = pd.getTargetsState().getTargetConfiguration(target);
|
||||
|
||||
boolean isTargetConfigChange = false;
|
||||
if (context.isProjectRebuild()) {
|
||||
FSOperations.markDirtyFiles(context, target, timestamps, true, null, null);
|
||||
pd.fsState.markInitialScanPerformed(target);
|
||||
configuration.save();
|
||||
}
|
||||
else if (context.getScope().isRecompilationForced(target) || configuration.isTargetDirty() || configuration.outputRootWasDeleted(context)) {
|
||||
else if (context.getScope().isRecompilationForced(target) ||
|
||||
(isTargetConfigChange = configuration.isTargetDirty()) ||
|
||||
configuration.outputRootWasDeleted(context)) {
|
||||
initTargetFSState(context, target, true);
|
||||
IncProjectBuilder.clearOutputFiles(context, target);
|
||||
pd.dataManager.cleanTargetStorages(target);
|
||||
configuration.save();
|
||||
|
||||
if (isTargetConfigChange && ModuleBuildTarget.REBUILD_ON_DEPENDENCY_CHANGE && JavaModuleBuildTargetType.PRODUCTION.equals(target.getTargetType())) {
|
||||
final String moduleName = ((ModuleBuildTarget)target).getModule().getName();
|
||||
context.processMessage(new CompilerMessage("", BuildMessage.Kind.INFO, "Rebuilding module \"" + moduleName + "\" because of dependencies change"));
|
||||
}
|
||||
|
||||
}
|
||||
else if (!pd.fsState.isInitialScanPerformed(target)) {
|
||||
initTargetFSState(context, target, false);
|
||||
|
||||
@@ -22,6 +22,7 @@ import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.ProjectPaths;
|
||||
import org.jetbrains.jps.api.GlobalOptions;
|
||||
import org.jetbrains.jps.builders.*;
|
||||
import org.jetbrains.jps.builders.java.ExcludedJavaSourceRootProvider;
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||
@@ -50,6 +51,9 @@ import java.util.Set;
|
||||
* @author nik
|
||||
*/
|
||||
public final class ModuleBuildTarget extends JVMModuleBuildTarget<JavaSourceRootDescriptor> {
|
||||
public static final Boolean REBUILD_ON_DEPENDENCY_CHANGE = Boolean.valueOf(
|
||||
System.getProperty(GlobalOptions.REBUILD_ON_DEPENDENCY_CHANGE_OPTION, "true")
|
||||
);
|
||||
private final JavaModuleBuildTargetType myTargetType;
|
||||
|
||||
public ModuleBuildTarget(@NotNull JpsModule module, JavaModuleBuildTargetType targetType) {
|
||||
@@ -169,10 +173,13 @@ public final class ModuleBuildTarget extends JVMModuleBuildTarget<JavaSourceRoot
|
||||
}
|
||||
|
||||
private int getDependenciesFingerprint() {
|
||||
final JpsModule module = getModule();
|
||||
|
||||
int fingerprint = 0;
|
||||
|
||||
if (!REBUILD_ON_DEPENDENCY_CHANGE) {
|
||||
return fingerprint;
|
||||
}
|
||||
|
||||
final JpsModule module = getModule();
|
||||
JpsJavaDependenciesEnumerator enumerator = JpsJavaExtensionService.dependencies(module).compileOnly();
|
||||
if (!isTests()) {
|
||||
enumerator = enumerator.productionOnly();
|
||||
|
||||
@@ -243,7 +243,7 @@ public abstract class GlobalSearchScope extends SearchScope implements ProjectAw
|
||||
|
||||
@NotNull
|
||||
public static GlobalSearchScope moduleTestsWithDependentsScope(@NotNull Module module) {
|
||||
return module.getModuleWithDependentsScope();
|
||||
return module.getModuleTestsWithDependentsScope();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -53,6 +54,10 @@ public class Executor {
|
||||
}
|
||||
}
|
||||
|
||||
public static void cd(VirtualFile dir) {
|
||||
cd(dir.getPath());
|
||||
}
|
||||
|
||||
public static String pwd() {
|
||||
return ourCurrentDir;
|
||||
}
|
||||
@@ -157,15 +162,15 @@ public class Executor {
|
||||
for (String dir : path.split(File.pathSeparator)) {
|
||||
File file = new File(dir, name);
|
||||
if (file.canExecute()) {
|
||||
log("Using $programName from PATH");
|
||||
log("Using " + programName + " from PATH");
|
||||
return file.getPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalStateException("$programName executable not found. " +
|
||||
"Please define a valid environment variable ${pathEnvs.iterator().next()} " +
|
||||
"pointing to the $programName executable.");
|
||||
throw new IllegalStateException(programName + " executable not found. " +
|
||||
"Please define a valid environment variable " + pathEnvs.iterator().next() +
|
||||
" pointing to the " + programName + " executable.");
|
||||
}
|
||||
|
||||
protected static void log(String msg) {
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.picocontainer.alternatives.AbstractDelegatingMutablePicoContainer;
|
||||
/**
|
||||
* @author Alexander Kireyev
|
||||
*/
|
||||
@SuppressWarnings({"unchecked"})
|
||||
class AreaPicoContainerImpl extends AbstractDelegatingMutablePicoContainer implements AreaPicoContainer {
|
||||
private final AreaInstance myAreaInstance;
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 140 KiB |
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 635 B |
|
After Width: | Height: | Size: 469 B |
|
After Width: | Height: | Size: 472 B |
|
After Width: | Height: | Size: 520 B |
|
After Width: | Height: | Size: 511 B |
|
After Width: | Height: | Size: 698 B |
|
After Width: | Height: | Size: 704 B |
|
After Width: | Height: | Size: 364 B |
|
After Width: | Height: | Size: 161 B |
|
After Width: | Height: | Size: 350 B |
|
After Width: | Height: | Size: 469 B |
|
After Width: | Height: | Size: 472 B |
|
After Width: | Height: | Size: 517 B |
|
After Width: | Height: | Size: 511 B |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 390 B After Width: | Height: | Size: 460 B |
|
After Width: | Height: | Size: 981 B |
|
After Width: | Height: | Size: 874 B |
|
After Width: | Height: | Size: 448 B |
|
Before Width: | Height: | Size: 387 B After Width: | Height: | Size: 361 B |
|
After Width: | Height: | Size: 607 B |
|
Before Width: | Height: | Size: 452 B After Width: | Height: | Size: 348 B |
|
After Width: | Height: | Size: 567 B |
|
Before Width: | Height: | Size: 297 B After Width: | Height: | Size: 484 B |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 493 B |
|
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 165 B |
|
After Width: | Height: | Size: 283 B |
|
Before Width: | Height: | Size: 505 B After Width: | Height: | Size: 513 B |
|
After Width: | Height: | Size: 970 B |
|
After Width: | Height: | Size: 964 B |
|
Before Width: | Height: | Size: 482 B After Width: | Height: | Size: 506 B |
|
Before Width: | Height: | Size: 768 B After Width: | Height: | Size: 536 B |
|
After Width: | Height: | Size: 968 B |
|
After Width: | Height: | Size: 972 B |
|
After Width: | Height: | Size: 540 B |
|
Before Width: | Height: | Size: 212 B After Width: | Height: | Size: 449 B |
|
After Width: | Height: | Size: 921 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 481 B After Width: | Height: | Size: 470 B |
|
After Width: | Height: | Size: 817 B |
|
After Width: | Height: | Size: 818 B |
|
After Width: | Height: | Size: 455 B |
|
Before Width: | Height: | Size: 474 B After Width: | Height: | Size: 444 B |
|
After Width: | Height: | Size: 761 B |
|
After Width: | Height: | Size: 757 B |
|
After Width: | Height: | Size: 442 B |
|
Before Width: | Height: | Size: 457 B After Width: | Height: | Size: 493 B |
|
After Width: | Height: | Size: 856 B |
|
After Width: | Height: | Size: 856 B |
|
After Width: | Height: | Size: 494 B |
|
Before Width: | Height: | Size: 475 B After Width: | Height: | Size: 440 B |
|
After Width: | Height: | Size: 782 B |
|
After Width: | Height: | Size: 787 B |
|
After Width: | Height: | Size: 439 B |