mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -498,6 +498,7 @@ def reorder(String home, String targetDirectory) {
|
||||
arg(value: "$home/lib")
|
||||
classpath {
|
||||
pathelement(location: util.output)
|
||||
pathelement(location: getProperty('util-rt').output)
|
||||
pathelement(location: "$home/lib/jna.jar")
|
||||
pathelement(location: "$home/lib/trove4j.jar")
|
||||
}
|
||||
|
||||
@@ -642,6 +642,7 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
pushUnknown();
|
||||
final ConditionalGotoInstruction branch = new ConditionalGotoInstruction(-1, false, null);
|
||||
addInstruction(branch);
|
||||
addInstruction(new EmptyStackInstruction());
|
||||
addInstruction(new GosubInstruction(cd.getJumpOffset()));
|
||||
addInstruction(new ReturnInstruction());
|
||||
branch.setOffset(myCurrentFlow.getInstructionCount());
|
||||
@@ -651,6 +652,7 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
pushUnknown();
|
||||
final ConditionalGotoInstruction branch = new ConditionalGotoInstruction(-1, false, null);
|
||||
addInstruction(branch);
|
||||
addInstruction(new EmptyStackInstruction());
|
||||
addInstruction(new PushInstruction(myFactory.getNotNullFactory().create(myRuntimeException), null));
|
||||
addGotoCatch(cd);
|
||||
branch.setOffset(myCurrentFlow.getInstructionCount());
|
||||
|
||||
@@ -297,9 +297,13 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
}
|
||||
}
|
||||
|
||||
private int getOrCreateEqClassIndex(DfaValue dfaValue) {
|
||||
@Nullable("for boxed values which can't be compared by ==")
|
||||
private Integer getOrCreateEqClassIndex(DfaValue dfaValue) {
|
||||
int i = getEqClassIndex(dfaValue);
|
||||
if (i != -1) return i;
|
||||
if (!canBeReused(dfaValue) && !(((DfaBoxedValue)dfaValue).getWrappedValue() instanceof DfaConstValue)) {
|
||||
return null;
|
||||
}
|
||||
SortedIntSet aClass = new SortedIntSet();
|
||||
aClass.add(dfaValue.getID());
|
||||
myEqClasses.add(aClass);
|
||||
@@ -338,26 +342,28 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
for (int i = 0; i < myEqClasses.size(); i++) {
|
||||
SortedIntSet aClass = myEqClasses.get(i);
|
||||
if (aClass != null && aClass.contains(dfaValue.getID())) {
|
||||
if (dfaValue instanceof DfaBoxedValue && !canBeReused(((DfaBoxedValue)dfaValue).getWrappedValue(), this) && aClass.size() > 1) return -1;
|
||||
if (!canBeReused(dfaValue) && aClass.size() > 1) return -1;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
private static boolean canBeReused(final DfaValue valueToWrap, final DfaMemoryState memoryState) {
|
||||
if (valueToWrap instanceof DfaConstValue) {
|
||||
return cacheable((DfaConstValue)valueToWrap);
|
||||
}
|
||||
else if (valueToWrap instanceof DfaVariableValue) {
|
||||
if (PsiType.BOOLEAN.equals(((DfaVariableValue)valueToWrap).getPsiVariable().getType())) return true;
|
||||
List<DfaValue> values = ((DfaMemoryStateImpl)memoryState).getEqClassesFor(valueToWrap);
|
||||
for (DfaValue value : values) {
|
||||
if (value instanceof DfaConstValue && cacheable((DfaConstValue)value)) return true;
|
||||
|
||||
private boolean canBeReused(final DfaValue dfaValue) {
|
||||
if (dfaValue instanceof DfaBoxedValue) {
|
||||
DfaValue valueToWrap = ((DfaBoxedValue)dfaValue).getWrappedValue();
|
||||
if (valueToWrap instanceof DfaConstValue) {
|
||||
return cacheable((DfaConstValue)valueToWrap);
|
||||
}
|
||||
if (valueToWrap instanceof DfaVariableValue) {
|
||||
if (PsiType.BOOLEAN.equals(((DfaVariableValue)valueToWrap).getPsiVariable().getType())) return true;
|
||||
for (DfaValue value : getEqClassesFor(valueToWrap)) {
|
||||
if (value instanceof DfaConstValue && cacheable((DfaConstValue)value)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
//throw new IllegalArgumentException(""+valueToWrap);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean cacheable(DfaConstValue dfaConstValue) {
|
||||
@@ -474,10 +480,10 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
|
||||
if (dfaValue instanceof DfaVariableValue || dfaValue instanceof DfaConstValue) {
|
||||
DfaConstValue dfaNull = myFactory.getConstFactory().getNull();
|
||||
int c1Index = getOrCreateEqClassIndex(dfaValue);
|
||||
int c2Index = getOrCreateEqClassIndex(dfaNull);
|
||||
Integer c1Index = getOrCreateEqClassIndex(dfaValue);
|
||||
Integer c2Index = getOrCreateEqClassIndex(dfaNull);
|
||||
|
||||
return c1Index == c2Index;
|
||||
return c1Index != null && c1Index.equals(c2Index);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -485,13 +491,16 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
|
||||
public boolean isNotNull(DfaVariableValue dfaVar) {
|
||||
DfaConstValue dfaNull = myFactory.getConstFactory().getNull();
|
||||
int c1Index = getOrCreateEqClassIndex(dfaVar);
|
||||
int c2Index = getOrCreateEqClassIndex(dfaNull);
|
||||
Integer c1Index = getOrCreateEqClassIndex(dfaVar);
|
||||
Integer c2Index = getOrCreateEqClassIndex(dfaNull);
|
||||
if (c1Index == null || c2Index == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
long[] pairs = myDistinctClasses.toArray();
|
||||
for (long pair : pairs) {
|
||||
if (low(pair) == c1Index && high(pair) == c2Index ||
|
||||
high(pair) == c1Index && low(pair) == c2Index) {
|
||||
if (c1Index.equals(low(pair)) && c2Index.equals(high(pair)) ||
|
||||
c1Index.equals(high(pair)) && c2Index.equals(low(pair))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -568,21 +577,20 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
if (dfaRight instanceof DfaNotNullValue) {
|
||||
if (dfaLeft instanceof DfaVariableValue) {
|
||||
DfaVariableState varState = getVariableState((DfaVariableValue)dfaLeft);
|
||||
DfaVariableValue dfaVar = (DfaVariableValue)dfaLeft;
|
||||
DfaTypeValue type = myFactory.getTypeFactory().create(((DfaNotNullValue)dfaRight).getType());
|
||||
if (isNegated) {
|
||||
return varState.addNotInstanceofValue(type) || applyCondition(compareToNull(dfaVar, false));
|
||||
return varState.addNotInstanceofValue(type) ||
|
||||
applyCondition(myFactory.getRelationFactory().create(dfaVar, DfaUnknownValue.getInstance(), JavaTokenType.EQEQ, false));
|
||||
}
|
||||
return applyCondition(compareToNull(dfaVar, true)) && varState.setInstanceofValue(type);
|
||||
return applyCondition(compareToNull(dfaVar, false)) && varState.setInstanceofValue(type);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
if (dfaRight == myFactory.getConstFactory().getNull() && dfaLeft instanceof DfaVariableValue) {
|
||||
final DfaVariableState varState = getVariableState((DfaVariableValue)dfaLeft);
|
||||
@@ -637,15 +645,18 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
|
||||
private boolean applyRelation(@NotNull final DfaValue dfaLeft, @NotNull final DfaValue dfaRight, boolean isNegated) {
|
||||
// DfaConstValue || DfaVariableValue
|
||||
int c1Index = getOrCreateEqClassIndex(dfaLeft);
|
||||
int c2Index = getOrCreateEqClassIndex(dfaRight);
|
||||
Integer c1Index = getOrCreateEqClassIndex(dfaLeft);
|
||||
Integer c2Index = getOrCreateEqClassIndex(dfaRight);
|
||||
if (c1Index == null || c2Index == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isNegated) { //Equals
|
||||
if (c1Index == c2Index) return true;
|
||||
if (c1Index.equals(c2Index)) return true;
|
||||
if (!uniteClasses(c1Index, c2Index)) return false;
|
||||
}
|
||||
else { // Not Equals
|
||||
if (c1Index == c2Index) return false;
|
||||
if (c1Index.equals(c2Index)) return false;
|
||||
makeClassesDistinct(c1Index, c2Index);
|
||||
}
|
||||
|
||||
@@ -706,8 +717,8 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
boolean resetNullability = isNotNull(field);
|
||||
flushVariable(field);
|
||||
if (resetNullability) {
|
||||
getVariableState(field).setNullable(false);
|
||||
}
|
||||
getVariableState(field).setNullable(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -716,15 +727,15 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
return;
|
||||
}
|
||||
|
||||
doFlash(variable);
|
||||
doFlush(variable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushVariableOutOfScope(DfaVariableValue variable) {
|
||||
doFlash(variable);
|
||||
doFlush(variable);
|
||||
}
|
||||
|
||||
private void doFlash(DfaVariableValue varPlain) {
|
||||
private void doFlush(DfaVariableValue varPlain) {
|
||||
DfaVariableValue varNegated = (DfaVariableValue)varPlain.createNegated();
|
||||
|
||||
final int idPlain = varPlain.getID();
|
||||
|
||||
@@ -150,6 +150,9 @@ public abstract class InstructionVisitor {
|
||||
}
|
||||
|
||||
public DfaInstructionState[] visitPush(PushInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
|
||||
if (instruction.isFieldReference()) {
|
||||
memState.fieldReferenced();
|
||||
}
|
||||
memState.push(instruction.getValue());
|
||||
return nextInstruction(instruction, runner, memState);
|
||||
}
|
||||
|
||||
+3
-2
@@ -289,8 +289,6 @@ public class StandardInstructionVisitor extends InstructionVisitor {
|
||||
}
|
||||
else if (JavaTokenType.PLUS == opSign) {
|
||||
memState.push(instruction.getNonNullStringValue(factory));
|
||||
instruction.setTrueReachable(); // Not a branching instruction actually.
|
||||
instruction.setFalseReachable();
|
||||
}
|
||||
else {
|
||||
if (instruction instanceof InstanceofInstruction) {
|
||||
@@ -319,6 +317,9 @@ public class StandardInstructionVisitor extends InstructionVisitor {
|
||||
memState.push(DfaUnknownValue.getInstance());
|
||||
}
|
||||
|
||||
instruction.setTrueReachable(); // Not a branching instruction actually.
|
||||
instruction.setFalseReachable();
|
||||
|
||||
return nextInstruction(instruction, runner, memState);
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -31,6 +31,8 @@ import com.intellij.codeInspection.dataFlow.InstructionVisitor;
|
||||
import com.intellij.codeInspection.dataFlow.value.DfaUnknownValue;
|
||||
import com.intellij.codeInspection.dataFlow.value.DfaValue;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.psi.PsiField;
|
||||
import com.intellij.psi.PsiReferenceExpression;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PushInstruction extends Instruction {
|
||||
@@ -59,4 +61,8 @@ public class PushInstruction extends Instruction {
|
||||
public String toString() {
|
||||
return "PUSH " + myValue;
|
||||
}
|
||||
|
||||
public boolean isFieldReference() {
|
||||
return myPlace instanceof PsiReferenceExpression && ((PsiReferenceExpression)myPlace).resolve() instanceof PsiField;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -644,7 +644,7 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool {
|
||||
final RefElement refElement = (RefElement)refEntity;
|
||||
final HighlightSeverity severity = getCurrentSeverity(refElement);
|
||||
final String attributeKey =
|
||||
getTextAttributeKey(refElement.getElement().getProject(), severity, ProblemHighlightType.LIKE_UNUSED_SYMBOL);
|
||||
getTextAttributeKey(refElement.getRefManager().getProject(), severity, ProblemHighlightType.LIKE_UNUSED_SYMBOL);
|
||||
problemClassElement.setAttribute("severity", severity.myName);
|
||||
problemClassElement.setAttribute("attribute_key", attributeKey);
|
||||
}
|
||||
|
||||
+11
@@ -6,8 +6,10 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.listeners.RefactoringElementListener;
|
||||
import com.intellij.refactoring.util.RefactoringConflictsUtil;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -99,6 +101,15 @@ public class JavaMoveDirectoryWithClassesHelper extends MoveDirectoryWithClasses
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preprocessUsages(Project project,
|
||||
Set<PsiFile> files,
|
||||
UsageInfo[] infos,
|
||||
PsiDirectory directory,
|
||||
MultiMap<PsiElement, String> conflicts) {
|
||||
RefactoringConflictsUtil.analyzeModuleConflicts(project, files, infos, directory, conflicts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeMove(PsiFile psiFile) {
|
||||
ChangeContextUtil.encodeContextInfo(psiFile, true);
|
||||
|
||||
+19
-8
@@ -33,18 +33,15 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.refactoring.HelpID;
|
||||
import com.intellij.refactoring.JavaRefactoringSettings;
|
||||
import com.intellij.refactoring.PackageWrapper;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.*;
|
||||
import com.intellij.refactoring.move.MoveCallback;
|
||||
import com.intellij.refactoring.rename.DirectoryAsPackageRenameHandlerBase;
|
||||
import com.intellij.refactoring.rename.RenameUtil;
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.refactoring.util.RefactoringUIUtil;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.refactoring.util.TextOccurrencesUtil;
|
||||
import com.intellij.refactoring.ui.ConflictsDialog;
|
||||
import com.intellij.refactoring.util.*;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -326,6 +323,20 @@ public class MoveClassesOrPackagesImpl {
|
||||
if (!chooser.isOK()) return;
|
||||
final PsiDirectory selectedTarget = chooser.getSelectedDirectory();
|
||||
if (selectedTarget == null) return;
|
||||
final MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
|
||||
RefactoringConflictsUtil.analyzeModuleConflicts(project, Arrays.asList(directories), UsageInfo.EMPTY_ARRAY, selectedTarget, conflicts);
|
||||
if (!conflicts.isEmpty()) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
throw new BaseRefactoringProcessor.ConflictsInTestsException(conflicts.values());
|
||||
}
|
||||
else {
|
||||
final ConflictsDialog conflictsDialog = new ConflictsDialog(project, conflicts);
|
||||
conflictsDialog.show();
|
||||
if (!conflictsDialog.isOK()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
final Ref<IncorrectOperationException> ex = Ref.create(null);
|
||||
final String commandDescription = RefactoringBundle.message("moving.directories.command");
|
||||
Runnable runnable = new Runnable() {
|
||||
|
||||
@@ -227,7 +227,7 @@ public class RefactoringConflictsUtil {
|
||||
final MultiMap<PsiElement, String> conflicts) {
|
||||
if (scopes == null) return;
|
||||
for (final PsiElement scope : scopes) {
|
||||
if (scope instanceof PsiPackage || scope instanceof PsiDirectory) return;
|
||||
if (scope instanceof PsiPackage) return;
|
||||
}
|
||||
|
||||
final Module targetModule = ModuleUtil.findModuleForFile(vFile, project);
|
||||
|
||||
+8
-3
@@ -32,6 +32,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class ClassResolverProcessor extends BaseScopeProcessor implements NameHint, ElementClassHint {
|
||||
private static final String[] DEFAULT_PACKAGES = new String[]{CommonClassNames.DEFAULT_PACKAGE};
|
||||
private final String myClassName;
|
||||
private final PsiElement myPlace;
|
||||
private PsiClass myAccessClass = null;
|
||||
@@ -108,12 +109,16 @@ public class ClassResolverProcessor extends BaseScopeProcessor implements NameHi
|
||||
|
||||
String fqn = psiClass.getQualifiedName();
|
||||
if (fqn == null) return false;
|
||||
|
||||
PsiFile file = myPlace == null ? null : FileContextUtil.getContextFile(myPlace);
|
||||
|
||||
String[] defaultPackages = file instanceof PsiJavaFile ? ((PsiJavaFile)file).getImplicitlyImportedPackages() : DEFAULT_PACKAGES;
|
||||
String packageName = StringUtil.getPackageName(fqn);
|
||||
if (CommonClassNames.DEFAULT_PACKAGE.equals(packageName)) return true;
|
||||
for (String defaultPackage : defaultPackages) {
|
||||
if (defaultPackage.equals(packageName)) return true;
|
||||
}
|
||||
|
||||
// class from my package imported implicitly
|
||||
PsiFile file = myPlace == null ? null : FileContextUtil.getContextFile(myPlace);
|
||||
|
||||
return file instanceof PsiJavaFile && ((PsiJavaFile)file).getPackageName().equals(packageName);
|
||||
}
|
||||
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
public class Bar {
|
||||
private Object field;
|
||||
private final Object lock = new Object();
|
||||
|
||||
public void main() {
|
||||
synchronized (lock) {
|
||||
if (field != null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
synchronized (lock) {
|
||||
if (field != null) {
|
||||
return;
|
||||
}
|
||||
if (<warning descr="Condition 'field == null' is always 'true'">field == null</warning>) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class Main {
|
||||
static class User {
|
||||
public int RegistrationState;
|
||||
}
|
||||
|
||||
public static void fun(User user) {
|
||||
if ((user.RegistrationState == 5 || user.RegistrationState == 10) == true) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import java.util.List;
|
||||
|
||||
public class Foo {
|
||||
public void matchAfterFragment(int patternIndex, int matchLen) {
|
||||
int star = patternIndex < matchLen ? matchLen : -1;
|
||||
while (matchLen > 0) {
|
||||
int i = matchLen == star ? matchLen : star;
|
||||
}
|
||||
}
|
||||
|
||||
public void matchAfterFragmentBoxed(Integer patternIndex, Integer matchLen) {
|
||||
Integer star = patternIndex < matchLen ? matchLen : -1;
|
||||
while (matchLen > 0) {
|
||||
Integer i = matchLen == star ? matchLen : star;
|
||||
}
|
||||
}
|
||||
|
||||
public void matchAfterFragmentSemiBoxed(Integer patternIndex, Integer matchLen) {
|
||||
int star = patternIndex < matchLen ? matchLen : -1;
|
||||
while (matchLen > 0) {
|
||||
Integer i = matchLen == star ? matchLen : star;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
public class Bar {
|
||||
public static void main(String[] args) {
|
||||
for (String s : args) {
|
||||
try {
|
||||
System.out.println(s);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-1
@@ -50,7 +50,13 @@ public class DataFlowInspectionFixtureTest extends JavaCodeInsightFixtureTestCas
|
||||
public void testFieldInAnonymous() throws Throwable { doTest(); }
|
||||
public void testNullableField() throws Throwable { doTest(); }
|
||||
public void testCanBeNullDoesntImplyIsNull() throws Throwable { doTest(); }
|
||||
/*public void testAnnReport() throws Throwable { doTest(); }*/
|
||||
public void testAnnReport() throws Throwable { doTest(); }
|
||||
|
||||
public void testBigMethodNotComplex() throws Throwable { doTest(); }
|
||||
public void testTernaryInWhileNotComplex() throws Throwable { doTest(); }
|
||||
public void testTryCatchInForNotComplex() throws Throwable { doTest(); }
|
||||
public void testFieldChangedBetweenSynchronizedBlocks() throws Throwable { doTest(); }
|
||||
|
||||
public void testIDEA84489() throws Throwable { doTest(); }
|
||||
|
||||
}
|
||||
|
||||
@@ -9,9 +9,12 @@
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.slice.SliceTreeTest;
|
||||
import com.intellij.codeInspection.dataFlow.DataFlowInspection;
|
||||
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
|
||||
import com.intellij.testFramework.InspectionTestCase;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
public class DataFlowInspectionTest extends InspectionTestCase {
|
||||
@@ -148,4 +151,13 @@ public class DataFlowInspectionTest extends InspectionTestCase {
|
||||
|
||||
//public void testIDEADEV11033() throws Exception { doTest15(); }
|
||||
public void testSwitchEnumCases() throws Exception { doTest15(); }
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite();
|
||||
suite.addTestSuite(DataFlowInspectionFixtureTest.class);
|
||||
suite.addTestSuite(DataFlowInspectionTest.class);
|
||||
suite.addTestSuite(SliceTreeTest.class);
|
||||
return suite;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
-1
@@ -97,6 +97,12 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler {
|
||||
myStartOffset = selectionModel.getSelectionStart();
|
||||
myEndOffset = selectionModel.getSelectionEnd();
|
||||
|
||||
FoldRegion fold = myEditor.getFoldingModel().getCollapsedRegionAtOffset(myStartOffset);
|
||||
if (fold != null && fold.shouldNeverExpand() && fold.getStartOffset() == myStartOffset && fold.getEndOffset() == myEndOffset) {
|
||||
// Foldings that never expand are automatically selected, so the fact it is selected must not interfer with commenter's logic
|
||||
hasSelection = false;
|
||||
}
|
||||
|
||||
if (myDocument.getTextLength() == 0) return;
|
||||
|
||||
while (true) {
|
||||
@@ -648,4 +654,4 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1520,7 +1520,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable
|
||||
public Dimension preferredLayoutSize(@Nullable Container parent) {
|
||||
int maxCellWidth = myLookupTextWidth + myCellRenderer.getIconIndent();
|
||||
int scrollBarWidth = myScrollPane.getPreferredSize().width - myScrollPane.getViewport().getPreferredSize().width;
|
||||
int listWidth = Math.min(scrollBarWidth + maxCellWidth, UISettings.getInstance().MAX_LOOKUP_WIDTH);
|
||||
int listWidth = Math.min(scrollBarWidth + maxCellWidth, UISettings.getInstance().MAX_LOOKUP_WIDTH2);
|
||||
int adWidth = myAdComponent.getAdComponent().getPreferredSize().width;
|
||||
return new Dimension(Math.max(listWidth, adWidth),
|
||||
Math.min(mainPanel.getPreferredSize().height, myMaximumHeight));
|
||||
@@ -1535,7 +1535,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable
|
||||
if (!myResizePending) {
|
||||
Dimension preferredSize = preferredLayoutSize(null);
|
||||
if (preferredSize.width != size.width) {
|
||||
UISettings.getInstance().MAX_LOOKUP_WIDTH = Math.max(300, size.width);
|
||||
UISettings.getInstance().MAX_LOOKUP_WIDTH2 = Math.max(500, size.width);
|
||||
}
|
||||
|
||||
int listHeight = myList.getLastVisibleIndex() - myList.getFirstVisibleIndex() + 1;
|
||||
|
||||
+1
-1
@@ -290,7 +290,7 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem
|
||||
ProblemHighlightType problemHighlightType = description instanceof ProblemDescriptor
|
||||
? ((ProblemDescriptor)description).getHighlightType()
|
||||
: ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
|
||||
final String attributeKey = getTextAttributeKey(refElement.getElement().getProject(), severity, problemHighlightType);
|
||||
final String attributeKey = getTextAttributeKey(refElement.getRefManager().getProject(), severity, problemHighlightType);
|
||||
problemClassElement.setAttribute("severity", severity.myName);
|
||||
problemClassElement.setAttribute("attribute_key", attributeKey);
|
||||
}
|
||||
|
||||
+6
-1
@@ -337,7 +337,12 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G
|
||||
for (Element element : globalTools.keySet()) {
|
||||
final Tools tools = globalTools.get(element);
|
||||
for (ScopeToolState state : tools.getTools()) {
|
||||
((InspectionTool)state.getTool()).exportResults(element, refEntity);
|
||||
try {
|
||||
((InspectionTool)state.getTool()).exportResults(element, refEntity);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error("Problem when exporting: " + refEntity.getExternalName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ public abstract class InspectionTool extends InspectionProfileEntry {
|
||||
}
|
||||
|
||||
protected HighlightSeverity getCurrentSeverity(RefElement element) {
|
||||
final PsiElement psiElement = element.getElement();
|
||||
final PsiElement psiElement = element.getPointer().getContainingFile();
|
||||
if (psiElement != null) {
|
||||
if (myContext != null) {
|
||||
final Tools tools = myContext.getTools().get(getShortName());
|
||||
|
||||
+8
@@ -11,12 +11,14 @@ import com.intellij.refactoring.move.moveFilesOrDirectories.MoveFileHandler;
|
||||
import com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectoriesUtil;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author ksafonov
|
||||
@@ -40,6 +42,12 @@ public abstract class MoveDirectoryWithClassesHelper {
|
||||
|
||||
public abstract void afterMove(PsiElement newElement);
|
||||
|
||||
public void preprocessUsages(Project project,
|
||||
Set<PsiFile> files,
|
||||
UsageInfo[] infos,
|
||||
PsiDirectory directory,
|
||||
MultiMap<PsiElement, String> conflicts) {}
|
||||
|
||||
public static MoveDirectoryWithClassesHelper[] findAll() {
|
||||
return Extensions.getExtensions(EP_NAME);
|
||||
}
|
||||
|
||||
+3
@@ -123,6 +123,9 @@ public class MoveDirectoryWithClassesProcessor extends BaseRefactoringProcessor
|
||||
conflicts.putValue(psiFile, e.getMessage());
|
||||
}
|
||||
}
|
||||
for (MoveDirectoryWithClassesHelper helper : MoveDirectoryWithClassesHelper.findAll()) {
|
||||
helper.preprocessUsages(myProject, myFilesToMove.keySet(), refUsages.get(), myTargetDirectory, conflicts);
|
||||
}
|
||||
return showConflicts(conflicts, refUsages.get());
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public class UISettings implements PersistentStateComponent<UISettings>, Exporta
|
||||
public boolean DISABLE_MNEMONICS = SystemInfo.isMac; // IDEADEV-33409, should be disabled by default on MacOS
|
||||
public boolean DISABLE_MNEMONICS_IN_CONTROLS = false;
|
||||
public boolean SORT_LOOKUP_ELEMENTS_LEXICOGRAPHICALLY = false;
|
||||
public int MAX_LOOKUP_WIDTH = 500;
|
||||
public int MAX_LOOKUP_WIDTH2 = 500;
|
||||
public int MAX_LOOKUP_LIST_HEIGHT = 11;
|
||||
public boolean HIDE_NAVIGATION_ON_FOCUS_LOSS = true;
|
||||
|
||||
|
||||
@@ -196,6 +196,7 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
|
||||
for (CaretListener listener : myCaretListeners) {
|
||||
listener.caretPositionChanged(event);
|
||||
}
|
||||
EditorActionUtil.selectNonexpandableFold(myEditor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,6 +238,7 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
|
||||
for (CaretListener listener : myCaretListeners) {
|
||||
listener.caretPositionChanged(event);
|
||||
}
|
||||
EditorActionUtil.selectNonexpandableFold(myEditor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,8 +64,8 @@ public class Win32Kernel {
|
||||
return ArrayUtil.toStringArray(names);
|
||||
}
|
||||
|
||||
public boolean exists(String path) {
|
||||
return doGetInfo(path) != null;
|
||||
public void exists(String path) throws FileNotFoundException {
|
||||
getInfo(path);
|
||||
}
|
||||
|
||||
public boolean isDirectory(String path) throws FileNotFoundException {
|
||||
@@ -88,6 +88,7 @@ public class Win32Kernel {
|
||||
return getInfo(path).length;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private FileInfo getInfo(String path) throws FileNotFoundException {
|
||||
FileInfo info = doGetInfo(path);
|
||||
if (info == null) {
|
||||
@@ -110,20 +111,21 @@ public class Win32Kernel {
|
||||
}
|
||||
|
||||
@FileUtil.FileBooleanAttributes
|
||||
public int getBooleanAttributes(@NotNull String path, @FileUtil.FileBooleanAttributes int flags) {
|
||||
FileInfo info = doGetInfo(path);
|
||||
public int getBooleanAttributes(@NotNull String path, @FileUtil.FileBooleanAttributes int flags) throws FileNotFoundException {
|
||||
FileInfo info = getInfo(path);
|
||||
int result = 0;
|
||||
if ((flags & FileUtil.BA_EXISTS) != 0) {
|
||||
result |= info == null ? 0 : FileUtil.BA_EXISTS;
|
||||
result |= FileUtil.BA_EXISTS;
|
||||
}
|
||||
if ((flags & FileUtil.BA_DIRECTORY) != 0) {
|
||||
result |= info == null || (info.attributes & FILE_ATTRIBUTE_DIRECTORY) == 0 ? 0 : FileUtil.BA_DIRECTORY;
|
||||
result |= (info.attributes & FILE_ATTRIBUTE_DIRECTORY) == 0 ? 0 : FileUtil.BA_DIRECTORY;
|
||||
}
|
||||
if ((flags & FileUtil.BA_REGULAR) != 0) {
|
||||
result |= info == null || (info.attributes & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE | FILE_ATTRIBUTE_REPARSE_POINT)) != 0 ? 0 : FileUtil.BA_REGULAR;
|
||||
result |= (info.attributes & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE | FILE_ATTRIBUTE_REPARSE_POINT)) != 0
|
||||
? 0 : FileUtil.BA_REGULAR;
|
||||
}
|
||||
if ((flags & FileUtil.BA_HIDDEN) != 0) {
|
||||
result |= info == null || (info.attributes & FILE_ATTRIBUTE_HIDDEN) == 0 ? 0 : FileUtil.BA_HIDDEN;
|
||||
result |= (info.attributes & FILE_ATTRIBUTE_HIDDEN) == 0 ? 0 : FileUtil.BA_HIDDEN;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+15
-5
@@ -118,11 +118,16 @@ public class Win32LocalFileSystem extends LocalFileSystemBase {
|
||||
@Override
|
||||
public boolean exists(@NotNull VirtualFile fileOrDirectory) {
|
||||
if (fileOrDirectory.getParent() == null) return true;
|
||||
boolean b = myKernel.exists(fileOrDirectory.getPath());
|
||||
if (checkMe && b != super.exists(fileOrDirectory)) {
|
||||
LOG.error(fileOrDirectory.getPath());
|
||||
try {
|
||||
myKernel.exists(fileOrDirectory.getPath());
|
||||
if (checkMe && !super.exists(fileOrDirectory)) {
|
||||
LOG.error(fileOrDirectory.getPath());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
return super.exists(fileOrDirectory);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -199,7 +204,12 @@ public class Win32LocalFileSystem extends LocalFileSystemBase {
|
||||
|
||||
@Override
|
||||
public int getBooleanAttributes(@NotNull VirtualFile file, int flags) {
|
||||
return myKernel.getBooleanAttributes(file.getPath(), flags);
|
||||
try {
|
||||
return myKernel.getBooleanAttributes(file.getPath(), flags);
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
return super.getBooleanAttributes(file, flags);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -223,8 +223,6 @@ public class MacFileChooserDialogImpl implements PathChooserDialog {
|
||||
directory, file, types, focusedWindow, self, Foundation.createSelector("openPanelDidEnd:returnCode:contextInfo:"), null);
|
||||
}
|
||||
}
|
||||
|
||||
Foundation.cfRelease(directory, file, types);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+16
-4
@@ -20,11 +20,9 @@ import com.intellij.ide.GeneralSettings;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.SafeWriteRequestor;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.openapi.vfs.newvfs.ManagingFS;
|
||||
import com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem;
|
||||
import com.intellij.openapi.vfs.newvfs.RefreshQueue;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent;
|
||||
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS;
|
||||
@@ -323,4 +321,18 @@ public class LocalFileSystemTest extends PlatformLangTestCase {
|
||||
FileUtil.delete(dir);
|
||||
}
|
||||
}
|
||||
|
||||
public void testWindowsVirtualDirectory() throws Exception {
|
||||
if (!SystemInfo.isWindows) return;
|
||||
File file = new File("c:\\Documents and Settings\\desktop.ini");
|
||||
VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
|
||||
assertNotNull("File not found: " + file, virtualFile);
|
||||
|
||||
NewVirtualFileSystem system = (NewVirtualFileSystem)virtualFile.getFileSystem();
|
||||
system = PersistentFS.replaceWithNativeFS(system);
|
||||
|
||||
assertTrue(system.exists(virtualFile));
|
||||
int childAttributes = system.getBooleanAttributes(virtualFile, -1);
|
||||
assertTrue((childAttributes & FileUtil.BA_EXISTS) != 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,6 +354,7 @@
|
||||
<antCustomCompiler implementation="org.jetbrains.plugins.groovy.ant.GroovyAntCustomCompilerProvider"/>
|
||||
|
||||
<project.converterProvider implementation="org.jetbrains.plugins.groovy.config.GroovyModuleConverterProvider"/>
|
||||
<project.converterProvider implementation="org.jetbrains.plugins.groovy.config.GroovyRunConfigurationConverterProvider"/>
|
||||
|
||||
<iconProvider implementation="org.jetbrains.plugins.groovy.GroovyIconProvider"/>
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class GroovyProjectConverter extends ProjectConverter {
|
||||
}
|
||||
else {
|
||||
element.setAttribute("type", wasGrails ? GRAILS_RUN_CONFIGURATION_TYPE : "GroovyScriptRunConfiguration");
|
||||
element.setAttribute("factoryName", wasGrails ? "Grails" : "Groovy Script");
|
||||
element.setAttribute("factoryName", wasGrails ? "Grails" : "Groovy");
|
||||
}
|
||||
}
|
||||
else if (GRAILS_RUN_CONFIGURATION_TYPE.equals(confType) &&
|
||||
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.plugins.groovy.config;
|
||||
|
||||
import com.intellij.conversion.*;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class GroovyRunConfigurationConverterProvider extends ConverterProvider {
|
||||
public GroovyRunConfigurationConverterProvider() {
|
||||
super("groovy-script-run-configurations");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getConversionDescription() {
|
||||
return "Groovy Script run configurations will be converted into a new format";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ProjectConverter createConverter(@NotNull ConversionContext context) {
|
||||
return new ProjectConverter() {
|
||||
@Override
|
||||
public ConversionProcessor<RunManagerSettings> createRunConfigurationsConverter() {
|
||||
return new ConversionProcessor<RunManagerSettings>() {
|
||||
@Override
|
||||
public boolean isConversionNeeded(RunManagerSettings settings) {
|
||||
for (Element element : settings.getRunConfigurations()) {
|
||||
if ("Groovy Script".equals(element.getAttributeValue("factoryName"))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(RunManagerSettings settings) throws CannotConvertException {
|
||||
for (Element element : settings.getRunConfigurations()) {
|
||||
if ("Groovy Script".equals(element.getAttributeValue("factoryName"))) {
|
||||
element.setAttribute("factoryName", "Groovy");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ package org.jetbrains.idea.maven.execution;
|
||||
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.maven.project.MavenConsole;
|
||||
import org.jetbrains.idea.maven.project.MavenGeneralSettings;
|
||||
import org.jetbrains.idea.maven.server.MavenServerConsole;
|
||||
@@ -28,8 +29,6 @@ import java.text.MessageFormat;
|
||||
|
||||
public abstract class MavenExecutor {
|
||||
final MavenRunnerParameters myParameters;
|
||||
final MavenGeneralSettings myCoreSettings;
|
||||
final MavenRunnerSettings myRunnerSettings;
|
||||
private final String myCaption;
|
||||
protected MavenConsole myConsole;
|
||||
private String myAction;
|
||||
@@ -39,13 +38,9 @@ public abstract class MavenExecutor {
|
||||
private int exitCode = 0;
|
||||
|
||||
public MavenExecutor(MavenRunnerParameters parameters,
|
||||
MavenGeneralSettings coreSettings,
|
||||
MavenRunnerSettings runnerSettings,
|
||||
String caption,
|
||||
MavenConsole console) {
|
||||
myParameters = parameters;
|
||||
myCoreSettings = coreSettings;
|
||||
myRunnerSettings = runnerSettings;
|
||||
myCaption = caption;
|
||||
myConsole = console;
|
||||
}
|
||||
@@ -58,7 +53,7 @@ public abstract class MavenExecutor {
|
||||
return myConsole;
|
||||
}
|
||||
|
||||
public void setAction(final String action) {
|
||||
public void setAction(@Nullable final String action) {
|
||||
myAction = action;
|
||||
}
|
||||
|
||||
@@ -113,5 +108,5 @@ public abstract class MavenExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
public abstract boolean execute(ProgressIndicator indicator);
|
||||
public abstract boolean execute(@Nullable ProgressIndicator indicator);
|
||||
}
|
||||
|
||||
+24
-10
@@ -19,6 +19,7 @@
|
||||
package org.jetbrains.idea.maven.execution;
|
||||
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.configurations.JavaParameters;
|
||||
import com.intellij.execution.process.DefaultJavaProcessHandler;
|
||||
import com.intellij.execution.process.OSProcessHandler;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -26,6 +27,8 @@ import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.maven.project.MavenConsole;
|
||||
import org.jetbrains.idea.maven.project.MavenGeneralSettings;
|
||||
import org.jetbrains.idea.maven.server.MavenServerConsole;
|
||||
@@ -36,24 +39,35 @@ public class MavenExternalExecutor extends MavenExecutor {
|
||||
|
||||
@NonNls private static final String PHASE_INFO_REGEXP = "\\[INFO\\] \\[.*:.*\\]";
|
||||
@NonNls private static final int INFO_PREFIX_SIZE = "[INFO] ".length();
|
||||
private final Project myProject;
|
||||
|
||||
private JavaParameters myJavaParameters;
|
||||
private ExecutionException myParameterCreationError;
|
||||
|
||||
public MavenExternalExecutor(Project project,
|
||||
MavenRunnerParameters parameters,
|
||||
MavenGeneralSettings coreSettings,
|
||||
MavenRunnerSettings runnerSettings,
|
||||
MavenConsole console) {
|
||||
super(parameters, coreSettings, runnerSettings, RunnerBundle.message("external.executor.caption"), console);
|
||||
myProject = project;
|
||||
@NotNull MavenRunnerParameters parameters,
|
||||
@Nullable MavenGeneralSettings coreSettings,
|
||||
@Nullable MavenRunnerSettings runnerSettings,
|
||||
@NotNull MavenConsole console) {
|
||||
super(parameters, RunnerBundle.message("external.executor.caption"), console);
|
||||
|
||||
try {
|
||||
myJavaParameters = MavenExternalParameters.createJavaParameters(project, myParameters, coreSettings, runnerSettings);
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
myParameterCreationError = e;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean execute(final ProgressIndicator indicator) {
|
||||
displayProgress();
|
||||
|
||||
try {
|
||||
if (myParameterCreationError != null) {
|
||||
throw myParameterCreationError;
|
||||
}
|
||||
|
||||
myProcessHandler =
|
||||
new DefaultJavaProcessHandler(
|
||||
MavenExternalParameters.createJavaParameters(myProject, myParameters, myCoreSettings, myRunnerSettings)) {
|
||||
new DefaultJavaProcessHandler(myJavaParameters) {
|
||||
public void notifyTextAvailable(String text, Key outputType) {
|
||||
// todo move this logic to ConsoleAdapter class
|
||||
if (!myConsole.isSuppressed(text)) {
|
||||
@@ -91,7 +105,7 @@ public class MavenExternalExecutor extends MavenExecutor {
|
||||
myProcessHandler.waitFor();
|
||||
}
|
||||
|
||||
private void updateProgress(final ProgressIndicator indicator, final String text) {
|
||||
private void updateProgress(@Nullable final ProgressIndicator indicator, final String text) {
|
||||
if (indicator != null) {
|
||||
if (indicator.isCanceled()) {
|
||||
if (!isCancelled()) {
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ public class MavenResumeAction extends AnAction {
|
||||
case STATE_WAIT_FOR_BUILD:
|
||||
if (textWithoutInfo.startsWith("Building ")) {
|
||||
String projectName = textWithoutInfo.substring("Building ".length());
|
||||
if (myBuildingProjectIndex > myMavenProjectNames.size() ||
|
||||
if (myBuildingProjectIndex >= myMavenProjectNames.size() ||
|
||||
!projectName.startsWith(myMavenProjectNames.get(myBuildingProjectIndex))) {
|
||||
myState = STATE_WTF;
|
||||
log(String.format("Invalid project building order. Defined order: %s, error index: %d, invalid line: %s",
|
||||
|
||||
@@ -15,18 +15,20 @@
|
||||
*/
|
||||
package org.jetbrains.idea.maven.execution;
|
||||
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.maven.project.MavenConsole;
|
||||
@@ -39,6 +41,9 @@ import java.util.List;
|
||||
|
||||
@State(name = "MavenRunner", storages = {@Storage( file = "$WORKSPACE_FILE$")})
|
||||
public class MavenRunner implements PersistentStateComponent<MavenRunnerSettings> {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.idea.maven.execution.MavenRunner");
|
||||
|
||||
private MavenRunnerSettings mySettings = new MavenRunnerSettings();
|
||||
private final Project myProject;
|
||||
|
||||
@@ -65,10 +70,9 @@ public class MavenRunner implements PersistentStateComponent<MavenRunnerSettings
|
||||
public void run(final MavenRunnerParameters parameters, final MavenRunnerSettings settings, final Runnable onComplete) {
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
|
||||
final MavenConsole console = createConsole(getGeneralSettings(),
|
||||
Pair.create(parameters, settings));
|
||||
final MavenConsole console = createConsole();
|
||||
try {
|
||||
final MavenExecutor[] executor = new MavenExecutor[]{createExecutor(parameters, getGeneralSettings(), settings, console)};
|
||||
final MavenExecutor[] executor = new MavenExecutor[]{createExecutor(parameters, null, settings, console)};
|
||||
|
||||
ProgressManager.getInstance().run(new Task.Backgroundable(myProject, executor[0].getCaption(), true) {
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
@@ -114,21 +118,26 @@ public class MavenRunner implements PersistentStateComponent<MavenRunnerSettings
|
||||
}
|
||||
}
|
||||
|
||||
private MavenGeneralSettings getGeneralSettings() {
|
||||
return MavenProjectsManager.getInstance(myProject).getGeneralSettings();
|
||||
}
|
||||
|
||||
public boolean runBatch(List<MavenRunnerParameters> commands,
|
||||
@Nullable MavenGeneralSettings coreSettings,
|
||||
@Nullable MavenRunnerSettings runnerSettings,
|
||||
@Nullable final String action,
|
||||
ProgressIndicator indicator) {
|
||||
@Nullable ProgressIndicator indicator) {
|
||||
LOG.assertTrue(!ApplicationManager.getApplication().isReadAccessAllowed());
|
||||
|
||||
if (commands.isEmpty()) return true;
|
||||
|
||||
final MavenGeneralSettings effectiveCoreSettings = coreSettings != null ? coreSettings : getGeneralSettings();
|
||||
final MavenRunnerSettings effectiveRunnerSettings = runnerSettings != null ? runnerSettings : getState();
|
||||
MavenConsole console;
|
||||
|
||||
AccessToken accessToken = ReadAction.start();
|
||||
try {
|
||||
if (myProject.isDisposed()) return false;
|
||||
console = createConsole();
|
||||
}
|
||||
finally {
|
||||
accessToken.finish();
|
||||
}
|
||||
|
||||
MavenConsole console = createConsole(effectiveCoreSettings, null);
|
||||
try {
|
||||
int count = 0;
|
||||
for (MavenRunnerParameters command : commands) {
|
||||
@@ -136,7 +145,17 @@ public class MavenRunner implements PersistentStateComponent<MavenRunnerSettings
|
||||
indicator.setFraction(((double)count++) / commands.size());
|
||||
}
|
||||
|
||||
MavenExecutor executor = createExecutor(command, effectiveCoreSettings, effectiveRunnerSettings, console);
|
||||
MavenExecutor executor;
|
||||
|
||||
accessToken = ReadAction.start();
|
||||
try {
|
||||
if (myProject.isDisposed()) break;
|
||||
executor = createExecutor(command, coreSettings, runnerSettings, console);
|
||||
}
|
||||
finally {
|
||||
accessToken.finish();
|
||||
}
|
||||
|
||||
executor.setAction(action);
|
||||
if (!executor.execute(indicator)) {
|
||||
updateTargetFolders();
|
||||
@@ -158,8 +177,7 @@ public class MavenRunner implements PersistentStateComponent<MavenRunnerSettings
|
||||
MavenProjectsManager.getInstance(myProject).updateProjectTargetFolders();
|
||||
}
|
||||
|
||||
private MavenConsole createConsole(MavenGeneralSettings coreSettings,
|
||||
Pair<MavenRunnerParameters, MavenRunnerSettings> parametersAndSettings) {
|
||||
private MavenConsole createConsole() {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
return new SoutMavenConsole();
|
||||
}
|
||||
@@ -167,8 +185,8 @@ public class MavenRunner implements PersistentStateComponent<MavenRunnerSettings
|
||||
}
|
||||
|
||||
private MavenExecutor createExecutor(MavenRunnerParameters taskParameters,
|
||||
MavenGeneralSettings coreSettings,
|
||||
MavenRunnerSettings runnerSettings,
|
||||
@Nullable MavenGeneralSettings coreSettings,
|
||||
@Nullable MavenRunnerSettings runnerSettings,
|
||||
MavenConsole console) {
|
||||
return new MavenExternalExecutor(myProject, taskParameters, coreSettings, runnerSettings, console);
|
||||
}
|
||||
|
||||
+12
-6
@@ -31,6 +31,7 @@ import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.maven.execution.MavenRunner;
|
||||
import org.jetbrains.idea.maven.execution.MavenRunnerParameters;
|
||||
import org.jetbrains.idea.maven.navigator.SelectMavenGoalDialog;
|
||||
@@ -40,6 +41,7 @@ import org.jetbrains.idea.maven.utils.MavenIcons;
|
||||
import org.jetbrains.idea.maven.utils.MavenLog;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class MavenBeforeRunTasksProvider extends BeforeRunTaskProvider<MavenBeforeRunTask> {
|
||||
@@ -76,6 +78,7 @@ public class MavenBeforeRunTasksProvider extends BeforeRunTaskProvider<MavenBefo
|
||||
: TasksBundle.message("maven.tasks.before.run", desc);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Pair<MavenProject, String> getProjectAndGoalChecked(MavenBeforeRunTask task) {
|
||||
String path = task.getProjectPath();
|
||||
String goal = task.getGoal();
|
||||
@@ -129,6 +132,9 @@ public class MavenBeforeRunTasksProvider extends BeforeRunTaskProvider<MavenBefo
|
||||
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
|
||||
final Collection<String> explicitProfiles = MavenProjectsManager.getInstance(project).getExplicitProfiles();
|
||||
final MavenRunner mavenRunner = MavenRunner.getInstance(project);
|
||||
|
||||
targetDone.down();
|
||||
new Task.Backgroundable(project, TasksBundle.message("maven.tasks.executing"), true) {
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
@@ -137,13 +143,13 @@ public class MavenBeforeRunTasksProvider extends BeforeRunTaskProvider<MavenBefo
|
||||
true,
|
||||
projectAndGoal.first.getDirectory(),
|
||||
Collections.singletonList(projectAndGoal.second),
|
||||
MavenProjectsManager.getInstance(project).getExplicitProfiles());
|
||||
explicitProfiles);
|
||||
|
||||
result[0] = MavenRunner.getInstance(project).runBatch(Collections.singletonList(params),
|
||||
null,
|
||||
null,
|
||||
TasksBundle.message("maven.tasks.executing"),
|
||||
indicator);
|
||||
result[0] = mavenRunner.runBatch(Collections.singletonList(params),
|
||||
null,
|
||||
null,
|
||||
TasksBundle.message("maven.tasks.executing"),
|
||||
indicator);
|
||||
}
|
||||
finally {
|
||||
targetDone.up();
|
||||
|
||||
+4
@@ -356,6 +356,10 @@ public class DefaultFunctionContext extends AbstractFunctionContext {
|
||||
decls.put(Pair.create(new QName(null, value.getName()), value.getParameters().length), value);
|
||||
}
|
||||
|
||||
public static void addFunction(Map<Pair<QName, Integer>, Function> decls, String namespace, Function value) {
|
||||
decls.put(Pair.create(new QName(namespace, value.getName()), value.getParameters().length), value);
|
||||
}
|
||||
|
||||
public boolean allowsExtensions() {
|
||||
return false;
|
||||
}
|
||||
|
||||
+77
@@ -38,6 +38,13 @@ public class XsltFunctionContext extends DefaultFunctionContext {
|
||||
}
|
||||
};
|
||||
|
||||
public static final String EXSLT_DATE_TIME = "http://exslt.org/dates-and-times";
|
||||
public static final String EXSLT_COMMON = "http://exslt.org/common";
|
||||
public static final String EXSLT_MATH = "http://exslt.org/math";
|
||||
public static final String EXSLT_SETS = "http://exslt.org/sets";
|
||||
public static final String EXSLT_DYNAMIC = "http://exslt.org/dynamic";
|
||||
public static final String EXSLT_STRINGS = "http://exslt.org/strings";
|
||||
|
||||
static {
|
||||
final Map<Pair<QName, Integer>, Function> decls = new HashMap<Pair<QName, Integer>, Function>();
|
||||
|
||||
@@ -75,6 +82,76 @@ public class XsltFunctionContext extends DefaultFunctionContext {
|
||||
// node-set current()
|
||||
addFunction(decls, new FunctionImpl("current", XPathType.NODESET));
|
||||
|
||||
final Parameter optional_string = new Parameter(XPathType.STRING, Parameter.Kind.OPTIONAL);
|
||||
final Parameter required_string = new Parameter(XPathType.STRING, Parameter.Kind.REQUIRED);
|
||||
final Parameter required_nodeset = new Parameter(XPathType.NODESET, Parameter.Kind.REQUIRED);
|
||||
final Parameter required_number = new Parameter(XPathType.NUMBER, Parameter.Kind.REQUIRED);
|
||||
|
||||
// EXSLT (http://www.exslt.org) extensions supported by Xalan & Saxon
|
||||
addFunction(decls, EXSLT_DATE_TIME, new FunctionImpl("date", XPathType.STRING, optional_string));
|
||||
addFunction(decls, EXSLT_DATE_TIME, new FunctionImpl("date-time", XPathType.STRING));
|
||||
addFunction(decls, EXSLT_DATE_TIME, new FunctionImpl("day-abbreviation", XPathType.STRING, optional_string));
|
||||
addFunction(decls, EXSLT_DATE_TIME, new FunctionImpl("day-in-month", XPathType.NUMBER, optional_string));
|
||||
addFunction(decls, EXSLT_DATE_TIME, new FunctionImpl("day-in-week", XPathType.NUMBER, optional_string));
|
||||
addFunction(decls, EXSLT_DATE_TIME, new FunctionImpl("day-in-year", XPathType.NUMBER, optional_string));
|
||||
addFunction(decls, EXSLT_DATE_TIME, new FunctionImpl("day-name", XPathType.STRING, optional_string));
|
||||
addFunction(decls, EXSLT_DATE_TIME, new FunctionImpl("day-of-week-in-month", XPathType.NUMBER, optional_string));
|
||||
addFunction(decls, EXSLT_DATE_TIME, new FunctionImpl("hour-in-day", XPathType.NUMBER, optional_string));
|
||||
addFunction(decls, EXSLT_DATE_TIME, new FunctionImpl("leap-year", XPathType.BOOLEAN, optional_string));
|
||||
addFunction(decls, EXSLT_DATE_TIME, new FunctionImpl("minute-in-hour", XPathType.NUMBER, optional_string));
|
||||
addFunction(decls, EXSLT_DATE_TIME, new FunctionImpl("month-abbreviation", XPathType.STRING, optional_string));
|
||||
addFunction(decls, EXSLT_DATE_TIME, new FunctionImpl("month-in-year", XPathType.NUMBER, optional_string));
|
||||
addFunction(decls, EXSLT_DATE_TIME, new FunctionImpl("month-name", XPathType.STRING, optional_string));
|
||||
addFunction(decls, EXSLT_DATE_TIME, new FunctionImpl("second-in-minute", XPathType.NUMBER, optional_string));
|
||||
addFunction(decls, EXSLT_DATE_TIME, new FunctionImpl("time", XPathType.STRING, optional_string));
|
||||
addFunction(decls, EXSLT_DATE_TIME, new FunctionImpl("week-in-year", XPathType.NUMBER, optional_string));
|
||||
addFunction(decls, EXSLT_DATE_TIME, new FunctionImpl("year", XPathType.NUMBER, optional_string));
|
||||
|
||||
addFunction(decls, EXSLT_COMMON, new FunctionImpl("node-set", XPathType.NODESET, new Parameter(XPathType.ANY, Parameter.Kind.REQUIRED)));
|
||||
addFunction(decls, EXSLT_COMMON, new FunctionImpl("object-type", XPathType.STRING, new Parameter(XPathType.ANY, Parameter.Kind.REQUIRED)));
|
||||
|
||||
addFunction(decls, EXSLT_MATH, new FunctionImpl("highest", XPathType.NODESET, required_nodeset));
|
||||
addFunction(decls, EXSLT_MATH, new FunctionImpl("lowest", XPathType.NODESET, required_nodeset));
|
||||
addFunction(decls, EXSLT_MATH, new FunctionImpl("max", XPathType.NUMBER, required_nodeset));
|
||||
addFunction(decls, EXSLT_MATH, new FunctionImpl("min", XPathType.NUMBER, required_nodeset));
|
||||
|
||||
addFunction(decls, EXSLT_MATH, new FunctionImpl("abs", XPathType.NUMBER, required_number));
|
||||
addFunction(decls, EXSLT_MATH, new FunctionImpl("sqrt", XPathType.NUMBER, required_number));
|
||||
addFunction(decls, EXSLT_MATH, new FunctionImpl("log", XPathType.NUMBER, required_number));
|
||||
addFunction(decls, EXSLT_MATH, new FunctionImpl("sin", XPathType.NUMBER, required_number));
|
||||
addFunction(decls, EXSLT_MATH, new FunctionImpl("cos", XPathType.NUMBER, required_number));
|
||||
addFunction(decls, EXSLT_MATH, new FunctionImpl("tan", XPathType.NUMBER, required_number));
|
||||
addFunction(decls, EXSLT_MATH, new FunctionImpl("asin", XPathType.NUMBER, required_number));
|
||||
addFunction(decls, EXSLT_MATH, new FunctionImpl("acos", XPathType.NUMBER, required_number));
|
||||
addFunction(decls, EXSLT_MATH, new FunctionImpl("atan", XPathType.NUMBER, required_number));
|
||||
addFunction(decls, EXSLT_MATH, new FunctionImpl("exp", XPathType.NUMBER, required_number));
|
||||
addFunction(decls, EXSLT_MATH, new FunctionImpl("atan2", XPathType.NUMBER, required_number, required_number));
|
||||
addFunction(decls, EXSLT_MATH, new FunctionImpl("power", XPathType.NUMBER, required_number, required_number));
|
||||
addFunction(decls, EXSLT_MATH, new FunctionImpl("random", XPathType.NUMBER));
|
||||
|
||||
addFunction(decls, EXSLT_MATH, new FunctionImpl("constant", XPathType.NUMBER, required_string, required_number));
|
||||
|
||||
addFunction(decls, EXSLT_SETS, new FunctionImpl("difference", XPathType.NODESET, required_nodeset, required_nodeset));
|
||||
addFunction(decls, EXSLT_SETS, new FunctionImpl("intersection", XPathType.NODESET, required_nodeset, required_nodeset));
|
||||
addFunction(decls, EXSLT_SETS, new FunctionImpl("leading", XPathType.NODESET, required_nodeset, required_nodeset));
|
||||
addFunction(decls, EXSLT_SETS, new FunctionImpl("trailing", XPathType.NODESET, required_nodeset, required_nodeset));
|
||||
addFunction(decls, EXSLT_SETS, new FunctionImpl("has-same-node", XPathType.BOOLEAN, required_nodeset, required_nodeset));
|
||||
addFunction(decls, EXSLT_SETS, new FunctionImpl("distinct", XPathType.NODESET, required_nodeset));
|
||||
|
||||
// Xalan only
|
||||
addFunction(decls, EXSLT_DYNAMIC, new FunctionImpl("evaluate", XPathType.ANY, required_string));
|
||||
addFunction(decls, EXSLT_DYNAMIC, new FunctionImpl("min", XPathType.NUMBER, required_nodeset, required_string));
|
||||
addFunction(decls, EXSLT_DYNAMIC, new FunctionImpl("max", XPathType.NUMBER, required_nodeset, required_string));
|
||||
addFunction(decls, EXSLT_DYNAMIC, new FunctionImpl("sum", XPathType.NUMBER, required_nodeset, required_string));
|
||||
addFunction(decls, EXSLT_DYNAMIC, new FunctionImpl("map", XPathType.NODESET, required_nodeset, required_string));
|
||||
addFunction(decls, EXSLT_DYNAMIC, new FunctionImpl("closure", XPathType.NODESET, required_nodeset, required_string));
|
||||
|
||||
addFunction(decls, EXSLT_STRINGS, new FunctionImpl("align", XPathType.STRING, required_string, required_string, optional_string));
|
||||
addFunction(decls, EXSLT_STRINGS, new FunctionImpl("padding", XPathType.STRING, required_number, optional_string));
|
||||
addFunction(decls, EXSLT_STRINGS, new FunctionImpl("tokenize", XPathType.NODESET, required_string, optional_string));
|
||||
addFunction(decls, EXSLT_STRINGS, new FunctionImpl("split", XPathType.NODESET, required_string, optional_string));
|
||||
|
||||
|
||||
XSLT_FUNCTIONS = Collections.unmodifiableMap(decls);
|
||||
}
|
||||
|
||||
|
||||
+8
@@ -19,6 +19,7 @@ package org.intellij.lang.xpath.xslt.impl;
|
||||
import com.intellij.javaee.ResourceRegistrar;
|
||||
import com.intellij.javaee.StandardResourceProvider;
|
||||
import org.intellij.lang.xpath.xslt.XsltSupport;
|
||||
import org.intellij.lang.xpath.xslt.context.XsltFunctionContext;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
@@ -28,5 +29,12 @@ public class XsltResourceProvider implements StandardResourceProvider {
|
||||
public void registerResources(ResourceRegistrar registrar) {
|
||||
registrar.addStdResource(XsltSupport.XSLT_NS, "/org/intellij/lang/xpath/xslt/resources/xslt-schema.xsd", getClass());
|
||||
registrar.addIgnoredResource(XsltSupport.PLUGIN_EXTENSIONS_NS);
|
||||
|
||||
registrar.addIgnoredResource(XsltFunctionContext.EXSLT_COMMON);
|
||||
registrar.addIgnoredResource(XsltFunctionContext.EXSLT_DATE_TIME);
|
||||
registrar.addIgnoredResource(XsltFunctionContext.EXSLT_DYNAMIC);
|
||||
registrar.addIgnoredResource(XsltFunctionContext.EXSLT_MATH);
|
||||
registrar.addIgnoredResource(XsltFunctionContext.EXSLT_SETS);
|
||||
registrar.addIgnoredResource(XsltFunctionContext.EXSLT_STRINGS);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user