Merge remote-tracking branch 'origin/master'

This commit is contained in:
Roman Shevchenko
2016-03-09 22:05:14 +01:00
209 changed files with 2704 additions and 1069 deletions
-1
View File
@@ -88,7 +88,6 @@ target(compile: "Compile project") {
projectBuilder.targetFolder = "$out/classes"
clearBuildCaches()
projectBuilder.cleanOutput()
bundledJDKs()
projectBuilder.buildProduction()
projectBuilder.makeModuleTests(findModule("jps-builders"))
}
@@ -818,6 +818,18 @@
</value>
</option>
<option baseAttributes="TEXT" name="IVAR" />
<option name="JADE_FILE_PATH">
<value>
<option name="FOREGROUND" value="66CC33" />
</value>
</option>
<option baseAttributes="DEFAULT_LABEL" name="JADE_FILTER_NAME" />
<option baseAttributes="DEFAULT_IDENTIFIER" name="JADE_JS_BLOCK" />
<option name="JADE_STATEMENTS">
<value>
<option name="FOREGROUND" value="CC7833" />
</value>
</option>
<option name="JAVA_BLOCK_COMMENT">
<value>
<option name="FOREGROUND" value="9933CC" />
@@ -1433,6 +1445,41 @@
<option name="BACKGROUND" value="434242" />
</value>
</option>
<option name="SPY-JS.EXCEPTION">
<value>
<option name="BACKGROUND" value="723f3f" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="FFFFFF" />
</value>
</option>
<option name="SPY-JS.FUNCTION_SCOPE">
<value>
<option name="BACKGROUND" value="2e2e1f" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="FFFFFF" />
</value>
</option>
<option name="SPY-JS.PATH_LEVEL_ONE">
<value>
<option name="BACKGROUND" value="264326" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="FFFFFF" />
</value>
</option>
<option name="SPY-JS.PATH_LEVEL_TWO">
<value>
<option name="EFFECT_TYPE" value="1" />
<option name="EFFECT_COLOR" value="FFFFFF" />
</value>
</option>
<option name="SPY-JS.PROGRAM_SCOPE">
<value>
<option name="BACKGROUND" value="2b2b2b" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="FFFFFF" />
</value>
</option>
<option baseAttributes="TEXT" name="SPY-JS.VALUE_HINT" />
<option name="STATIC_FIELD_ATTRIBUTES">
<value>
<option name="FOREGROUND" value="fda5ff" />
@@ -795,6 +795,26 @@
</value>
</option>
<option baseAttributes="TEXT" name="IVAR" />
<option name="JADE_FILE_PATH">
<value>
<option name="FOREGROUND" value="61CE3C" />
</value>
</option>
<option name="JADE_FILTER_NAME">
<value>
<option name="FOREGROUND" value="FF6400" />
</value>
</option>
<option name="JADE_JS_BLOCK">
<value>
<option name="FOREGROUND" value="FF6400" />
</value>
</option>
<option name="JADE_STATEMENTS">
<value>
<option name="FOREGROUND" value="FBDE2D" />
</value>
</option>
<option name="JAVA_BLOCK_COMMENT">
<value>
<option name="FOREGROUND" value="AEAEAE" />
@@ -1421,6 +1441,41 @@
</value>
</option>
<option baseAttributes="SLIM_STATIC_CONTENT" name="SLIM_TAG_START" />
<option name="SPY-JS.EXCEPTION">
<value>
<option name="BACKGROUND" value="713f3f" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="F8F8F8" />
</value>
</option>
<option name="SPY-JS.FUNCTION_SCOPE">
<value>
<option name="BACKGROUND" value="2e2e1f" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="F8F8F8" />
</value>
</option>
<option name="SPY-JS.PATH_LEVEL_ONE">
<value>
<option name="BACKGROUND" value="264326" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="F8F8F8" />
</value>
</option>
<option name="SPY-JS.PATH_LEVEL_TWO">
<value>
<option name="EFFECT_TYPE" value="1" />
<option name="EFFECT_COLOR" value="F8F8F8" />
</value>
</option>
<option name="SPY-JS.PROGRAM_SCOPE">
<value>
<option name="BACKGROUND" value="2b2b2b" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="F8F8F8" />
</value>
</option>
<option baseAttributes="TEXT" name="SPY-JS.VALUE_HINT" />
<option name="STATIC_FIELD_ATTRIBUTES">
<value>
<option name="FOREGROUND" value="fda5ff" />
+55
View File
@@ -964,6 +964,26 @@
<option name="FOREGROUND" value="CCCCCC" />
</value>
</option>
<option name="JADE_FILE_PATH">
<value>
<option name="FOREGROUND" value="3AD900" />
</value>
</option>
<option name="JADE_FILTER_NAME">
<value>
<option name="FOREGROUND" value="FFDD00" />
</value>
</option>
<option name="JADE_JS_BLOCK">
<value>
<option name="FOREGROUND" value="FFDD00" />
</value>
</option>
<option name="JADE_STATEMENTS">
<value>
<option name="FOREGROUND" value="FF9D00" />
</value>
</option>
<option name="JAVA_BLOCK_COMMENT">
<value>
<option name="FOREGROUND" value="0088FF" />
@@ -1835,6 +1855,41 @@
<option name="FOREGROUND" value="E1EFFF" />
</value>
</option>
<option name="SPY-JS.EXCEPTION">
<value>
<option name="BACKGROUND" value="713f3f" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="FFFFFF" />
</value>
</option>
<option name="SPY-JS.FUNCTION_SCOPE">
<value>
<option name="BACKGROUND" value="2e2e20" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="FFFFFF" />
</value>
</option>
<option name="SPY-JS.PATH_LEVEL_ONE">
<value>
<option name="BACKGROUND" value="254226" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="FFFFFF" />
</value>
</option>
<option name="SPY-JS.PATH_LEVEL_TWO">
<value>
<option name="EFFECT_TYPE" value="1" />
<option name="EFFECT_COLOR" value="FFFFFF" />
</value>
</option>
<option name="SPY-JS.PROGRAM_SCOPE">
<value>
<option name="BACKGROUND" value="2b2b2c" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="FFFFFF" />
</value>
</option>
<option baseAttributes="TEXT" name="SPY-JS.VALUE_HINT" />
<option name="STATIC_FIELD_ATTRIBUTES">
<value>
<option name="FOREGROUND" value="fda5ff" />
+49
View File
@@ -886,6 +886,20 @@
<option name="FOREGROUND" value="108888" />
</value>
</option>
<option name="JADE_FILE_PATH">
<value>
<option name="FOREGROUND" value="DD1144" />
<option name="BACKGROUND" value="f7e7f1" />
</value>
</option>
<option baseAttributes="DEFAULT_LABEL" name="JADE_FILTER_NAME" />
<option baseAttributes="DEFAULT_IDENTIFIER" name="JADE_JS_BLOCK" />
<option name="JADE_STATEMENTS">
<value>
<option name="FOREGROUND" value="000000" />
<option name="FONT_TYPE" value="1" />
</value>
</option>
<option name="JAVA_BLOCK_COMMENT">
<value>
<option name="FOREGROUND" value="DD1144" />
@@ -1675,6 +1689,41 @@
<option name="FOREGROUND" value="121289" />
</value>
</option>
<option name="SPY-JS.EXCEPTION">
<value>
<option name="BACKGROUND" value="fecccc" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="000000" />
</value>
</option>
<option name="SPY-JS.FUNCTION_SCOPE">
<value>
<option name="BACKGROUND" value="fefef0" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="000000" />
</value>
</option>
<option name="SPY-JS.PATH_LEVEL_ONE">
<value>
<option name="BACKGROUND" value="e2fee2" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="000000" />
</value>
</option>
<option name="SPY-JS.PATH_LEVEL_TWO">
<value>
<option name="EFFECT_TYPE" value="1" />
<option name="EFFECT_COLOR" value="000000" />
</value>
</option>
<option name="SPY-JS.PROGRAM_SCOPE">
<value>
<option name="BACKGROUND" value="fefeff" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="000000" />
</value>
</option>
<option baseAttributes="TEXT" name="SPY-JS.VALUE_HINT" />
<option name="STATIC_FIELD_ATTRIBUTES">
<value>
<option name="FOREGROUND" value="660e7a" />
+47
View File
@@ -797,6 +797,18 @@
</value>
</option>
<option baseAttributes="TEXT" name="IVAR" />
<option name="JADE_FILE_PATH">
<value>
<option name="FOREGROUND" value="E6DB74" />
</value>
</option>
<option baseAttributes="DEFAULT_LABEL" name="JADE_FILTER_NAME" />
<option baseAttributes="DEFAULT_IDENTIFIER" name="JADE_JS_BLOCK" />
<option name="JADE_STATEMENTS">
<value>
<option name="FOREGROUND" value="F92672" />
</value>
</option>
<option name="JAVA_BLOCK_COMMENT">
<value>
<option name="FOREGROUND" value="75715E" />
@@ -1461,6 +1473,41 @@
</value>
</option>
<option baseAttributes="SLIM_STATIC_CONTENT" name="SLIM_TAG_START" />
<option name="SPY-JS.EXCEPTION">
<value>
<option name="BACKGROUND" value="713f3f" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="F8F8F2" />
</value>
</option>
<option name="SPY-JS.FUNCTION_SCOPE">
<value>
<option name="BACKGROUND" value="2e2e1f" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="F8F8F2" />
</value>
</option>
<option name="SPY-JS.PATH_LEVEL_ONE">
<value>
<option name="BACKGROUND" value="264226" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="F8F8F2" />
</value>
</option>
<option name="SPY-JS.PATH_LEVEL_TWO">
<value>
<option name="EFFECT_TYPE" value="1" />
<option name="EFFECT_COLOR" value="F8F8F2" />
</value>
</option>
<option name="SPY-JS.PROGRAM_SCOPE">
<value>
<option name="BACKGROUND" value="2b2b2b" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="F8F8F2" />
</value>
</option>
<option baseAttributes="TEXT" name="SPY-JS.VALUE_HINT" />
<option name="STATIC_FIELD_ATTRIBUTES">
<value>
<option name="FOREGROUND" value="fda5ff" />
@@ -852,6 +852,18 @@
<option name="FOREGROUND" value="D0D0FF" />
</value>
</option>
<option name="JADE_FILE_PATH">
<value>
<option name="FOREGROUND" value="A5C261" />
</value>
</option>
<option baseAttributes="DEFAULT_LABEL" name="JADE_FILTER_NAME" />
<option baseAttributes="DEFAULT_IDENTIFIER" name="JADE_JS_BLOCK" />
<option name="JADE_STATEMENTS">
<value>
<option name="FOREGROUND" value="CC7833" />
</value>
</option>
<option name="JAVA_BLOCK_COMMENT">
<value>
<option name="FOREGROUND" value="BC9458" />
@@ -1582,6 +1594,41 @@
</value>
</option>
<option baseAttributes="SLIM_STATIC_CONTENT" name="SLIM_TAG_START" />
<option name="SPY-JS.EXCEPTION">
<value>
<option name="BACKGROUND" value="713f3f" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="E6E1DC" />
</value>
</option>
<option name="SPY-JS.FUNCTION_SCOPE">
<value>
<option name="BACKGROUND" value="2e2e1f" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="E6E1DC" />
</value>
</option>
<option name="SPY-JS.PATH_LEVEL_ONE">
<value>
<option name="BACKGROUND" value="264226" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="E6E1DC" />
</value>
</option>
<option name="SPY-JS.PATH_LEVEL_TWO">
<value>
<option name="EFFECT_TYPE" value="1" />
<option name="EFFECT_COLOR" value="E6E1DC" />
</value>
</option>
<option name="SPY-JS.PROGRAM_SCOPE">
<value>
<option name="BACKGROUND" value="2b2b2b" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="E6E1DC" />
</value>
</option>
<option baseAttributes="TEXT" name="SPY-JS.VALUE_HINT" />
<option name="STATIC_FIELD_ATTRIBUTES">
<value>
<option name="FOREGROUND" value="fda5ff" />
@@ -861,6 +861,26 @@
<option name="FOREGROUND" value="7587A6" />
</value>
</option>
<option name="JADE_FILE_PATH">
<value>
<option name="FOREGROUND" value="8F9D6A" />
</value>
</option>
<option name="JADE_FILTER_NAME">
<value>
<option name="FOREGROUND" value="9B703F" />
</value>
</option>
<option name="JADE_JS_BLOCK">
<value>
<option name="FOREGROUND" value="9B703F" />
</value>
</option>
<option name="JADE_STATEMENTS">
<value>
<option name="FOREGROUND" value="CDA869" />
</value>
</option>
<option name="JAVA_BLOCK_COMMENT">
<value>
<option name="FOREGROUND" value="5F5A60" />
@@ -1589,6 +1609,41 @@
</value>
</option>
<option baseAttributes="SLIM_STATIC_CONTENT" name="SLIM_TAG_START" />
<option name="SPY-JS.EXCEPTION">
<value>
<option name="BACKGROUND" value="713f3f" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="F8F8F8" />
</value>
</option>
<option name="SPY-JS.FUNCTION_SCOPE">
<value>
<option name="BACKGROUND" value="2e2e1f" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="F8F8F8" />
</value>
</option>
<option name="SPY-JS.PATH_LEVEL_ONE">
<value>
<option name="BACKGROUND" value="264326" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="F8F8F8" />
</value>
</option>
<option name="SPY-JS.PATH_LEVEL_TWO">
<value>
<option name="EFFECT_TYPE" value="1" />
<option name="EFFECT_COLOR" value="F8F8F8" />
</value>
</option>
<option name="SPY-JS.PROGRAM_SCOPE">
<value>
<option name="BACKGROUND" value="2b2b2b" />
<option name="EFFECT_TYPE" value="2" />
<option name="EFFECT_COLOR" value="F8F8F8" />
</value>
</option>
<option baseAttributes="TEXT" name="SPY-JS.VALUE_HINT" />
<option name="STATIC_FIELD_ATTRIBUTES">
<value>
<option name="FOREGROUND" value="fda5ff" />
@@ -293,10 +293,10 @@ public class BuildManager implements Disposable {
}
if (fileIndex.isInContent(eventFile)) {
if (ProjectCoreUtil.isProjectOrWorkspaceFile(eventFile)) {
if (ProjectCoreUtil.isProjectOrWorkspaceFile(eventFile) || GeneratedSourcesFilter.isGeneratedSourceByAnyFilter(eventFile, project)) {
// changes in project files or generated stuff should not trigger auto-make
continue;
}
return true;
}
}
-2
View File
@@ -21,8 +21,6 @@
<orderEntry type="module" module-name="java-impl" />
<orderEntry type="module" module-name="platform-impl" />
<orderEntry type="module" module-name="util" />
<orderEntry type="module" module-name="diff-api" />
<orderEntry type="module" module-name="jps-builders" />
</component>
<component name="copyright">
<Base>
@@ -26,6 +26,7 @@ import com.intellij.psi.JavaRecursiveElementVisitor;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiLocalVariable;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XDebuggerManager;
import com.intellij.xdebugger.impl.XDebugSessionImpl;
@@ -87,7 +88,7 @@ public class CodeFragmentFactoryContextWrapper extends CodeFragmentFactory {
XValueMarkers<?, ?> markers = ((XDebugSessionImpl)session).getValueMarkers();
Map<?, ValueMarkup> markupMap = markers != null ? markers.getAllMarkers() : null;
//final Map<ObjectReference, ValueMarkup> markupMap = ValueDescriptorImpl.getMarkupMap(process);
if (markupMap != null && markupMap.size() > 0) {
if (ContainerUtil.isEmpty(markupMap)) {
final Pair<String, Map<String, ObjectReference>> markupVariables = createMarkupVariablesText(markupMap);
int offset = markupVariables.getFirst().length() - 1;
final TextWithImportsImpl textWithImports = new TextWithImportsImpl(CodeFragmentKind.CODE_BLOCK, markupVariables.getFirst(), "", myDelegate.getFileType());
@@ -0,0 +1,54 @@
/*
* 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.
* 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.debugger.engine.evaluation.expression;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
import com.sun.jdi.ObjectReference;
/**
* @author egor
*/
public class CatchEvaluator implements Evaluator {
private final String myExceptionType;
private final String myParamName;
private final CodeFragmentEvaluator myEvaluator;
public CatchEvaluator(String exceptionType, String paramName, CodeFragmentEvaluator evaluator) {
myExceptionType = exceptionType;
myParamName = paramName;
myEvaluator = evaluator;
}
public Object evaluate(ObjectReference exception, EvaluationContextImpl context) throws EvaluateException {
myEvaluator.setValue(myParamName, exception);
return myEvaluator.evaluate(context);
}
@Override
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
throw new IllegalStateException("Use evaluate(ObjectReference exception, EvaluationContextImpl context)");
}
public String getExceptionType() {
return myExceptionType;
}
@Override
public Modifier getModifier() {
return null;
}
}
@@ -18,6 +18,7 @@ package com.intellij.debugger.engine.evaluation.expression;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
import com.intellij.debugger.engine.evaluation.EvaluateRuntimeException;
import com.intellij.debugger.jdi.VirtualMachineProxyImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.containers.HashMap;
@@ -103,10 +104,11 @@ public class CodeFragmentEvaluator extends BlockStatementEvaluator{
}
}
public void setInitialValue(String localName, Object value) throws EvaluateException {
public void setInitialValue(String localName, Object value) {
LOG.assertTrue(!(value instanceof Value), "use setValue for jdi values");
if(hasValue(localName)) {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.variable.already.declared", localName));
throw new EvaluateRuntimeException(
EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.variable.already.declared", localName)));
}
mySyntheticLocals.put(localName, value);
}
@@ -190,9 +190,42 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
@Override
public void visitTryStatement(PsiTryStatement statement) {
throw new EvaluateRuntimeException(new UnsupportedExpressionException(statement.getText()));
Evaluator bodyEvaluator = accept(statement.getTryBlock());
if (bodyEvaluator != null) {
PsiCatchSection[] catchSections = statement.getCatchSections();
CatchEvaluator[] evaluators = new CatchEvaluator[catchSections.length];
for (int i = 0; i < catchSections.length; i++) {
CodeFragmentEvaluator oldFragmentEvaluator = setNewCodeFragmentEvaluator();
try {
PsiCatchSection section = catchSections[i];
PsiParameter parameter = section.getParameter();
if (parameter != null) {
myCurrentFragmentEvaluator.setInitialValue(parameter.getName(), null);
myCurrentFragmentEvaluator.setStatements(visitStatements(section.getCatchBlock().getStatements()));
evaluators[i] = new CatchEvaluator(parameter.getType().getCanonicalText(), parameter.getName(), myCurrentFragmentEvaluator);
}
} finally {
myCurrentFragmentEvaluator = oldFragmentEvaluator;
}
}
myResult = new TryEvaluator(bodyEvaluator, evaluators, accept(statement.getFinallyBlock()));
}
}
@Override
public void visitThrowStatement(PsiThrowStatement statement) {
Evaluator accept = accept(statement.getException());
if (accept != null) {
myResult = new ThrowEvaluator(accept);
}
}
@Override
public void visitReturnStatement(PsiReturnStatement statement) {
myResult = new ReturnEvaluator(accept(statement.getReturnValue()));
}
@Override
public void visitStatement(PsiStatement statement) {
throwEvaluateException(DebuggerBundle.message("evaluation.error.statement.not.supported", statement.getText()));
@@ -204,25 +237,33 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
return old;
}
private Evaluator[] visitStatements(PsiStatement[] statements) {
Evaluator[] evaluators = new Evaluator[statements.length];
for (int i = 0; i < statements.length; i++) {
PsiStatement psiStatement = statements[i];
psiStatement.accept(this);
evaluators[i] = new DisableGC(myResult);
myResult = null;
}
return evaluators;
}
@Override
public void visitBlockStatement(PsiBlockStatement statement) {
public void visitCodeBlock(PsiCodeBlock block) {
CodeFragmentEvaluator oldFragmentEvaluator = setNewCodeFragmentEvaluator();
try {
PsiStatement[] statements = statement.getCodeBlock().getStatements();
Evaluator[] evaluators = new Evaluator[statements.length];
for (int i = 0; i < statements.length; i++) {
PsiStatement psiStatement = statements[i];
psiStatement.accept(this);
evaluators[i] = new DisableGC(myResult);
myResult = null;
}
myResult = new BlockStatementEvaluator(evaluators);
myResult = new BlockStatementEvaluator(visitStatements(block.getStatements()));
}
finally {
myCurrentFragmentEvaluator = oldFragmentEvaluator;
}
}
@Override
public void visitBlockStatement(PsiBlockStatement statement) {
visitCodeBlock(statement.getCodeBlock());
}
@Override
public void visitLabeledStatement(PsiLabeledStatement labeledStatement) {
PsiStatement statement = labeledStatement.getStatement();
@@ -259,33 +300,40 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
@Override
public void visitForStatement(PsiForStatement statement) {
Evaluator initializerEvaluator = accept(statement.getInitialization());
Evaluator conditionEvaluator = accept(statement.getCondition());
if (conditionEvaluator != null) {
conditionEvaluator = new UnBoxingEvaluator(conditionEvaluator);
}
Evaluator updateEvaluator = accept(statement.getUpdate());
Evaluator bodyEvaluator = accept(statement.getBody());
if (bodyEvaluator != null) {
myResult = new ForStatementEvaluator(initializerEvaluator, conditionEvaluator, updateEvaluator, bodyEvaluator, getLabel(statement));
CodeFragmentEvaluator oldFragmentEvaluator = setNewCodeFragmentEvaluator();
try {
Evaluator initializerEvaluator = accept(statement.getInitialization());
Evaluator conditionEvaluator = accept(statement.getCondition());
if (conditionEvaluator != null) {
conditionEvaluator = new UnBoxingEvaluator(conditionEvaluator);
}
Evaluator updateEvaluator = accept(statement.getUpdate());
Evaluator bodyEvaluator = accept(statement.getBody());
if (bodyEvaluator != null) {
myResult =
new ForStatementEvaluator(initializerEvaluator, conditionEvaluator, updateEvaluator, bodyEvaluator, getLabel(statement));
}
} finally {
myCurrentFragmentEvaluator = oldFragmentEvaluator;
}
}
@Override
public void visitForeachStatement(PsiForeachStatement statement) {
CodeFragmentEvaluator oldFragmentEvaluator = setNewCodeFragmentEvaluator();
try {
String iterationParameterName = statement.getIterationParameter().getName();
myCurrentFragmentEvaluator.setInitialValue(iterationParameterName, null);
SyntheticVariableEvaluator iterationParameterEvaluator = new SyntheticVariableEvaluator(myCurrentFragmentEvaluator, iterationParameterName);
SyntheticVariableEvaluator iterationParameterEvaluator =
new SyntheticVariableEvaluator(myCurrentFragmentEvaluator, iterationParameterName);
Evaluator iteratedValueEvaluator = accept(statement.getIteratedValue());
Evaluator bodyEvaluator = accept(statement.getBody());
if (bodyEvaluator != null) {
myResult = new ForeachStatementEvaluator(iterationParameterEvaluator, iteratedValueEvaluator, bodyEvaluator, getLabel(statement));
}
}
catch (EvaluateException e) {
throw new EvaluateRuntimeException(e);
} finally {
myCurrentFragmentEvaluator = oldFragmentEvaluator;
}
}
@@ -538,9 +586,6 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
catch (IncorrectOperationException e) {
LOG.error(e);
}
catch (EvaluateException e) {
throw new EvaluateRuntimeException(e);
}
PsiExpression initializer = localVariable.getInitializer();
if (initializer != null) {
@@ -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.
@@ -72,6 +72,9 @@ public class ExpressionEvaluatorImpl implements ExpressionEvaluator {
myValue = (Value)value;
return myValue;
}
catch (ReturnEvaluator.ReturnException r) {
return (Value)r.getReturnValue();
}
catch (Throwable/*IncompatibleThreadStateException*/ e) {
if (LOG.isDebugEnabled()) {
LOG.debug(e);
@@ -0,0 +1,57 @@
/*
* 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.
* 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.debugger.engine.evaluation.expression;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
import org.jetbrains.annotations.Nullable;
/**
* @author egor
*/
public class ReturnEvaluator implements Evaluator {
@Nullable private final Evaluator myReturnValueEvaluator;
public ReturnEvaluator(@Nullable Evaluator returnValueEvaluator) {
myReturnValueEvaluator = returnValueEvaluator;
}
@Override
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
Object returnValue = myReturnValueEvaluator == null ?
context.getDebugProcess().getVirtualMachineProxy().mirrorOfVoid() :
myReturnValueEvaluator.evaluate(context);
throw new ReturnException(returnValue);
}
@Override
public Modifier getModifier() {
return null;
}
public static class ReturnException extends EvaluateException {
private final Object myReturnValue;
public ReturnException(Object returnValue) {
super("Return");
myReturnValue = returnValue;
}
public Object getReturnValue() {
return myReturnValue;
}
}
}
@@ -0,0 +1,47 @@
/*
* 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.
* 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.debugger.engine.evaluation.expression;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
import com.sun.jdi.ObjectReference;
import org.jetbrains.annotations.NotNull;
/**
* @author egor
*/
public class ThrowEvaluator implements Evaluator {
@NotNull private final Evaluator myExceptionEvaluator;
public ThrowEvaluator(@NotNull Evaluator exceptionEvaluator) {
myExceptionEvaluator = exceptionEvaluator;
}
@Override
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
ObjectReference exception = (ObjectReference)myExceptionEvaluator.evaluate(context);
EvaluateException ex = new EvaluateException(
DebuggerBundle.message("evaluation.error.method.exception", exception.referenceType().name()));
ex.setTargetException(exception);
throw ex;
}
@Override
public Modifier getModifier() {
return null;
}
}
@@ -0,0 +1,73 @@
/*
* 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.
* 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.debugger.engine.evaluation.expression;
import com.intellij.debugger.engine.DebuggerUtils;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
import com.sun.jdi.ObjectReference;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author egor
*/
public class TryEvaluator implements Evaluator {
@NotNull private final Evaluator myBodyEvaluator;
private final CatchEvaluator[] myCatchBlockEvaluators;
@Nullable private final Evaluator myFinallyEvaluator;
public TryEvaluator(@NotNull Evaluator bodyEvaluator,
CatchEvaluator[] catchBlockEvaluators,
@Nullable Evaluator finallyEvaluator) {
myBodyEvaluator = bodyEvaluator;
myCatchBlockEvaluators = catchBlockEvaluators;
myFinallyEvaluator = finallyEvaluator;
}
@Override
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
Object result = context.getSuspendContext().getDebugProcess().getVirtualMachineProxy().mirrorOfVoid();
try {
result = myBodyEvaluator.evaluate(context);
} catch (EvaluateException e) {
boolean catched = false;
ObjectReference vmException = e.getExceptionFromTargetVM();
if (vmException != null) {
for (CatchEvaluator evaluator : myCatchBlockEvaluators) {
if (evaluator != null && DebuggerUtils.instanceOf(vmException.type(), evaluator.getExceptionType())) {
result = evaluator.evaluate(vmException, context);
catched = true;
break;
}
}
}
if (!catched) {
throw e;
}
} finally {
if (myFinallyEvaluator != null) {
result = myFinallyEvaluator.evaluate(context);
}
}
return result;
}
@Override
public Modifier getModifier() {
return null;
}
}
@@ -101,7 +101,7 @@ public class AnnotateMethodFix implements LocalQuickFix {
@Override
@NotNull
public String getFamilyName() {
return getName();
return InspectionsBundle.message("inspection.annotate.method.quickfix.family.name");
}
private void annotateMethod(@NotNull PsiMethod method) {
@@ -248,7 +248,7 @@ public class JavaDocReferenceInspectionBase extends BaseJavaBatchLocalInspectio
@Override
@NotNull
public String getFamilyName() {
return getName();
return "Remove tag";
}
@Override
@@ -98,6 +98,6 @@ public class AnnotateOverriddenMethodParameterFix implements LocalQuickFix {
@Override
@NotNull
public String getFamilyName() {
return getName();
return InspectionsBundle.message("annotate.overridden.methods.parameters.family.name");
}
}
@@ -42,6 +42,7 @@ import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class UncheckedWarningLocalInspectionBase extends BaseJavaBatchLocalInspectionTool {
@@ -68,8 +69,8 @@ public class UncheckedWarningLocalInspectionBase extends BaseJavaBatchLocalInspe
return uncheckedCb;
}
public static LocalQuickFix[] getChangeVariableTypeFixes(@NotNull PsiVariable parameter, PsiType itemType) {
if (itemType instanceof PsiMethodReferenceType) return LocalQuickFix.EMPTY_ARRAY;
public static LocalQuickFix[] getChangeVariableTypeFixes(@NotNull PsiVariable parameter, PsiType itemType, LocalQuickFix[] generifyFixes) {
if (itemType instanceof PsiMethodReferenceType) return generifyFixes;
final List<LocalQuickFix> result = new ArrayList<LocalQuickFix>();
LOG.assertTrue(parameter.isValid());
if (itemType != null) {
@@ -81,6 +82,10 @@ public class UncheckedWarningLocalInspectionBase extends BaseJavaBatchLocalInspe
}
}
}
if (generifyFixes.length > 0) {
Collections.addAll(result, generifyFixes);
}
return result.toArray(new LocalQuickFix[result.size()]);
}
@@ -283,7 +288,7 @@ public class UncheckedWarningLocalInspectionBase extends BaseJavaBatchLocalInspe
if (initializer == null || initializer instanceof PsiArrayInitializerExpression) return;
final PsiType initializerType = initializer.getType();
checkRawToGenericsAssignment(initializer, initializer, variable.getType(), initializerType, true,
myOnTheFly ? getChangeVariableTypeFixes(variable, initializerType) : LocalQuickFix.EMPTY_ARRAY);
myOnTheFly ? getChangeVariableTypeFixes(variable, initializerType, myGenerifyFixes) : LocalQuickFix.EMPTY_ARRAY);
}
@Override
@@ -295,7 +300,8 @@ public class UncheckedWarningLocalInspectionBase extends BaseJavaBatchLocalInspe
final PsiExpression iteratedValue = statement.getIteratedValue();
if (iteratedValue == null) return;
final PsiType itemType = JavaGenericsUtil.getCollectionItemType(iteratedValue);
checkRawToGenericsAssignment(parameter, iteratedValue, parameterType, itemType, true, myOnTheFly ? getChangeVariableTypeFixes(parameter, itemType) : LocalQuickFix.EMPTY_ARRAY);
checkRawToGenericsAssignment(parameter, iteratedValue, parameterType, itemType, true, myOnTheFly ? getChangeVariableTypeFixes(parameter, itemType,
myGenerifyFixes) : LocalQuickFix.EMPTY_ARRAY);
}
@Override
@@ -316,7 +322,7 @@ public class UncheckedWarningLocalInspectionBase extends BaseJavaBatchLocalInspe
leftVar = (PsiVariable)element;
}
}
checkRawToGenericsAssignment(rExpr, rExpr, lType, rType, true, myOnTheFly && leftVar != null ? getChangeVariableTypeFixes(leftVar, rType) : LocalQuickFix.EMPTY_ARRAY);
checkRawToGenericsAssignment(rExpr, rExpr, lType, rType, true, myOnTheFly && leftVar != null ? getChangeVariableTypeFixes(leftVar, rType, myGenerifyFixes) : LocalQuickFix.EMPTY_ARRAY);
}
@Override
@@ -31,6 +31,8 @@ import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.refactoring.introduceParameter.AbstractJavaInplaceIntroducer;
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
import org.jetbrains.annotations.NotNull;
/**
@@ -73,7 +75,9 @@ public class CreateLocalFromUsageFix extends CreateVarFromUsageFix {
final PsiFile targetFile = targetClass.getContainingFile();
PsiType[] expectedTypes = CreateFromUsageUtils.guessType(myReferenceExpression, false);
PsiType type = expectedTypes[0];
final SmartTypePointer defaultType = SmartTypePointerManager.getInstance(project).createSmartTypePointer(expectedTypes[0]);
final PsiType preferredType = TypeSelectorManagerImpl.getPreferredType(expectedTypes, expectedTypes[0]);
PsiType type = preferredType != null ? preferredType : expectedTypes[0];
String varName = myReferenceExpression.getReferenceName();
PsiExpression initializer = null;
@@ -116,7 +120,10 @@ public class CreateLocalFromUsageFix extends CreateVarFromUsageFix {
var = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(var);
if (var == null) return;
TemplateBuilderImpl builder = new TemplateBuilderImpl(var);
builder.replaceElement(var.getTypeElement(), expression);
final PsiTypeElement typeElement = var.getTypeElement();
LOG.assertTrue(typeElement != null);
builder.replaceElement(typeElement,
AbstractJavaInplaceIntroducer.createExpression(expression, typeElement.getText()));
builder.setEndVariableAfter(var.getNameIdentifier());
Template template = builder.buildTemplate();
@@ -132,6 +139,8 @@ public class CreateLocalFromUsageFix extends CreateVarFromUsageFix {
final int offset = newEditor.getCaretModel().getOffset();
final PsiLocalVariable localVariable = PsiTreeUtil.findElementOfClassAtOffset(targetFile, offset, PsiLocalVariable.class, false);
if (localVariable != null) {
TypeSelectorManagerImpl.typeSelected(localVariable.getType(), defaultType.getType());
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
@@ -46,7 +46,7 @@ public class ReplacePrimitiveWithBoxedTypeAction extends LocalQuickFixAndIntenti
@NotNull
@Override
public String getFamilyName() {
return getText();
return "Convert primitive to boxed type";
}
@Override
@@ -51,7 +51,13 @@ public class DeadHTMLComposer extends HTMLComposerImpl {
@Override
public void compose(final StringBuffer buf, RefEntity refEntity) {
genPageHeader(buf, refEntity);
compose(buf, refEntity, true);
}
public void compose(final StringBuffer buf, RefEntity refEntity, boolean toExternalHtml) {
if (toExternalHtml) {
genPageHeader(buf, refEntity);
}
if (refEntity instanceof RefElement) {
RefElementImpl refElement = (RefElementImpl)refEntity;
@@ -59,12 +65,12 @@ public class DeadHTMLComposer extends HTMLComposerImpl {
appendHeading(buf, InspectionsBundle.message("inspection.problem.synopsis"));
//noinspection HardCodedStringLiteral
buf.append("<br>");
appendAfterHeaderIndention(buf);
appendProblemSynopsis(refElement, buf);
//noinspection HardCodedStringLiteral
buf.append("<br><br>");
appendResolution(buf, refElement, DescriptorComposer.quickFixTexts(refElement, myToolPresentation));
if (toExternalHtml) {
buf.append("<br><br>");
appendResolution(buf, refElement, DescriptorComposer.quickFixTexts(refElement, myToolPresentation));
}
refElement.accept(new RefJavaVisitor() {
@Override public void visitClass(@NotNull RefClass aClass) {
appendClassInstantiations(buf, aClass);
@@ -94,6 +100,7 @@ public class DeadHTMLComposer extends HTMLComposerImpl {
}
public static void appendProblemSynopsis(final RefElement refElement, final StringBuffer buf) {
buf.append("<div class=\"problem-description\">");
refElement.accept(new RefJavaVisitor() {
@Override public void visitField(@NotNull RefField field) {
if (field.isUsedForReading() && !field.isUsedForWriting()) {
@@ -210,6 +217,7 @@ public class DeadHTMLComposer extends HTMLComposerImpl {
}
}
});
buf.append("</div>");
}
@Override
@@ -343,6 +351,7 @@ public class DeadHTMLComposer extends HTMLComposerImpl {
if (!possibleChildren.isEmpty()) {
if (appendCallees){
appendHeading(buf, InspectionsBundle.message("inspection.export.results.callees"));
buf.append("<div class=\"problem-description\">");
}
@NonNls final String ul = "<ul>";
buf.append(ul);
@@ -359,6 +368,9 @@ public class DeadHTMLComposer extends HTMLComposerImpl {
}
@NonNls final String closeUl = "</ul>";
buf.append(closeUl);
if (appendCallees) {
buf.append("</div>");
}
}
}
@@ -82,7 +82,7 @@ public class DummyEntryPointsPresentation extends UnusedDeclarationPresentation
@Override
@NotNull
public HTMLComposerImpl getComposer() {
public DeadHTMLComposer getComposer() {
return new DeadHTMLComposer(this);
}
}
@@ -15,6 +15,7 @@
*/
package com.intellij.codeInspection.deadCode;
import com.intellij.codeInsight.highlighting.HighlightManager;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInspection.*;
import com.intellij.codeInspection.ex.*;
@@ -26,11 +27,20 @@ import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.colors.EditorColors;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.profile.codeInspection.ui.SingleInspectionProfilePanel;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
@@ -38,11 +48,14 @@ import com.intellij.psi.PsiModifierListOwner;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.refactoring.safeDelete.SafeDeleteHandler;
import com.intellij.ui.HyperlinkAdapter;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.HashMap;
import com.intellij.util.containers.HashSet;
import com.intellij.util.text.CharArrayUtil;
import com.intellij.util.text.DateFormatUtil;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
@@ -50,8 +63,17 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.text.AttributeSet;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.html.HTML;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.net.URL;
import java.util.*;
public class UnusedDeclarationPresentation extends DefaultInspectionToolPresentation {
@@ -100,7 +122,7 @@ public class UnusedDeclarationPresentation extends DefaultInspectionToolPresenta
@Override
@NotNull
public HTMLComposerImpl getComposer() {
public DeadHTMLComposer getComposer() {
if (myComposer == null) {
myComposer = new DeadHTMLComposer(this);
}
@@ -523,13 +545,64 @@ public class UnusedDeclarationPresentation extends DefaultInspectionToolPresenta
@Override
public JComponent getCustomPreviewPanel(RefEntity entity) {
JEditorPane htmlView = new JEditorPane();
final Project project = entity.getRefManager().getProject();
JEditorPane htmlView = new JEditorPane() {
@Override
public String getToolTipText(MouseEvent evt) {
int pos = viewToModel(evt.getPoint());
if (pos >= 0) {
HTMLDocument hdoc = (HTMLDocument) getDocument();
javax.swing.text.Element e = hdoc.getCharacterElement(pos);
AttributeSet a = e.getAttributes();
SimpleAttributeSet value = (SimpleAttributeSet) a.getAttribute(HTML.Tag.A);
if (value != null) {
String objectPackage = (String) value.getAttribute("qualifiedname");
if (objectPackage != null) {
return objectPackage;
}
}
}
return null;
}
};
htmlView.setContentType(UIUtil.HTML_MIME);
htmlView.setEditable(false);
htmlView.setOpaque(false);
htmlView.addHyperlinkListener(new HyperlinkAdapter() {
@Override
protected void hyperlinkActivated(HyperlinkEvent e) {
URL url = e.getURL();
if (url == null) {
return;
}
@NonNls String ref = url.getRef();
int offset = Integer.parseInt(ref);
String fileURL = url.toExternalForm();
fileURL = fileURL.substring(0, fileURL.indexOf('#'));
VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(fileURL);
if (vFile == null) {
vFile = VfsUtil.findFileByURL(url);
}
if (vFile != null) {
final OpenFileDescriptor descriptor = new OpenFileDescriptor(project, vFile, offset);
FileEditorManager.getInstance(project).openTextEditor(descriptor, true);
}
}
});
final StyleSheet css = ((HTMLEditorKit)htmlView.getEditorKit()).getStyleSheet();
css.addRule("p.problem-description-group {text-indent: " + JBUI.scale(12) + "px;font-weight:bold;}");
css.addRule("div.problem-description {margin-left: " + JBUI.scale(10) + "px;}");
css.addRule("ul {margin-left:" + JBUI.scale(10) + "px;text-indent: 0}");
//TODO Dmitry Batkovich: it's hack to hide tags in JEditorPane (any standard methods (display...) are unsupported in java)
final StringBuilder sb = new StringBuilder();
UIUtil.appendColor(UIUtil.getLabelBackground(), sb);
css.addRule(".package {color: #" + sb.toString() + ";}");
final StringBuffer buf = new StringBuffer();
getComposer().compose(buf, entity);
htmlView.setText(buf.toString());
return htmlView;
getComposer().compose(buf, entity, false);
final String text = buf.toString();
SingleInspectionProfilePanel.readHTML(htmlView, SingleInspectionProfilePanel.toHTML(htmlView, text, false));
return ScrollPaneFactory.createScrollPane(htmlView, true);
}
}
@@ -273,6 +273,7 @@ public class HTMLJavaHTMLComposerImpl extends HTMLJavaHTMLComposer {
public void appendReferencePresentation(RefEntity refElement, final StringBuffer buf, final boolean isPackageIncluded) {
if (refElement instanceof RefImplicitConstructor) {
buf.append(InspectionsBundle.message("inspection.export.results.implicit.constructor"));
buf.append("&nbsp;");
refElement = ((RefImplicitConstructor)refElement).getOwnerClass();
}
@@ -304,7 +305,15 @@ public class HTMLJavaHTMLComposerImpl extends HTMLJavaHTMLComposer {
buf.append(myComposer.myExporter.getURL(refElement));
}
buf.append("\">");
buf.append("\"");
if (isPackageIncluded) {
buf.append(" qualifiedname=\"");
buf.append(refElement.getQualifiedName());
buf.append("\"");
}
buf.append(">");
if (refElement instanceof RefClass && ((RefClass)refElement).isAnonymous()) {
buf.append(InspectionsBundle.message("inspection.reference.anonymous"));
@@ -336,7 +345,7 @@ public class HTMLJavaHTMLComposerImpl extends HTMLJavaHTMLComposer {
myComposer.appendElementReference(buf, ((RefElement)refElement.getOwner()), isPackageIncluded);
}
else if (isPackageIncluded) {
buf.append(" ").append(HTMLComposerImpl.CODE_OPENING).append("(");
buf.append(" ").append("<code class=\"package\">").append("(");
myComposer.appendQualifiedName(buf, refElement.getOwner());
// buf.append(RefUtil.getPackageName(refElement));
buf.append(")").append(HTMLComposerImpl.CODE_CLOSING);
@@ -2,6 +2,7 @@ package com.intellij.refactoring.introduceParameter;
import com.intellij.codeInsight.intention.impl.TypeExpression;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.PsiTypeLookupItem;
import com.intellij.codeInsight.template.Expression;
import com.intellij.codeInsight.template.ExpressionContext;
import com.intellij.codeInsight.template.Result;
@@ -200,7 +201,23 @@ public abstract class AbstractJavaInplaceIntroducer extends AbstractInplaceIntro
@Override
public LookupElement[] calculateLookupItems(ExpressionContext context) {
return expression.calculateLookupItems(context);
final LookupElement[] elements = expression.calculateLookupItems(context);
if (elements != null) {
LookupElement toBeSelected = null;
for (LookupElement element : elements) {
if (element instanceof PsiTypeLookupItem && ((PsiTypeLookupItem)element).getType().getPresentableText().equals(defaultType)) {
toBeSelected = element;
break;
}
}
if (toBeSelected != null) {
final int idx = ArrayUtil.find(elements, toBeSelected);
if (idx > 0) {
return ArrayUtil.prepend(toBeSelected, ArrayUtil.remove(elements, idx));
}
}
}
return elements;
}
@Override
@@ -17,6 +17,7 @@ package com.intellij.refactoring.typeCook;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiDiamondTypeUtil;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiUtil;
import com.intellij.refactoring.typeCook.deductive.PsiTypeVariableFactory;
@@ -405,6 +406,10 @@ public class Util {
list
.add(factory.createTypeElement(aType == null ? PsiType.getJavaLangObject(list.getManager(), list.getResolveScope()) : aType));
}
if (PsiDiamondTypeUtil.canCollapseToDiamond(newx, newx, newx.getType())) {
PsiDiamondTypeUtil.replaceExplicitWithDiamond(list);
}
}
}
else {
@@ -312,18 +312,25 @@ public class TypeSelectorManagerImpl implements TypeSelectorManager {
private void setTypesAndPreselect(PsiType[] types) {
myTypeSelector.setTypes(types);
final PsiType preferredType = getPreferredType(types, getDefaultType());
if (preferredType != null) {
myTypeSelector.selectType(preferredType);
}
}
public static PsiType getPreferredType(PsiType[] types, PsiType defaultType) {
Map<String, PsiType> map = new THashMap<String, PsiType>();
for (final PsiType type : types) {
map.put(serialize(type), type);
}
for (StatisticsInfo info : StatisticsManager.getInstance().getAllValues(getStatsKey())) {
for (StatisticsInfo info : StatisticsManager.getInstance().getAllValues(getStatsKey(defaultType))) {
final PsiType candidate = map.get(info.getValue());
if (candidate != null && StatisticsManager.getInstance().getUseCount(info) > 0) {
myTypeSelector.selectType(candidate);
return;
return candidate;
}
}
return null;
}
@Override
@@ -353,15 +360,10 @@ public class TypeSelectorManagerImpl implements TypeSelectorManager {
StatisticsManager.getInstance().incUseCount(new StatisticsInfo(getStatsKey(defaultType), serialize(type)));
}
private String getStatsKey() {
final PsiType defaultType = getDefaultType();
private static String getStatsKey(final PsiType defaultType) {
if (defaultType == null) {
return "IntroduceVariable##";
}
return getStatsKey(defaultType);
}
private static String getStatsKey(final PsiType defaultType) {
return "IntroduceVariable##" + serialize(defaultType);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 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.
@@ -16,7 +16,6 @@
package com.intellij.psi.search.searches;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.util.Condition;
import com.intellij.psi.PsiAnonymousClass;
import com.intellij.psi.PsiClass;
import com.intellij.psi.search.GlobalSearchScope;
@@ -25,6 +24,7 @@ import com.intellij.psi.util.PsiUtilCore;
import com.intellij.util.FilteredQuery;
import com.intellij.util.Query;
import com.intellij.util.QueryExecutor;
import org.jetbrains.annotations.NotNull;
/**
* @author max
@@ -34,30 +34,32 @@ public class DirectClassInheritorsSearch extends ExtensibleQueryFactory<PsiClass
public static final DirectClassInheritorsSearch INSTANCE = new DirectClassInheritorsSearch();
public static class SearchParameters {
private final PsiClass myClass;
private final SearchScope myScope;
@NotNull private final PsiClass myClass;
@NotNull private final SearchScope myScope;
private final boolean myIncludeAnonymous;
private final boolean myCheckInheritance;
public SearchParameters(PsiClass aClass, SearchScope scope, boolean includeAnonymous, boolean checkInheritance) {
public SearchParameters(@NotNull PsiClass aClass, @NotNull SearchScope scope, boolean includeAnonymous, boolean checkInheritance) {
myClass = aClass;
myScope = scope;
myIncludeAnonymous = includeAnonymous;
myCheckInheritance = checkInheritance;
}
public SearchParameters(final PsiClass aClass, SearchScope scope, final boolean includeAnonymous) {
public SearchParameters(@NotNull PsiClass aClass, @NotNull SearchScope scope, final boolean includeAnonymous) {
this(aClass, scope, includeAnonymous, true);
}
public SearchParameters(final PsiClass aClass, final SearchScope scope) {
public SearchParameters(@NotNull PsiClass aClass, @NotNull SearchScope scope) {
this(aClass, scope, true);
}
@NotNull
public PsiClass getClassToProcess() {
return myClass;
}
@NotNull
public SearchScope getScope() {
return myScope;
}
@@ -92,12 +94,7 @@ public class DirectClassInheritorsSearch extends ExtensibleQueryFactory<PsiClass
final Query<PsiClass> raw = INSTANCE.createUniqueResultsQuery(new SearchParameters(aClass, scope, includeAnonymous, checkInheritance));
if (!includeAnonymous) {
return new FilteredQuery<PsiClass>(raw, new Condition<PsiClass>() {
@Override
public boolean value(final PsiClass psiClass) {
return !(psiClass instanceof PsiAnonymousClass);
}
});
return new FilteredQuery<>(raw, psiClass -> !(psiClass instanceof PsiAnonymousClass));
}
return raw;
@@ -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.
@@ -37,6 +37,7 @@ import com.intellij.util.QueryExecutor;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collection;
@@ -51,87 +52,46 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
public boolean execute(@NotNull final DirectClassInheritorsSearch.SearchParameters p, @NotNull final Processor<PsiClass> consumer) {
final PsiClass aClass = p.getClassToProcess();
final SearchScope useScope = ApplicationManager.getApplication().runReadAction(new Computable<SearchScope>() {
@Override
public SearchScope compute() {
return aClass.getUseScope();
}
});
final SearchScope useScope = ApplicationManager.getApplication().runReadAction((Computable<SearchScope>)aClass::getUseScope);
final String qualifiedName = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
public String compute() {
return aClass.getQualifiedName();
}
});
final String qualifiedName = ApplicationManager.getApplication().runReadAction((Computable<String>)aClass::getQualifiedName);
final Project project = PsiUtilCore.getProjectInReadAction(aClass);
if (CommonClassNames.JAVA_LANG_OBJECT.equals(qualifiedName)) {
//[pasynkov]: WTF?
//final SearchScope scope = useScope.intersectWith(GlobalSearchScope.notScope(GlobalSearchScope.getScopeRestrictedByFileTypes(
// GlobalSearchScope.allScope(psiManager.getProject()), StdFileTypes.JSP, StdFileTypes.JSPX)));
return AllClassesSearch.search(useScope, project).forEach(new Processor<PsiClass>() {
@Override
public boolean process(final PsiClass psiClass) {
ProgressManager.checkCanceled();
if (psiClass.isInterface()) {
return consumer.process(psiClass);
}
final PsiClass superClass = psiClass.getSuperClass();
if (superClass != null && CommonClassNames.JAVA_LANG_OBJECT.equals(ApplicationManager.getApplication().runReadAction(new Computable<String>() {
public String compute() {
return superClass.getQualifiedName();
}
}))) {
return consumer.process(psiClass);
}
return true;
return AllClassesSearch.search(useScope, project).forEach(psiClass -> {
ProgressManager.checkCanceled();
if (psiClass.isInterface()) {
return consumer.process(psiClass);
}
final PsiClass superClass = psiClass.getSuperClass();
if (superClass != null &&
CommonClassNames.JAVA_LANG_OBJECT.equals(ApplicationManager.getApplication().runReadAction((Computable<String>)superClass::getQualifiedName))) {
return consumer.process(psiClass);
}
return true;
});
}
final GlobalSearchScope scope = useScope instanceof GlobalSearchScope ? (GlobalSearchScope)useScope : new EverythingGlobalScope(project);
final String searchKey = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
public String compute() {
return aClass.getName();
}
});
final String searchKey = ApplicationManager.getApplication().runReadAction((Computable<String>)aClass::getName);
if (StringUtil.isEmpty(searchKey)) {
return true;
}
Collection<PsiReferenceList> candidates = MethodUsagesSearcher.resolveInReadAction(project,
new Computable<Collection<PsiReferenceList>>() {
@Override
public Collection<PsiReferenceList> compute() {
return JavaSuperClassNameOccurenceIndex
.getInstance().get(searchKey, project, scope);
}
});
Collection<PsiReferenceList> candidates =
MethodUsagesSearcher.resolveInReadAction(project, () -> JavaSuperClassNameOccurenceIndex.getInstance().get(searchKey, project, scope));
Map<String, List<PsiClass>> classes = new HashMap<String, List<PsiClass>>();
Map<String, List<PsiClass>> classes = new HashMap<>();
for (final PsiReferenceList referenceList : candidates) {
ProgressManager.checkCanceled();
final PsiClass candidate = (PsiClass)ApplicationManager.getApplication().runReadAction(new Computable<PsiElement>() {
@Override
public PsiElement compute() {
return referenceList.getParent();
}
});
final PsiClass candidate = (PsiClass)ApplicationManager.getApplication().runReadAction((Computable<PsiElement>)referenceList::getParent);
if (!checkInheritance(p, aClass, candidate, project)) continue;
String fqn = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
public String compute() {
return candidate.getQualifiedName();
}
});
String fqn = ApplicationManager.getApplication().runReadAction((Computable<String>)candidate::getQualifiedName);
List<PsiClass> list = classes.get(fqn);
if (list == null) {
list = new ArrayList<PsiClass>();
list = new ArrayList<>();
classes.put(fqn, list);
}
list.add(candidate);
@@ -141,20 +101,13 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
final VirtualFile jarFile = getJarFile(aClass);
for (List<PsiClass> sameNamedClasses : classes.values()) {
ProgressManager.checkCanceled();
if (!processSameNamedClasses(consumer, sameNamedClasses, jarFile)) return false;
if (!processSameNamedClasses(sameNamedClasses, jarFile, consumer)) return false;
}
}
if (p.includeAnonymous()) {
Collection<PsiAnonymousClass> anonymousCandidates = MethodUsagesSearcher.resolveInReadAction(project,
new Computable<Collection<PsiAnonymousClass>>() {
@Override
public Collection<PsiAnonymousClass> compute() {
return JavaAnonymousClassBaseRefOccurenceIndex
.getInstance()
.get(searchKey, project, scope);
}
});
Collection<PsiAnonymousClass> anonymousCandidates =
MethodUsagesSearcher.resolveInReadAction(project, () -> JavaAnonymousClassBaseRefOccurenceIndex.getInstance().get(searchKey, project, scope));
for (PsiAnonymousClass candidate : anonymousCandidates) {
ProgressManager.checkCanceled();
@@ -163,30 +116,15 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
if (!consumer.process(candidate)) return false;
}
boolean isEnum = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
return aClass.isEnum();
}
});
boolean isEnum = ApplicationManager.getApplication().runReadAction((Computable<Boolean>)aClass::isEnum);
if (isEnum) {
// abstract enum can be subclassed in the body
PsiField[] fields = ApplicationManager.getApplication().runReadAction(new Computable<PsiField[]>() {
@Override
public PsiField[] compute() {
return aClass.getFields();
}
});
PsiField[] fields = ApplicationManager.getApplication().runReadAction((Computable<PsiField[]>)aClass::getFields);
for (final PsiField field : fields) {
ProgressManager.checkCanceled();
if (field instanceof PsiEnumConstant) {
PsiEnumConstantInitializer initializingClass =
ApplicationManager.getApplication().runReadAction(new Computable<PsiEnumConstantInitializer>() {
@Override
public PsiEnumConstantInitializer compute() {
return ((PsiEnumConstant)field).getInitializingClass();
}
});
ApplicationManager.getApplication().runReadAction((Computable<PsiEnumConstantInitializer>)((PsiEnumConstant)field)::getInitializingClass);
if (initializingClass != null) {
if (!consumer.process(initializingClass)) return false;
}
@@ -198,16 +136,16 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
return true;
}
private static boolean checkInheritance(final DirectClassInheritorsSearch.SearchParameters p, final PsiClass aClass, final PsiClass candidate, Project project) {
return MethodUsagesSearcher.resolveInReadAction(project, new Computable<Boolean>() {
@Override
public Boolean compute() {
return !p.isCheckInheritance() || candidate.isInheritor(aClass, false);
}
});
private static boolean checkInheritance(@NotNull DirectClassInheritorsSearch.SearchParameters p,
@NotNull PsiClass aClass,
@NotNull PsiClass candidate,
@NotNull Project project) {
return MethodUsagesSearcher.resolveInReadAction(project, () -> !p.isCheckInheritance() || candidate.isInheritor(aClass, false));
}
private static boolean processSameNamedClasses(Processor<PsiClass> consumer, List<PsiClass> sameNamedClasses, final VirtualFile jarFile) {
private static boolean processSameNamedClasses(@NotNull List<PsiClass> sameNamedClasses,
@Nullable VirtualFile jarFile,
@NotNull Processor<PsiClass> consumer) {
// if there is a class from the same jar, prefer it
boolean sameJarClassFound = false;
@@ -225,12 +163,7 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
return sameJarClassFound || ContainerUtil.process(sameNamedClasses, consumer);
}
private static VirtualFile getJarFile(final PsiClass aClass) {
return ApplicationManager.getApplication().runReadAction(new Computable<VirtualFile>() {
@Override
public VirtualFile compute() {
return PsiUtil.getJarFile(aClass);
}
});
private static VirtualFile getJarFile(@NotNull PsiClass aClass) {
return ApplicationManager.getApplication().runReadAction((Computable<VirtualFile>)() -> PsiUtil.getJarFile(aClass));
}
}
@@ -41,8 +41,11 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm
@Override
public boolean reduce(InferenceSession session, List<ConstraintFormula> constraints) {
if (!PsiPolyExpressionUtil.isPolyExpression(myExpression)) {
PsiType exprType = myExpression.getType();
if (session.isProperType(myT)) {
final boolean assignmentCompatible = TypeConversionUtil.areTypesAssignmentCompatible(myT, myExpression);
final boolean assignmentCompatible = TypeConversionUtil.isAssignable(myT, exprType);
if (!assignmentCompatible) {
final PsiType type = myExpression.getType();
session.registerIncompatibleErrorMessage((type != null ? type.getPresentableText() : myExpression.getText()) + " is not compatible with " + session.getPresentableText(myT));
@@ -50,8 +53,6 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm
return assignmentCompatible;
}
PsiType exprType = myExpression.getType();
if (exprType instanceof PsiLambdaParameterType) {
return false;
}
@@ -214,7 +214,7 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
PsiParameter parameter = lambdaParameters[lambdaParamIdx];
final PsiTypeElement typeElement = parameter.getTypeElement();
if (typeElement != null) {
final PsiType lambdaFormalType = toArray(typeElement.getType());
final PsiType lambdaFormalType = toArray(parameter.getType());
final PsiType methodParameterType = toArray(parameterTypes[lambdaParamIdx]);
if (!lambdaFormalType.equals(methodParameterType)) {
return false;
@@ -0,0 +1,8 @@
class Test {
{
pair<error descr="'pair(byte)' in 'Test' cannot be applied to '(int)'">(2)</error>;
}
static <T> void pair( byte b) {}
}
@@ -0,0 +1,10 @@
interface X {
void foo(int[] x);
}
class C {
static void main(String[] args){
X a = (int x[]) -> { };
}
}
@@ -0,0 +1,28 @@
import java.util.*;
class X<A extends Comparable<A>, B extends Comparable<B>> {
class Pair implements Comparable<Pair> {
A a;
B b;
public A getA() {
return a;
}
public B getB() {
return b;
}
@Override
public int compareTo(Pair other) {
Comparator<Pair> comparator = Comparator.comparing(Pair::getA).thenComparing(Pair::getB);
return comparator.compare(this, other);
}
}
}
@@ -0,0 +1,7 @@
// "Try to generify 'before2.java'" "true"
import java.util.ArrayList;
class Use {
void f() {
ArrayList<String> s = new ArrayLi<caret>st();
}
}
@@ -0,0 +1 @@
java.util.ArrayList<java.lang.String>\nnew
@@ -0,0 +1 @@
java.util.ArrayList\nnew
@@ -0,0 +1,6 @@
import java.util.ArrayList;
class Test
{
ArrayList<String> l = new ArrayList<>();
}
@@ -0,0 +1,6 @@
import java.util.ArrayList;
class Test
{
ArrayList<String> l = new ArrayList();
}
@@ -978,4 +978,8 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
public void testIDEA152179() throws Exception {
doTest();
}
public void testLooseInvocationContextForProperPrimitiveTypes() throws Exception {
doTest();
}
}
@@ -276,6 +276,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testCLikeArrayDeclarationInLambdaWithExplicitTypes() throws Exception {
doTest();
}
private void doTest() {
doTest(false);
}
@@ -498,6 +498,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testIDEA152659() throws Exception {
doTest();
}
private void doTest() {
doTest(false);
}
@@ -17,9 +17,11 @@ package com.intellij.refactoring;
import com.intellij.JavaTestUtil;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.PsiClass;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.refactoring.typeCook.Settings;
@@ -667,6 +669,18 @@ public class TypeCookTest extends MultiFileTestCase {
start();
}
public void testConvertToDiamond() throws Exception {
final LanguageLevelProjectExtension levelProjectExtension = LanguageLevelProjectExtension.getInstance(getProject());
final LanguageLevel oldLevel = levelProjectExtension.getLanguageLevel();
try {
levelProjectExtension.setLanguageLevel(LanguageLevel.JDK_1_8);
start();
}
finally {
levelProjectExtension.setLanguageLevel(oldLevel);
}
}
public void start() throws Exception {
start(false);
}
@@ -39,10 +39,9 @@ public abstract class HTMLComposer {
public abstract void appendListItem(StringBuffer buf, RefElement refElement);
public static void appendHeading(@NonNls StringBuffer buf, String name){
buf.append("&nbsp;&nbsp;<font style=\"font-weight:bold; color:")
.append(UIUtil.isUnderDarcula() ? "#A5C25C" : "#005555").append(";\">")
.append(name)
.append("</font>");
buf.append("<p class=\"problem-description-group\">")
.append(name)
.append("</p>");
}
public abstract void appendElementReference(StringBuffer buf, RefElement refElement, boolean isPackageIncluded);
@@ -55,6 +54,10 @@ public abstract class HTMLComposer {
public abstract void startListItem(@NonNls StringBuffer buf);
/**
* Use css for indentations
*/
@Deprecated
public static void appendAfterHeaderIndention(@NonNls StringBuffer buf) {
buf.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
}
@@ -322,6 +322,9 @@ public abstract class HTMLComposerImpl extends HTMLComposer {
@Override
public void startList(@NonNls final StringBuffer buf) {
if (myListStackTop == -1) {
buf.append("<div class=\"problem-description\">");
}
buf.append("<ul>");
myListStackTop++;
myListStack[myListStackTop] = 0;
@@ -333,6 +336,9 @@ public abstract class HTMLComposerImpl extends HTMLComposer {
if (myListStack[myListStackTop] != 0) {
buf.append("<table cellpadding=\"0\" border=\"0\" cellspacing=\"0\"><tr><td>&nbsp;</td></tr></table>");
}
if (myListStackTop == 0) {
buf.append("</div>");
}
myListStackTop--;
}
@@ -348,11 +354,9 @@ public abstract class HTMLComposerImpl extends HTMLComposer {
@Override
public void appendNoProblems(StringBuffer buf) {
buf.append(BR);
appendAfterHeaderIndention(buf);
buf.append(B_OPENING);
buf.append("<p class=\"problem-description-group\">");;
buf.append(InspectionsBundle.message("inspection.export.results.no.problems.found"));
buf.append(B_CLOSING).append(BR);
buf.append("</p>");
}
@Override
@@ -59,7 +59,11 @@ public class HTMLExporter {
public void createPage(RefEntity element) throws IOException {
final String currentFileName = fileNameForElement(element);
StringBuffer buf = new StringBuffer("<html><body>");
StringBuffer buf = new StringBuffer("<html>" +
"<head>\n" +
"<link rel=\"stylesheet\" type=\"text/css\" href=\"../inspection-report-style.css\">\n" +
"</head>" +
"<body>");
appendNavBar(buf, element);
myComposer.composeWithExporter(buf, element, this);
buf.append("</body></html>");
+2 -2
View File
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module relativePaths="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="true">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="jdk" jdkName="IDEA jdk" jdkType="JavaSDK" />
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
</component>
<component name="copyright">
<Base>
@@ -0,0 +1,59 @@
/*
* 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.
* 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.concurrency;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinWorkerThread;
import java.util.concurrent.atomic.AtomicLong;
// must be accessible via "ClassLoader.getSystemClassLoader().loadClass(fp).newInstance()" from java.util.concurrent.ForkJoinPool.makeCommonPool()
public class IdeaForkJoinWorkerThreadFactory implements ForkJoinPool.ForkJoinWorkerThreadFactory {
private static final int PARALLELISM = Runtime.getRuntime().availableProcessors();
// must be called in the earliest possible moment on startup
public static void setupForkJoinCommonPool() {
System.setProperty("java.util.concurrent.ForkJoinPool.common.parallelism", String.valueOf(PARALLELISM));
System.setProperty("java.util.concurrent.ForkJoinPool.common.threadFactory", IdeaForkJoinWorkerThreadFactory.class.getName());
if (!ForkJoinPool.commonPool().getFactory().getClass().getName().equals(IdeaForkJoinWorkerThreadFactory.class.getName())) {
throw new IllegalStateException("Could not set ForkJoinPool thread factory: got "+ForkJoinPool.commonPool().getFactory());
}
}
private static final AtomicLong bits = new AtomicLong();
@Override
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
final int n = setNextBit();
ForkJoinWorkerThread thread = new ForkJoinWorkerThread(pool) {
@Override
protected void onTermination(Throwable exception) {
clearBit(n);
super.onTermination(exception);
}
};
thread.setName("JobScheduler FJ pool " + n + "/" + PARALLELISM);
return thread;
}
private static int setNextBit() {
long oldValue = bits.getAndUpdate(value -> value + 1 | value);
return Long.numberOfTrailingZeros(oldValue + 1);
}
private static void clearBit(int n) {
bits.updateAndGet(value -> value & ~(1L << n));
}
}
@@ -32,13 +32,13 @@ public class StringLiteralLexer extends LexerBase {
public static final char NO_QUOTE_CHAR = (char)-1;
private CharSequence myBuffer;
private int myStart;
private int myEnd;
protected CharSequence myBuffer;
protected int myStart;
protected int myEnd;
private int myState;
private int myLastState;
private int myBufferEnd;
private final char myQuoteChar;
protected int myBufferEnd;
protected final char myQuoteChar;
private final IElementType myOriginalLiteralToken;
private final boolean myCanEscapeEolOrFramingSpaces;
private final String myAdditionalValidEscapes;
@@ -114,10 +114,7 @@ public class StringLiteralLexer extends LexerBase {
return StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN;
}
if (nextChar == 'u') {
for(int i = myStart + 2; i < myStart + 6; i++) {
if (i >= myEnd || !StringUtil.isHexDigit(myBuffer.charAt(i))) return StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN;
}
return StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN;
return getUnicodeEscapeSequenceType();
}
if (nextChar == 'x' && myAllowHex) {
@@ -155,6 +152,14 @@ public class StringLiteralLexer extends LexerBase {
return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN;
}
@NotNull
protected IElementType getUnicodeEscapeSequenceType() {
for (int i = myStart + 2; i < myStart + 6; i++) {
if (i >= myEnd || !StringUtil.isHexDigit(myBuffer.charAt(i))) return StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN;
}
return StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN;
}
// all subsequent chars are escaped spaces
private boolean isTrailingSpace(final int start) {
for (int i=start;i<myBufferEnd;i+=2) {
@@ -213,13 +218,7 @@ public class StringLiteralLexer extends LexerBase {
}
if (myBuffer.charAt(i) == 'u') {
i++;
for (; i < start + 6; i++) {
if (i == myBufferEnd || myBuffer.charAt(i) == '\n' || myBuffer.charAt(i) == myQuoteChar) {
return i;
}
}
return i;
return locateUnicodeEscapeSequence(start, i);
}
else {
return i + 1;
@@ -241,6 +240,16 @@ public class StringLiteralLexer extends LexerBase {
return i;
}
protected int locateUnicodeEscapeSequence(int start, int i) {
i++;
for (; i < start + 6; i++) {
if (i == myBufferEnd || myBuffer.charAt(i) == '\n' || myBuffer.charAt(i) == myQuoteChar) {
return i;
}
}
return i;
}
@Override
public void advance() {
myLastState = myState;
@@ -17,6 +17,8 @@ package com.intellij.openapi.application;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Ref;
import org.jetbrains.annotations.NotNull;
/**
@@ -96,14 +98,27 @@ public abstract class TransactionGuard {
}
/**
* Schedules a transaction and waits for it to be completed. Only allowed to be invoked on non-UI thread and outside read action.
* Schedules a transaction and waits for it to be completed. Fails if invoked on UI thread inside an incompatible transaction,
* or inside a read action on non-UI thread.
* @see #submitMergeableTransaction(TransactionKind, Runnable)
* @param kind
* @param transaction
* @throws ProcessCanceledException if current thread is interrupted
*/
public abstract void submitTransactionAndWait(@NotNull TransactionKind kind, @NotNull Runnable transaction) throws ProcessCanceledException;
/**
* Same as {@link #submitTransactionAndWait(TransactionKind, Runnable)}, but returns a value computed by the transaction.
*/
public <T> T submitTransactionAndWait(@NotNull TransactionKind kind, @NotNull final Computable<T> transaction) throws ProcessCanceledException {
final Ref<T> result = Ref.create();
submitTransactionAndWait(kind, new Runnable() {
@Override
public void run() {
result.set(transaction.compute());
}
});
return result.get();
}
/**
* A synchronous version of {@link #submitMergeableTransaction(TransactionKind, Runnable)}.
* @return a token object for this transaction. Call {@link AccessToken#finish()} (inside finally) when the transaction is complete.
@@ -76,7 +76,7 @@ public class PsiCacheKey<T, H extends PsiElement> extends Key<SoftReference<Pair
*/
private long getModificationCount(@NotNull PsiElement element) {
PsiFile file = element.getContainingFile();
long fileStamp = file == null ? 0 : file.getModificationStamp();
long fileStamp = file == null || file.isPhysical() ? 0 : file.getModificationStamp();
PsiModificationTracker tracker = file == null ? element.getManager().getModificationTracker()
: file.getManager().getModificationTracker();
@@ -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.
@@ -48,7 +48,6 @@ public class TransactionGuardImpl extends TransactionGuard {
// please assign exceptions that occur here to Peter
LOG.error("Nested transactions are not allowed, see FAQ in TransactionGuard class javadoc. Transaction start trace is in attachment. Kind is " + kind,
new Attachment("trace.txt", myTransactionStartTrace));
//throw new IllegalStateException("Nested transactions are not allowed");
}
myTransactionStartTrace = DebugUtil.currentStackTrace();
return new AccessToken() {
@@ -99,7 +98,7 @@ public class TransactionGuardImpl extends TransactionGuard {
Runnable runnable = new Runnable() {
@Override
public void run() {
if (!isInsideTransaction() || kind != TransactionKind.NO_MERGE && myMergeableKinds.contains(kind)) {
if (canRunTransactionNow(kind)) {
runSyncTransaction(kind, transaction);
}
else {
@@ -118,6 +117,10 @@ public class TransactionGuardImpl extends TransactionGuard {
}
}
protected boolean canRunTransactionNow(@NotNull TransactionKind kind) {
return !isInsideTransaction() || kind != TransactionKind.NO_MERGE && myMergeableKinds.contains(kind);
}
@Override
@NotNull
public AccessToken acceptNestedTransactions(TransactionKind... kinds) {
@@ -144,9 +147,15 @@ public class TransactionGuardImpl extends TransactionGuard {
@Override
public void submitTransactionAndWait(@NotNull TransactionKind kind, @NotNull final Runnable transaction) throws ProcessCanceledException {
Application app = ApplicationManager.getApplication();
assert !app.isDispatchThread() : "submitTransactionAndWait should not be invoked on dispatch thread";
assert !app.isReadAccessAllowed() : "submitTransactionAndWait should not be invoked from a read action";
if (app.isDispatchThread()) {
if (!canRunTransactionNow(kind)) {
throw new AssertionError("Cannot run submitTransactionAndWait from another transaction, kind " + kind + " is not allowed");
}
runSyncTransaction(kind, transaction);
return;
}
assert !app.isReadAccessAllowed() : "submitTransactionAndWait should not be invoked from a read action";
final Semaphore semaphore = new Semaphore();
semaphore.down();
final Throwable[] exception = {null};
@@ -16,6 +16,7 @@
package com.intellij.diff.util;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.util.BackgroundTaskUtil;
import com.intellij.util.Function;
import org.jetbrains.annotations.CalledInAwt;
import org.jetbrains.annotations.NotNull;
@@ -486,15 +486,15 @@ public class PushController implements Disposable {
public void run(@NotNull ProgressIndicator indicator) {
myPushSettings.saveExcludedRepoRoots(myExcludedRepositoryRoots);
for (PushSupport support : myPushSupports) {
doPush(support, force);
doPushSynchronously(support, force);
}
}
};
task.queue();
}
private <R extends Repository, S extends PushSource, T extends PushTarget> void doPush(@NotNull PushSupport<R, S, T> support,
boolean force) {
private <R extends Repository, S extends PushSource, T extends PushTarget> void doPushSynchronously(@NotNull PushSupport<R, S, T> support,
boolean force) {
VcsPushOptionValue options = myDialog.getAdditionalOptionValue(support);
Pusher<R, S, T> pusher = support.getPusher();
Map<R, PushSpec<S, T>> specs = collectPushSpecsForVcs(support);
@@ -23,11 +23,14 @@ import com.intellij.codeInsight.lookup.Lookup;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.codeInsight.lookup.impl.LookupImpl;
import com.intellij.codeInsight.template.impl.*;
import com.intellij.codeInsight.template.impl.editorActions.ExpandLiveTemplateCustomAction;
import com.intellij.featureStatistics.FeatureUsageTracker;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.intellij.util.containers.ContainerUtil;
@@ -55,7 +58,16 @@ public abstract class ChooseItemAction extends EditorAction {
if (lookup == null) {
throw new AssertionError("The last lookup disposed at: " + LookupImpl.getLastLookupDisposeTrace() + "\n-----------------------\n");
}
if ((finishingChar == Lookup.NORMAL_SELECT_CHAR || finishingChar == Lookup.REPLACE_SELECT_CHAR) &&
hasTemplatePrefix(lookup, finishingChar)) {
lookup.hideLookup(true);
ExpandLiveTemplateCustomAction.createExpandTemplateHandler(finishingChar).execute(editor, null, dataContext);
return;
}
if (finishingChar == Lookup.NORMAL_SELECT_CHAR) {
if (!lookup.isFocused()) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_CONTROL_ENTER);
@@ -78,10 +90,6 @@ public abstract class ChooseItemAction extends EditorAction {
if (lookup == null) return false;
if (!lookup.isAvailableToUser()) return false;
if (focusedOnly && lookup.getFocusDegree() == LookupImpl.FocusDegree.UNFOCUSED) return false;
if (finishingChar == Lookup.NORMAL_SELECT_CHAR && hasTemplatePrefix(lookup, TemplateSettings.ENTER_CHAR) ||
finishingChar == Lookup.REPLACE_SELECT_CHAR && hasTemplatePrefix(lookup, TemplateSettings.TAB_CHAR)) {
return false;
}
if (finishingChar == Lookup.REPLACE_SELECT_CHAR) {
return !lookup.getItems().isEmpty();
}
@@ -23,7 +23,6 @@ import com.intellij.lang.Language;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.event.EditorFactoryAdapter;
import com.intellij.openapi.editor.event.EditorFactoryEvent;
@@ -33,11 +32,15 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Trinity;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.CachedValueProvider;
import com.intellij.psi.util.CachedValuesManager;
import com.intellij.psi.util.PsiUtilBase;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.util.PairProcessor;
import com.intellij.util.containers.ConcurrentFactoryMap;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashMap;
import org.jetbrains.annotations.NotNull;
@@ -130,6 +133,7 @@ public class TemplateManagerImpl extends TemplateManager implements Disposable {
@Override
public boolean startTemplate(@NotNull Editor editor, char shortcutChar) {
PsiDocumentManager.getInstance(myProject).commitDocument(editor.getDocument());
Runnable runnable = prepareTemplate(editor, shortcutChar, null);
if (runnable != null) {
runnable.run();
@@ -260,36 +264,31 @@ public class TemplateManagerImpl extends TemplateManager implements Disposable {
PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, myProject);
if (file == null) return null;
TemplateSettings templateSettings = TemplateSettings.getInstance();
Map<TemplateImpl, String> template2argument = findMatchingTemplates(file, editor, shortcutChar, templateSettings);
Map<TemplateImpl, String> template2argument = findMatchingTemplates(file, editor, shortcutChar, TemplateSettings.getInstance());
for (final CustomLiveTemplate customLiveTemplate : CustomLiveTemplate.EP_NAME.getExtensions()) {
if (shortcutChar == customLiveTemplate.getShortcut()) {
if (editor.getCaretModel().getCaretCount() > 1 && !supportsMultiCaretMode(customLiveTemplate)) {
continue;
}
final Document document = editor.getDocument();
PsiDocumentManager.getInstance(myProject).commitDocument(document);
if (isApplicable(customLiveTemplate, editor, file)) {
final CustomTemplateCallback callback = new CustomTemplateCallback(editor, file);
final String key = customLiveTemplate.computeTemplateKey(callback);
List<CustomLiveTemplate> customCandidates = ContainerUtil.findAll(CustomLiveTemplate.EP_NAME.getExtensions(), customLiveTemplate ->
shortcutChar == customLiveTemplate.getShortcut() &&
(editor.getCaretModel().getCaretCount() <= 1 || supportsMultiCaretMode(customLiveTemplate)));
if (!customCandidates.isEmpty()) {
int caretOffset = editor.getCaretModel().getOffset();
PsiFile fileCopy = insertDummyIdentifierIfNeeded(file, caretOffset, caretOffset, "");
Document document = editor.getDocument();
for (final CustomLiveTemplate customLiveTemplate : customCandidates) {
if (isApplicable(customLiveTemplate, editor, fileCopy)) {
final String key = customLiveTemplate.computeTemplateKey(new CustomTemplateCallback(editor, fileCopy));
if (key != null) {
int caretOffset = editor.getCaretModel().getOffset();
int offsetBeforeKey = caretOffset - key.length();
CharSequence text = document.getImmutableCharSequence();
if (template2argument == null || !containsTemplateStartingBefore(template2argument, offsetBeforeKey, caretOffset, text)) {
return new Runnable() {
@Override
public void run() {
customLiveTemplate.expand(key, callback);
}
};
return () -> customLiveTemplate.expand(key, new CustomTemplateCallback(editor, file));
}
}
}
}
}
return startNonCustomTemplates(template2argument, editor, processor);
}
@@ -357,13 +356,6 @@ public class TemplateManagerImpl extends TemplateManager implements Disposable {
return null;
}
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
@Override
public void run() {
PsiDocumentManager.getInstance(myProject).commitDocument(document);
}
}, "", null);
candidatesWithoutArgument = filterApplicableCandidates(file, caretOffset, candidatesWithoutArgument);
candidatesWithArgument = filterApplicableCandidates(file, argumentOffset, candidatesWithArgument);
Map<TemplateImpl, String> candidate2Argument = new HashMap<TemplateImpl, String>();
@@ -474,7 +466,7 @@ public class TemplateManagerImpl extends TemplateManager implements Disposable {
return candidates;
}
PsiFile copy = insertDummyIdentifier(file, caretOffset, caretOffset);
PsiFile copy = insertDummyIdentifierIfNeeded(file, caretOffset, caretOffset, CompletionUtil.DUMMY_IDENTIFIER_TRIMMED);
List<TemplateImpl> result = new ArrayList<TemplateImpl>();
for (TemplateImpl candidate : candidates) {
@@ -610,15 +602,34 @@ public class TemplateManagerImpl extends TemplateManager implements Disposable {
boolean selection = editor.getSelectionModel().hasSelection();
final int startOffset = selection ? editor.getSelectionModel().getSelectionStart() : editor.getCaretModel().getOffset();
final int endOffset = selection ? editor.getSelectionModel().getSelectionEnd() : startOffset;
return insertDummyIdentifier(file, startOffset, endOffset);
return insertDummyIdentifierIfNeeded(file, startOffset, endOffset, CompletionUtil.DUMMY_IDENTIFIER_TRIMMED);
}
public static PsiFile insertDummyIdentifier(PsiFile file, final int startOffset, final int endOffset) {
file = (PsiFile)file.copy();
final Document document = file.getViewProvider().getDocument();
assert document != null;
document.replaceString(startOffset, endOffset, CompletionUtil.DUMMY_IDENTIFIER_TRIMMED);
PsiDocumentManager.getInstance(file.getProject()).commitDocument(document);
return file;
private static PsiFile insertDummyIdentifierIfNeeded(PsiFile file, final int startOffset, final int endOffset, String replacement) {
Document originalDocument = file.getViewProvider().getDocument();
assert originalDocument != null;
if (replacement.isEmpty() && PsiDocumentManager.getInstance(file.getProject()).isCommitted(originalDocument)) {
return file;
}
ConcurrentFactoryMap<Trinity<Integer, Integer, String>, PsiFile> map =
CachedValuesManager.getCachedValue(file, () -> CachedValueProvider.Result.create(new ConcurrentFactoryMap<Trinity<Integer, Integer, String>, PsiFile>() {
@Nullable
@Override
protected PsiFile create(Trinity<Integer, Integer, String> key) {
PsiFile copy = (PsiFile)file.copy();
final Document document = copy.getViewProvider().getDocument();
assert document != null;
document.setText(originalDocument.getImmutableCharSequence()); // original file might be uncommitted
document.replaceString(key.first, key.second, key.third);
PsiDocumentManager.getInstance(copy.getProject()).commitDocument(document);
return copy;
}
}, file, originalDocument));
return map.get(Trinity.create(startOffset, endOffset, replacement));
}
}
@@ -36,7 +36,7 @@ public class ExpandLiveTemplateCustomAction extends EditorAction {
setInjectedContext(true);
}
static EditorWriteActionHandler createExpandTemplateHandler(final char shortcutChar) {
public static EditorWriteActionHandler createExpandTemplateHandler(final char shortcutChar) {
return new EditorWriteActionHandler(true) {
@Override
public void executeWriteAction(Editor editor, @Nullable Caret caret, DataContext dataContext) {
@@ -51,7 +51,7 @@ public class DescriptorComposer extends HTMLComposerImpl {
genPageHeader(buf, refEntity);
if (myTool.getDescriptions(refEntity) != null) {
appendHeading(buf, InspectionsBundle.message("inspection.problem.synopsis"));
buf.append("<div class=\"problem-description\">");
CommonProblemDescriptor[] descriptions = myTool.getDescriptions(refEntity);
LOG.assertTrue(descriptions != null);
@@ -66,6 +66,7 @@ public class DescriptorComposer extends HTMLComposerImpl {
}
doneList(buf);
buf.append("</div>");
appendResolution(buf,refEntity, quickFixTexts(refEntity, myTool));
}
@@ -779,7 +779,15 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
@Override
public void close(boolean noSuspisiousCodeFound) {
if (!noSuspisiousCodeFound && (myView == null || myView.isRerun())) return;
if (!noSuspisiousCodeFound) {
if (myView.isRerun()) {
myViewClosed = true;
myView = null;
}
if (myView == null) {
return;
}
}
AnalysisUIOptions.getInstance(getProject()).save(myUIOptions);
if (myContent != null) {
final ContentManager contentManager = getContentManager();
@@ -51,7 +51,9 @@ import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.util.ThrowableRunnable;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.tree.TreeUtil;
import org.intellij.lang.annotations.Language;
import org.jdom.Document;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
@@ -71,6 +73,9 @@ public class ExportHTMLAction extends AnAction implements DumbAware {
@NonNls private static final String PROBLEMS = "problems";
@NonNls private static final String HTML = "HTML";
@NonNls private static final String XML = "XML";
@NonNls
private static String CSS = "";
public ExportHTMLAction(final InspectionResultsView view) {
super(InspectionsBundle.message("inspection.action.export.html"), null, AllIcons.Actions.Export);
@@ -293,7 +298,11 @@ public class ExportHTMLAction extends AnAction implements DumbAware {
List<RefEntity> packageContent = new ArrayList<RefEntity>(content.get(packageName));
Collections.sort(packageContent, RefEntityAlphabeticalComparator.getInstance());
StringBuffer contentIndex = new StringBuffer();
contentIndex.append("<html><body>");
contentIndex.append("<html>" +
"<head>\n" +
"<link rel=\"stylesheet\" type=\"text/css\" href=\"inspection-report-style.css\">\n" +
"</head>" +
"<body>");
for (RefEntity refElement : packageContent) {
refElement = refElement.getRefManager().getRefinedElement(refElement);
contentIndex.append("<a HREF=\"");
@@ -307,6 +316,9 @@ public class ExportHTMLAction extends AnAction implements DumbAware {
contentIndex.append("</body></html>");
HTMLExportUtil.writeFile(exporter.getRootFolder(), packageName + "-index.html", contentIndex, myView.getProject());
CSS = "p.problem-description-group {color: %s; font-weight:bold;}\n" +
".";
HTMLExportUtil.writeFile(exporter.getRootFolder(), "inspection-report-style.css", String.format(CSS, UIUtil.isUnderDarcula() ? "#A5C25C" : "#005555"), myView.getProject());
}
final Set<RefModule> modules = new HashSet<RefModule>();
@@ -73,6 +73,7 @@ import com.intellij.usageView.UsageInfo;
import com.intellij.usages.*;
import com.intellij.usages.impl.UsagePreviewPanel;
import com.intellij.util.*;
import com.intellij.util.containers.Convertor;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -644,6 +645,12 @@ public class FindDialog extends DialogWrapper {
}
};
myResultsPreviewTable = table;
new TableSpeedSearch(table, new Convertor<Object, String>() {
@Override
public String convert(Object o) {
return ((UsageInfo2UsageAdapter)o).getFile().getName();
}
});
myResultsPreviewTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
@@ -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.
@@ -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.
@@ -21,12 +21,12 @@ import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.util.Processor;
import com.intellij.util.concurrency.AtomicFieldUpdater;
import jsr166e.CountedCompleter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.CountedCompleter;
/**
* Executes processor on array elements in range from lo (inclusive) to hi (exclusive).
@@ -38,7 +38,7 @@ import java.util.List;
* After that, the task completes itself.
* The process of completing traverses task parent hierarchy, decrementing each pending count until it either
* decrements not-zero pending count and stops or
* reaches the top, in which case it invokes {@link jsr166e.ForkJoinTask#quietlyComplete()} which causes the top level task to wake up and join successfully.
* reaches the top, in which case it invokes {@link java.util.concurrent.ForkJoinTask#quietlyComplete()} which causes the top level task to wake up and join successfully.
* The exceptions from the sub tasks bubble up to the top and saved in {@link #throwable}.
*/
class ApplierCompleter<T> extends CountedCompleter<Void> {
@@ -55,7 +55,7 @@ class ApplierCompleter<T> extends CountedCompleter<Void> {
private static final AtomicFieldUpdater<ApplierCompleter, Throwable> throwableUpdater = AtomicFieldUpdater.forFieldOfType(ApplierCompleter.class, Throwable.class);
// if not null, the read action has failed and this list contains unfinished subtasks
private List<ApplierCompleter<T>> failedSubTasks;
private final Collection<ApplierCompleter<T>> failedSubTasks;
//private final List<ApplierCompleter> children = new ArrayList<ApplierCompleter>();
@@ -72,6 +72,7 @@ class ApplierCompleter<T> extends CountedCompleter<Void> {
@NotNull Processor<? super T> processor,
int lo,
int hi,
@NotNull Collection<ApplierCompleter<T>> failedSubTasks,
ApplierCompleter<T> next) {
super(parent);
this.runInReadAction = runInReadAction;
@@ -80,28 +81,20 @@ class ApplierCompleter<T> extends CountedCompleter<Void> {
this.processor = processor;
this.lo = lo;
this.hi = hi;
this.failedSubTasks = failedSubTasks;
this.next = next;
}
@Override
public void compute() {
wrapInReadActionAndIndicator(new Runnable() {
@Override
public void run() {
execAndForkSubTasks();
}
});
wrapInReadActionAndIndicator(this::execAndForkSubTasks);
}
private void wrapInReadActionAndIndicator(@NotNull final Runnable process) {
Runnable toRun = runInReadAction ? new Runnable() {
@Override
public void run() {
if (!ApplicationManagerEx.getApplicationEx().tryRunReadAction(process)) {
failedSubTasks = new ArrayList<ApplierCompleter<T>>();
failedSubTasks.add(ApplierCompleter.this);
doComplete(throwable);
}
Runnable toRun = runInReadAction ? () -> {
if (!ApplicationManagerEx.getApplicationEx().tryRunReadAction(process)) {
failedSubTasks.add(this);
doComplete(throwable);
}
} : process;
ProgressIndicator existing = ProgressManager.getInstance().getProgressIndicator();
@@ -122,6 +115,7 @@ class ApplierCompleter<T> extends CountedCompleter<Void> {
long start = System.currentTimeMillis();
ApplierCompleter<T> right = null;
Throwable throwable = null;
try {
for (int i = lo; i < hi; ++i) {
progressIndicator.checkCanceled();
@@ -132,7 +126,7 @@ class ApplierCompleter<T> extends CountedCompleter<Void> {
long elapsed = finish - start;
if (elapsed > 5 && hi - i >= 2 && getSurplusQueuedTaskCount() <= JobSchedulerImpl.CORES_COUNT) {
int mid = i + hi >>> 1;
right = new ApplierCompleter<T>(this, runInReadAction, progressIndicator, array, processor, mid, hi, right);
right = new ApplierCompleter<>(this, runInReadAction, progressIndicator, array, processor, mid, hi, failedSubTasks, right);
//children.add(right);
addToPendingCount(1);
right.fork();
@@ -223,34 +217,23 @@ class ApplierCompleter<T> extends CountedCompleter<Void> {
}
boolean completeTaskWhichFailToAcquireReadAction() {
if (failedSubTasks == null) {
return true;
}
final boolean[] result = {true};
// these tasks could not be executed in the other thread; do them here
for (final ApplierCompleter<T> task : failedSubTasks) {
task.failedSubTasks = null;
task.wrapInReadActionAndIndicator(new Runnable() {
@Override
public void run() {
for (int i = task.lo; i < task.hi; ++i) {
if (!task.processor.process(task.array.get(i))) {
result[0] = false;
break;
}
task.wrapInReadActionAndIndicator(() -> {
for (int i = task.lo; i < task.hi; ++i) {
if (!task.processor.process(task.array.get(i))) {
result[0] = false;
break;
}
}
});
if (task.failedSubTasks != null) {
result[0] = false;
break;
}
}
return result[0];
}
@Override
public String toString() {
return System.identityHashCode(this) + " ("+lo+"-"+hi+")";
return "("+lo+"-"+hi+")"+(getCompleter() == null ? "" : " parent: "+getCompleter());
}
}
@@ -15,7 +15,6 @@
*/
package com.intellij.concurrency;
import com.intellij.Patches;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
@@ -25,64 +24,20 @@ import com.intellij.util.Consumer;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.Processor;
import com.intellij.util.io.storage.HeavyProcessLatch;
import jsr166e.ForkJoinPool;
import jsr166e.ForkJoinTask;
import jsr166e.ForkJoinWorkerThread;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
/**
* @author cdr
*/
public class JobLauncherImpl extends JobLauncher {
private static final AtomicLong bits = new AtomicLong();
static {
assert Patches.USE_REFLECTION_TO_ACCESS_JDK8 : "Please port to java.util.concurrent.ForkJoinPool";
}
private static final ForkJoinPool.ForkJoinWorkerThreadFactory FACTORY = new ForkJoinPool.ForkJoinWorkerThreadFactory() {
@Override
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
final int n = addThread();
ForkJoinWorkerThread thread = new ForkJoinWorkerThread(pool) {
@Override
protected void onTermination(Throwable exception) {
finishThread(n);
super.onTermination(exception);
}
};
thread.setName("JobScheduler FJ pool "+ n +"/"+ JobSchedulerImpl.CORES_COUNT);
return thread;
}
private int addThread() {
boolean set;
int n;
do {
long l = bits.longValue();
long next = (l + 1) | l;
n = Long.numberOfTrailingZeros(l + 1);
set = bits.compareAndSet(l, next);
} while (!set);
return n;
}
private void finishThread(int n) {
boolean set;
do {
long l = bits.get();
long next = l & ~(1L << n);
set = bits.compareAndSet(l, next);
} while (!set);
}
};
private static final ForkJoinPool pool = new ForkJoinPool(JobSchedulerImpl.CORES_COUNT, FACTORY, null, false);
static final int CORES_FORK_THRESHOLD = 1;
@Override
@@ -99,9 +54,10 @@ public class JobLauncherImpl extends JobLauncher {
HeavyProcessLatch.INSTANCE.stopThreadPrioritizing();
ApplierCompleter<T> applier = new ApplierCompleter<>(null, runInReadAction, wrapper, things, thingProcessor, 0, things.size(), null);
List<ApplierCompleter<T>> failedSubTasks = Collections.synchronizedList(new ArrayList<>());
ApplierCompleter<T> applier = new ApplierCompleter<>(null, runInReadAction, wrapper, things, thingProcessor, 0, things.size(), failedSubTasks, null);
try {
pool.invoke(applier);
ForkJoinPool.commonPool().invoke(applier);
if (applier.throwable != null) throw applier.throwable;
}
catch (ApplierCompleter.ComputationAbortedException e) {
@@ -217,7 +173,7 @@ public class JobLauncherImpl extends JobLauncher {
}
private void submit() {
pool.submit(myForkJoinTask);
ForkJoinPool.commonPool().submit(myForkJoinTask);
}
//////////////// Job
@@ -282,8 +238,8 @@ public class JobLauncherImpl extends JobLauncher {
catch (CancellationException e) {
// was canceled in the middle of execution
// can't do anything but wait. help other tasks in the meantime
if (Thread.currentThread() instanceof ForkJoinWorkerThread) { // if called outside FJP the FJTask.fork() starts up commonPool which is undesirable
pool.awaitQuiescence(millis, TimeUnit.MILLISECONDS);
if (!isDone()) {
ForkJoinPool.commonPool().awaitQuiescence(millis, TimeUnit.MILLISECONDS);
}
}
}
@@ -365,7 +321,7 @@ public class JobLauncherImpl extends JobLauncher {
List<ForkJoinTask<Boolean>> tasks = new ArrayList<>();
for (int i = 0; i < JobSchedulerImpl.CORES_COUNT; i++) {
tasks.add(pool.submit(new MyTask(i)));
tasks.add(ForkJoinPool.commonPool().submit(new MyTask(i)));
}
boolean result = true;
@@ -448,10 +448,16 @@ public class StartupUtil {
});
viewer.setText(htmlText);
StyleSheet styleSheet = ((HTMLDocument)viewer.getDocument()).getStyleSheet();
styleSheet.addRule("body {font-size:" + JBUI.scaleFontSize(17) + "pt;}");
styleSheet.addRule("h4 {font-size:" + JBUI.scaleFontSize(18) + "pt;}");
styleSheet.addRule("body {font-family: \"Segoe UI\", Tahoma, sans-serif;}");
styleSheet.addRule("body {margin-top:0;padding-top:0;}");
styleSheet.addRule("body {font-size:" + JBUI.scaleFontSize(13) + "pt;}");
styleSheet.addRule("h2, em {margin-top:" + JBUI.scaleFontSize(20) + "pt;}");
styleSheet.addRule("h1, h2, h3, p, h4, em {margin-bottom:0;padding-bottom:0;}");
styleSheet.addRule("p, h1 {margin-top:0;padding-top:"+JBUI.scaleFontSize(6)+"pt;}");
styleSheet.addRule("li {margin-bottom:" + JBUI.scaleFontSize(6) + "pt;}");
styleSheet.addRule("h2 {margin-top:0;padding-top:"+JBUI.scaleFontSize(13)+"pt;}");
viewer.setCaretPosition(0);
viewer.setBorder(JBUI.Borders.empty(5));
viewer.setBorder(JBUI.Borders.empty(0, 5, 5, 5));
centerPanel.add(new JLabel("Please read and accept these terms and conditions:"), BorderLayout.NORTH);
centerPanel
.add(new JBScrollPane(viewer, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER),
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 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.
@@ -31,7 +31,10 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.ui.popup.Balloon;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.ShutDownTracker;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.Trinity;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.*;
import com.intellij.ui.awt.RelativePoint;
@@ -535,8 +538,7 @@ public class EventLog {
if (target != null) {
IdeFrame frame = WindowManager.getInstance().getIdeFrame(project);
assert frame != null;
Balloon balloon = NotificationsManagerImpl.createBalloon(frame, myNotification, true, true, null);
Disposer.register(project, balloon);
Balloon balloon = NotificationsManagerImpl.createBalloon(frame, myNotification, true, true, null, project);
balloon.show(target, Balloon.Position.above);
}
}
@@ -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.
@@ -21,6 +21,7 @@ import com.intellij.ide.ui.laf.darcula.ui.DarculaButtonPainter;
import com.intellij.ide.ui.laf.darcula.ui.DarculaButtonUI;
import com.intellij.notification.*;
import com.intellij.notification.impl.ui.NotificationsUtil;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
@@ -228,8 +229,7 @@ public class NotificationsManagerImpl extends NotificationsManager {
final boolean noProjects = projectManager.getOpenProjects().length == 0;
final boolean sticky = NotificationDisplayType.STICKY_BALLOON == displayType || noProjects;
Ref<Object> layoutDataRef = newEnabled() ? new Ref<Object>() : null;
final Balloon balloon = createBalloon((IdeFrame)window, notification, false, false, layoutDataRef);
Disposer.register(project != null ? project : ApplicationManager.getApplication(), balloon);
final Balloon balloon = createBalloon((IdeFrame)window, notification, false, false, layoutDataRef, project != null ? project : ApplicationManager.getApplication());
if (notification.isExpired()) {
return null;
@@ -295,8 +295,9 @@ public class NotificationsManagerImpl extends NotificationsManager {
@NotNull final Notification notification,
final boolean showCallout,
final boolean hideOnClickOutside,
@Nullable Ref<Object> layoutDataRef) {
return createBalloon(window.getComponent(), notification, showCallout, hideOnClickOutside, layoutDataRef);
@Nullable Ref<Object> layoutDataRef,
@NotNull Disposable parentDisposable) {
return createBalloon(window.getComponent(), notification, showCallout, hideOnClickOutside, layoutDataRef, parentDisposable);
}
@NotNull
@@ -304,9 +305,12 @@ public class NotificationsManagerImpl extends NotificationsManager {
@NotNull final Notification notification,
final boolean showCallout,
final boolean hideOnClickOutside,
@Nullable Ref<Object> layoutDataRef) {
@Nullable Ref<Object> layoutDataRef,
@NotNull Disposable parentDisposable) {
if (layoutDataRef != null) {
return createNewBalloon(windowComponent, notification, showCallout, hideOnClickOutside, layoutDataRef);
Balloon balloon = createNewBalloon(windowComponent, notification, showCallout, hideOnClickOutside, layoutDataRef);
Disposer.register(parentDisposable, balloon);
return balloon;
}
final JEditorPane text = new JEditorPane();
@@ -380,6 +384,7 @@ public class NotificationsManagerImpl extends NotificationsManager {
final Balloon balloon = builder.createBalloon();
balloon.setAnimationEnabled(false);
notification.setBalloon(balloon);
Disposer.register(parentDisposable, balloon);
return balloon;
}
@@ -17,7 +17,7 @@ package com.intellij.openapi.application.impl;
import com.intellij.BundleBase;
import com.intellij.CommonBundle;
import com.intellij.Patches;
import com.intellij.concurrency.IdeaForkJoinWorkerThreadFactory;
import com.intellij.diagnostic.LogEventException;
import com.intellij.diagnostic.PerformanceWatcher;
import com.intellij.diagnostic.ThreadDumper;
@@ -77,12 +77,12 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import org.jetbrains.ide.PooledThreadExecutor;
import org.picocontainer.MutablePicoContainer;
import sun.awt.AWTAccessor;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
@@ -168,6 +168,10 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
}
};
static {
IdeaForkJoinWorkerThreadFactory.setupForkJoinCommonPool();
}
public ApplicationImpl(boolean isInternal,
boolean isUnitTestMode,
boolean isHeadless,
@@ -1077,15 +1081,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
private static Thread getEventQueueThread() {
EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
try {
// use sun.awt.AWTAccessor.EventQueueAccessor?
assert Patches.USE_REFLECTION_TO_ACCESS_JDK8;
Method method = ReflectionUtil.getDeclaredMethod(EventQueue.class, "getDispatchThread");
return (Thread)method.invoke(eventQueue);
}
catch (Exception e) {
throw new RuntimeException(e);
}
return AWTAccessor.getEventQueueAccessor().getDispatchThread(eventQueue);
}
@Override
@@ -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.
@@ -182,7 +182,7 @@ public class ServiceManagerImpl implements BaseComponent {
private final ServiceDescriptor myDescriptor;
private final PluginDescriptor myPluginDescriptor;
private final ComponentManagerEx myComponentManager;
private volatile Object myInitializedComponentInstance = null;
private volatile Object myInitializedComponentInstance;
public MyComponentAdapter(final ServiceDescriptor descriptor, final PluginDescriptor pluginDescriptor, ComponentManagerEx componentManager) {
myDescriptor = descriptor;
@@ -302,8 +302,6 @@ public class CaretImpl extends UserDataHolderBase implements Caret, Dumpable {
// We want to move caret to the first column if it's already located at the first line and 'Up' is pressed.
newColumnNumber = 0;
desiredX = -1;
lastColumnNumber = -1;
}
VisualPosition pos = new VisualPosition(newLineNumber, newColumnNumber);
@@ -316,8 +314,6 @@ public class CaretImpl extends UserDataHolderBase implements Caret, Dumpable {
if (lastOffsetColumn > newColumnNumber) {
newColumnNumber = lastOffsetColumn;
newLeansRight = true;
desiredX = -1;
lastColumnNumber = -1;
}
}
if (!editorSettings.isCaretInsideTabs()) {
@@ -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.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.diff.util;
package com.intellij.openapi.progress.util;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
@@ -28,6 +28,7 @@ import com.intellij.openapi.util.EmptyRunnable;
import com.intellij.openapi.util.Ref;
import com.intellij.util.Consumer;
import com.intellij.util.Function;
import org.jetbrains.annotations.CalledInAny;
import org.jetbrains.annotations.CalledInAwt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -168,8 +169,27 @@ public class BackgroundTaskUtil {
@CalledInAwt
@NotNull
public static ProgressIndicator executeOnPooledThread(@NotNull final Consumer<ProgressIndicator> task, @NotNull Disposable parent) {
public static ProgressIndicator executeOnPooledThread(@NotNull Consumer<ProgressIndicator> task, @NotNull Disposable parent) {
final ModalityState modalityState = ModalityState.current();
return executeOnPooledThread(task, parent, modalityState);
}
@NotNull
@CalledInAny
public static ProgressIndicator executeOnPooledThread(@NotNull final Runnable runnable, @NotNull Disposable parent) {
return executeOnPooledThread(new Consumer<ProgressIndicator>() {
@Override
public void consume(@Nullable ProgressIndicator indicator) {
runnable.run();
}
}, parent, ModalityState.NON_MODAL);
}
@NotNull
@CalledInAny
public static ProgressIndicator executeOnPooledThread(@NotNull final Consumer<ProgressIndicator> task,
@NotNull Disposable parent,
final ModalityState modalityState) {
final ProgressIndicator indicator = new EmptyProgressIndicator() {
@NotNull
@Override
@@ -177,7 +197,6 @@ public class BackgroundTaskUtil {
return modalityState;
}
};
indicator.start();
final Disposable disposable = new Disposable() {
@Override
@@ -186,6 +205,7 @@ public class BackgroundTaskUtil {
}
};
Disposer.register(parent, disposable);
indicator.start();
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
@Override
@@ -26,7 +26,6 @@ import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.application.ex.ApplicationInfoEx;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Version;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.BrowserHyperlinkListener;
import com.intellij.ui.JBColor;
@@ -243,8 +242,6 @@ class UpdateInfoDialog extends AbstractUpdateDialog {
}
protected static String formatVersion(String versionString, String build) {
Version version = Version.parseVersion(versionString);
String formattedVersion = version != null ? version.toString() : versionString;
return IdeBundle.message("updates.version.info", formattedVersion, build);
return IdeBundle.message("updates.version.info", versionString, build);
}
}
@@ -917,8 +917,6 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui {
Toolkit.getDefaultToolkit().removeAWTEventListener(myAwtActivityListener);
if (myLayeredPane != null) {
myLayeredPane.removeComponentListener(myComponentListener);
Disposer.register(ApplicationManager.getApplication(),
this); // to be safe if Application suddenly exits and animation wouldn't have a chance to complete
runAnimation(false, myLayeredPane, disposeRunnable);
}
@@ -9,7 +9,7 @@ unknown.file.type.error=Unknown file type: {0}
save.merge.result.command.name=Merge
compare.file.vs.file.dialog.title={0} vs {1}
diff.content.editor.content.title=Editor
diff.content.clipboard.content.title=Clipboard
diff.content.clipboard.content.title=From \u0441lipboard
diff.clipboard.vs.editor.dialog.title=Clipboard vs Editor
diff.clipboard.vs.file.dialog.title=Clipboard vs {0}
diff.content.selection.from.editor.content.title=Selection from Editor
@@ -424,7 +424,7 @@ inspection.dead.code.problem.synopsis21=Method is never used as a member of this
inspection.dead.code.problem.synopsis22=Method overrides a library method but<ul><li>its {0} is never instantiated OR</li><li>its {0} instantiation is not reachable from entry points.</li></ul>
inspection.dead.code.problem.synopsis23={0} is not implemented.
inspection.dead.code.problem.synopsis24={0} has an implementation but <ul><li>it is never instantiated OR</li><li>no instantiations are reachable from entry points.</li></ul>
inspection.dead.code.problem.synopsis25={0} has {1, choice, 1#direct or indirect implementation|2#{1,number} direct or indirect implementations} but <ul><li>they are never instantiated OR</li><li>no instantiations are reachable from entry points.</li></ul>
inspection.dead.code.problem.synopsis25={0} has {1, choice, 1#direct or indirect implementation|2#{1,number} direct or indirect implementations} but <ul><li>\u2014they are never instantiated OR</li><li>\u2014no instantiations are reachable from entry points.</li></ul>
inspection.dead.code.problem.synopsis26.constructor=Constructor is never used.
inspection.dead.code.problem.synopsis27.constructor=Constructor has usage(s) but they all belong to calls chain that has no members reachable from entry points.
inspection.dead.code.problem.synopsis28.constructor=Constructor has one usage but it is not reachable from entry points.
@@ -663,6 +663,7 @@ annotate.overridden.methods.as.notnull=Annotate overridden methods as ''@{0}''
nullable.stuff.problems.overridden.methods.are.not.annotated=Overridden methods are not annotated
nullable.stuff.problems.overridden.method.parameters.are.not.annotated=Overridden method parameters are not annotated
annotate.overridden.methods.parameters=Annotate overridden method parameters as ''@{0}''
annotate.overridden.methods.parameters.family.name=Annotate overridden method parameters
offline.inspections.library.was.not.resolved=Please configure library ''{0}'' which is used in module ''{1}''
report.suspicious.but.possibly.correct.method.calls=&Report suspicious but possibly correct method calls
unused.library.display.name=Unused library
@@ -303,4 +303,20 @@ public class EditorImplTest extends AbstractEditorTest {
verifySoftWrapPositions();
}
public void testUpDownNearDocumentTopAndBottom() throws Exception {
initText("abc\nd<caret>ef\nghi");
up();
checkResultByText("a<caret>bc\ndef\nghi");
up();
checkResultByText("<caret>abc\ndef\nghi");
down();
checkResultByText("abc\nd<caret>ef\nghi");
down();
checkResultByText("abc\ndef\ng<caret>hi");
down();
checkResultByText("abc\ndef\nghi<caret>");
up();
checkResultByText("abc\nd<caret>ef\nghi");
}
}
@@ -256,15 +256,8 @@ abstract class DebugProcessImpl<C : VmConnection<*>>(session: XDebugSession,
protected fun addChildVm(vm: Vm) {
beforeInitBreakpoints(vm)
val breakpointManager = XDebuggerManager.getInstance(session.project).breakpointManager
@Suppress("UNCHECKED_CAST")
for (breakpointHandler in breakpointHandlers) {
if (breakpointHandler is LineBreakpointHandler) {
val breakpoints = runReadAction { breakpointManager.getBreakpoints(breakpointHandler.breakpointTypeClass) }
for (breakpoint in breakpoints) {
breakpointHandler.manager.setBreakpoint(vm, breakpoint)
}
}
processBreakpoints { handler, breakpoint ->
handler.manager.setBreakpoint(vm, breakpoint)
}
}
@@ -276,6 +269,18 @@ abstract class DebugProcessImpl<C : VmConnection<*>>(session: XDebugSession,
}
}
}
protected inline fun processBreakpoints(processor: (handler: LineBreakpointHandler, breakpoint: XLineBreakpoint<*>) -> Unit) {
val breakpointManager = XDebuggerManager.getInstance(session.project).breakpointManager
for (breakpointHandler in breakpointHandlers) {
if (breakpointHandler is LineBreakpointHandler) {
val breakpoints = runReadAction { breakpointManager.getBreakpoints(breakpointHandler.breakpointTypeClass) }
for (breakpoint in breakpoints) {
processor(breakpointHandler, breakpoint)
}
}
}
}
}
@Suppress("UNCHECKED_CAST")
@@ -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.
@@ -2702,6 +2702,11 @@ public class ContainerUtil extends ContainerUtilRt {
return collection == null || collection.isEmpty();
}
@Contract(value = "null -> true", pure = true)
public static boolean isEmpty(Map map) {
return map == null || map.isEmpty();
}
@NotNull
@Contract(pure=true)
public static <T> List<T> notNullize(@Nullable List<T> list) {
@@ -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.
@@ -29,7 +29,6 @@ import com.intellij.diff.tools.util.base.DiffViewerBase;
import com.intellij.diff.tools.util.base.DiffViewerListener;
import com.intellij.diff.tools.util.side.OnesideTextDiffViewer;
import com.intellij.diff.tools.util.side.TwosideTextDiffViewer;
import com.intellij.diff.util.BackgroundTaskUtil;
import com.intellij.diff.util.Side;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
@@ -43,10 +42,10 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.localVcs.UpToDateLineNumberProvider;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.util.BackgroundTaskUtil;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.Balloon;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vcs.*;
@@ -388,8 +387,7 @@ public class AnnotateDiffViewerAction extends ToggleAction implements DumbAware
return;
}
Balloon balloon = NotificationsManagerImpl.createBalloon(component, notification, false, true, null);
Disposer.register(viewer, balloon);
Balloon balloon = NotificationsManagerImpl.createBalloon(component, notification, false, true, null, viewer);
Dimension componentSize = component.getSize();
Dimension balloonSize = balloon.getPreferredSize();
@@ -124,7 +124,7 @@ public class LineStatusTracker {
synchronized (myLock) {
try {
if (myInitialized || myReleased) return;
if (myReleased) return;
if (myBaseRevisionNumber != null && myBaseRevisionNumber.contains(baseRevisionNumber)) return;
myBaseRevisionNumber = baseRevisionNumber;
@@ -21,7 +21,6 @@ import com.intellij.codeInsight.hint.HintManagerImpl;
import com.intellij.diff.comparison.ByWord;
import com.intellij.diff.comparison.ComparisonPolicy;
import com.intellij.diff.fragments.DiffFragment;
import com.intellij.diff.util.BackgroundTaskUtil;
import com.intellij.diff.util.DiffDrawUtil;
import com.intellij.diff.util.DiffUtil;
import com.intellij.diff.util.TextDiffType;
@@ -46,6 +45,7 @@ import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.util.BackgroundTaskUtil;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.registry.Registry;
@@ -155,7 +155,7 @@ public class EmptyDirectoryInspection extends BaseGlobalInspection {
@NotNull
@Override
public String getFamilyName() {
return getName();
return InspectionGadgetsBundle.message("empty.directories.delete.quickfix", "");
}
@Override
@@ -31,6 +31,7 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ChangeListManager;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.vcsUtil.VcsUtil;
import git4idea.GitRevisionNumber;
@@ -131,16 +132,13 @@ public class GithubOpenInBrowserAction extends DumbAwareAction {
return null;
}
final String rootPath = repository.getRoot().getPath();
final String path = virtualFile.getPath();
if (!path.startsWith(rootPath)) {
GithubNotifications
.showError(project, CANNOT_OPEN_IN_BROWSER, "File is not under repository root", "Root: " + rootPath + ", file: " + path);
String relativePath = VfsUtilCore.getRelativePath(virtualFile, repository.getRoot());
if (relativePath == null) {
GithubNotifications.showError(project, CANNOT_OPEN_IN_BROWSER, "File is not under repository root",
"Root: " + repository.getRoot().getPresentableUrl() + ", file: " + virtualFile.getPresentableUrl());
return null;
}
String relativePath = path.substring(rootPath.length());
String hash = getCurrentFileRevisionHash(project, virtualFile);
if (hash != null) {
return makeUrlToOpen(editor, relativePath, hash, githubRemoteUrl);
@@ -164,7 +162,7 @@ public class GithubOpenInBrowserAction extends DumbAwareAction {
builder.append(githubRepoUrl).append("/tree/").append(branch);
}
else {
builder.append(githubRepoUrl).append("/blob/").append(branch).append(relativePath);
builder.append(githubRepoUrl).append("/blob/").append(branch).append('/').append(relativePath);
}
if (editor != null && editor.getDocument().getLineCount() >= 1) {
@@ -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.
@@ -33,6 +33,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnState
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.path.GrIndexProperty;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrGdkMethod;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
@@ -95,7 +96,13 @@ public class SubstitutorComputer {
}
}
else if (parent instanceof GrAssignmentExpression && myPlaceToInferContext.equals(((GrAssignmentExpression)parent).getRValue())) {
return ((GrAssignmentExpression)parent).getLValue().getType();
GrExpression lValue = ((GrAssignmentExpression)parent).getLValue();
if (lValue instanceof GrIndexProperty) {
return null;
}
else {
return lValue.getType();
}
}
else if (parent instanceof GrVariable) {
return ((GrVariable)parent).getDeclaredType();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 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.
@@ -31,6 +31,7 @@ import org.intellij.plugins.intelliLang.inject.InjectorUtils;
import org.intellij.plugins.intelliLang.inject.LanguageInjectionSupport;
import org.intellij.plugins.intelliLang.inject.config.BaseInjection;
import org.intellij.plugins.intelliLang.inject.java.JavaLanguageInjectionSupport;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -228,6 +229,7 @@ public class GroovyLanguageInjectionSupport extends AbstractLanguageInjectionSup
};
}
@Contract("null -> false")
private static boolean isStringLiteral(@Nullable PsiLanguageInjectionHost element) {
if (element instanceof GrStringContent) {
return true;
@@ -1969,6 +1969,24 @@ import groovy.transform.Field
@Field
def (,<error descr="Identifier expected">)</error>
'''
}
void 'test no SOE in index property assignment with generic function'() {
testHighlighting '''
class Main {
static <T> T foo() {}
static void main(String[] args) {
def main = new Main()
main[Main] = foo()
}
def putAt(x, String t) {
println "Works: $x = $t"
}
}
'''
}
}
@@ -58,7 +58,7 @@ public class HgTaskHandler extends DvcsTaskHandler<HgRepository> {
@Override
protected void checkoutAsNewBranch(@NotNull String name, @NotNull List<HgRepository> repositories) {
HgBookmarkCommand.createBookmark(repositories, name, true);
HgBookmarkCommand.createBookmarkAsynchronously(repositories, name, true);
}
@Override
@@ -87,7 +87,7 @@ public class HgTaskHandler extends DvcsTaskHandler<HgRepository> {
Project project = repository.getProject();
VirtualFile repositoryRoot = repository.getRoot();
try {
new HgCommitCommand(project, repository, "Automated merge with " + branch).execute();
new HgCommitCommand(project, repository, "Automated merge with " + branch).executeInCurrentThread();
new HgBookmarkCommand(project, repositoryRoot, branch).deleteBookmark();
}
catch (HgCommandException e) {
@@ -153,7 +153,7 @@ public class HgVFSListener extends VcsVFSListener {
HgStatusCommand statusCommand = new HgStatusCommand.Builder(false).unknown(true).ignored(true).build(myProject);
for (Map.Entry<VirtualFile, Collection<VirtualFile>> entry : sortedSourceFilesByRepos.entrySet()) {
Set<HgChange> changes =
statusCommand.execute(entry.getKey(), ContainerUtil.map(entry.getValue(), new Function<VirtualFile, FilePath>() {
statusCommand.executeInCurrentThread(entry.getKey(), ContainerUtil.map(entry.getValue(), new Function<VirtualFile, FilePath>() {
@Override
public FilePath fun(VirtualFile virtualFile) {
return VcsUtil.getFilePath(virtualFile);
@@ -181,13 +181,13 @@ public class HgVFSListener extends VcsVFSListener {
// add for all files at once
if (!adds.isEmpty()) {
new HgAddCommand(myProject).execute(adds);
new HgAddCommand(myProject).executeInCurrentThread(adds);
}
// copy needs to be run for each file separately
if (!copies.isEmpty()) {
for(Map.Entry<VirtualFile, VirtualFile> copy : copies.entrySet()) {
new HgCopyCommand(myProject).execute(copy.getKey(), copy.getValue());
for (Map.Entry<VirtualFile, VirtualFile> copy : copies.entrySet()) {
new HgCopyCommand(myProject).executeInCurrentThread(copy.getKey(), copy.getValue());
}
}
@@ -301,7 +301,7 @@ public class HgVFSListener extends VcsVFSListener {
}
if (!deletes.isEmpty()) {
new HgRemoveCommand(myProject).execute(deletes);
new HgRemoveCommand(myProject).executeInCurrentThread(deletes);
}
for (HgFile file : deletes) {
@@ -406,12 +406,12 @@ public class HgVcs extends AbstractVcs<CommittedChangeList> {
@Override
@CalledInAwt
public void enableIntegration() {
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
HgUtil.executeOnPooledThread(new Runnable() {
public void run() {
Collection<VcsRoot> roots = ServiceManager.getService(myProject, VcsRootDetector.class).detect();
new HgIntegrationEnabler(HgVcs.this).enable(roots);
}
});
}, myProject);
}
@Override
@@ -151,6 +151,6 @@ public class HgCompareWithBranchAction extends DvcsCompareWithBranchAction<HgRep
HgStatusCommand statusCommand = new HgStatusCommand.Builder(true).ignored(false).unknown(false).copySource(!path.isDirectory())
.baseRevision(compareWithRevisionNumber).targetRevision(null).build(repository.getProject());
statusCommand.cleanFilesOption(true);
return !statusCommand.execute(repository.getRoot(), Collections.singleton(path)).isEmpty();
return !statusCommand.executeInCurrentThread(repository.getRoot(), Collections.singleton(path)).isEmpty();
}
}
@@ -42,7 +42,8 @@ public class HgCreateNewBranchFromLogAction extends HgLogSingleCommitAction {
@Override
public void run(@NotNull ProgressIndicator indicator) {
if (HgUpdateCommand.updateRepoToInCurrentThread(project, repository.getRoot(), commit.asString(), false)) {
new HgBranchPopupActions.HgNewBranchAction(project, Collections.singletonList(repository), repository).createNewBranch(name);
new HgBranchPopupActions.HgNewBranchAction(project, Collections.singletonList(repository), repository)
.createNewBranchInCurrentThread(name);
}
}
}.queue();
@@ -34,7 +34,7 @@ public class HgCreateTagAction extends HgAbstractGlobalSingleRepoAction {
final HgTagDialog dialog = new HgTagDialog(project, repositories, selectedRepo);
if (dialog.showAndGet()) {
try {
new HgTagCreateCommand(project, dialog.getRepository(), dialog.getTagName(), reference).execute(new HgCommandResultHandler() {
new HgTagCreateCommand(project, dialog.getRepository(), dialog.getTagName(), reference).executeAsynchronously(new HgCommandResultHandler() {
@Override
public void process(@Nullable HgCommandResult result) {
if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
@@ -86,7 +86,7 @@ public class HgInit extends DumbAwareAction {
}
if (needToCreateRepo) {
createRepository(selectedRoot, mapRoot);
createRepositoryAsynchronously(selectedRoot, mapRoot);
}
else {
updateDirectoryMappings(mapRoot);
@@ -105,8 +105,8 @@ public class HgInit extends DumbAwareAction {
}
}
private void createRepository(final VirtualFile selectedRoot, final VirtualFile mapRoot) {
new HgInitCommand(myProject).execute(selectedRoot, new HgCommandResultHandler() {
private void createRepositoryAsynchronously(final VirtualFile selectedRoot, final VirtualFile mapRoot) {
new HgInitCommand(myProject).executeAsynchronously(selectedRoot, new HgCommandResultHandler() {
@Override
public void process(@Nullable HgCommandResult result) {
if (!HgErrorUtil.hasErrorsInCommandExecution(result)) {
@@ -46,7 +46,7 @@ public class HgPullAction extends HgAbstractGlobalSingleRepoAction {
private static void executePull(final Project project, final HgRepository hgRepository, final String source) {
final HgPullCommand command = new HgPullCommand(project, hgRepository.getRoot());
command.setSource(source);
command.execute();
command.executeInCurrentThread();
hgRepository.update();
}
}
@@ -35,7 +35,7 @@ public abstract class HgActionFromMqPatches extends DumbAwareAction {
@Override
public void run() {
ProgressManager.getInstance().getProgressIndicator().setText(getTitle());
execute(repository, names);
executeInCurrentThread(repository, names);
}
};
patchInfo.updatePatchSeriesInBackground(task);
@@ -51,7 +51,7 @@ public abstract class HgActionFromMqPatches extends DumbAwareAction {
return true; //todo should be improved, param not needed
}
protected abstract void execute(@NotNull HgRepository repository, @NotNull List<String> patchNames);
protected abstract void executeInCurrentThread(@NotNull HgRepository repository, @NotNull List<String> patchNames);
@NotNull
protected abstract String getTitle();

Some files were not shown because too many files have changed in this diff Show More