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:
@@ -1,5 +1,5 @@
|
||||
# The file might be automatically updated. Comments and empty lines will be removed.
|
||||
kotlinPluginBuild=1.2.10-release-IJ2017.3-1
|
||||
jetSignBuild=42.30
|
||||
jdkBuild=u152b1102.2
|
||||
jdkBuild=u152b1136.1
|
||||
gradleApiVersion=4.4
|
||||
|
||||
@@ -31,10 +31,10 @@ import com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns;
|
||||
import com.intellij.ui.treeStructure.treetable.TreeColumnInfo;
|
||||
import com.intellij.ui.treeStructure.treetable.TreeTable;
|
||||
import com.intellij.ui.treeStructure.treetable.TreeTableTree;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.EditSourceOnDoubleClickHandler;
|
||||
import com.intellij.util.EditSourceOnEnterKeyHandler;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.TransferToEDTQueue;
|
||||
import com.intellij.util.text.DateFormatUtil;
|
||||
import com.intellij.util.ui.ColumnInfo;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -70,7 +70,6 @@ public class BuildTreeConsoleView implements ConsoleView, DataProvider, BuildCon
|
||||
private final SimpleTreeBuilder myBuilder;
|
||||
private final Map<Object, ExecutionNode> nodesMap = ContainerUtil.newConcurrentMap();
|
||||
private final ExecutionNodeProgressAnimator myProgressAnimator;
|
||||
private Set<Update> myRequests = Collections.synchronizedSet(new HashSet<Update>());
|
||||
|
||||
private final Project myProject;
|
||||
private final SimpleTreeStructure myTreeStructure;
|
||||
@@ -79,7 +78,8 @@ public class BuildTreeConsoleView implements ConsoleView, DataProvider, BuildCon
|
||||
private final String myWorkingDir;
|
||||
private volatile int myTimeColumnWidth;
|
||||
private final AtomicBoolean myDisposed = new AtomicBoolean();
|
||||
private final Alarm myUpdateTreeAlarm;
|
||||
private final TransferToEDTQueue<Runnable> myLaterInvocator =
|
||||
TransferToEDTQueue.createRunnableMerger("BuildTreeConsoleView later invocator");
|
||||
|
||||
public BuildTreeConsoleView(Project project, BuildDescriptor buildDescriptor) {
|
||||
myProject = project;
|
||||
@@ -209,7 +209,6 @@ public class BuildTreeConsoleView implements ConsoleView, DataProvider, BuildCon
|
||||
myPanel.add(myThreeComponentsSplitter, BorderLayout.CENTER);
|
||||
|
||||
myProgressAnimator = new ExecutionNodeProgressAnimator(this);
|
||||
myUpdateTreeAlarm = new Alarm(this);
|
||||
}
|
||||
|
||||
private ExecutionNode getRootElement() {
|
||||
@@ -418,16 +417,14 @@ public class BuildTreeConsoleView implements ConsoleView, DataProvider, BuildCon
|
||||
}
|
||||
|
||||
void scheduleUpdate(ExecutionNode executionNode) {
|
||||
final Update update = new Update(executionNode) {
|
||||
SimpleNode node = executionNode.getParent() == null ? executionNode : executionNode.getParent();
|
||||
final Update update = new Update(node) {
|
||||
@Override
|
||||
public void run() {
|
||||
myRequests.remove(this);
|
||||
myBuilder.queueUpdateFrom(executionNode, false, true);
|
||||
myBuilder.queueUpdateFrom(node, false, true);
|
||||
}
|
||||
};
|
||||
if (myRequests.add(update)) {
|
||||
myUpdateTreeAlarm.addRequest(update, 100);
|
||||
}
|
||||
myLaterInvocator.offerIfAbsent(update);
|
||||
}
|
||||
|
||||
private ExecutionNode createMessageParentNodes(MessageEvent messageEvent, ExecutionNode parentNode) {
|
||||
|
||||
@@ -38,7 +38,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.containers.TransferToEDTQueue;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -61,6 +61,7 @@ public class BuildView extends CompositeView<ExecutionConsole> implements BuildP
|
||||
private final AtomicBoolean isBuildStartEventProcessed = new AtomicBoolean();
|
||||
private final List<BuildEvent> myAfterStartEvents = ContainerUtil.createConcurrentList();
|
||||
private final ViewManager myViewManager;
|
||||
private final TransferToEDTQueue<Runnable> myLaterInvocator = TransferToEDTQueue.createRunnableMerger("BuildView later invocator");
|
||||
|
||||
public BuildView(Project project, BuildDescriptor buildDescriptor, String selectionStateKey, ViewManager viewManager) {
|
||||
this(project, null, buildDescriptor, selectionStateKey, viewManager);
|
||||
@@ -113,9 +114,7 @@ public class BuildView extends CompositeView<ExecutionConsole> implements BuildP
|
||||
String eventViewName = BuildTreeConsoleView.class.getName();
|
||||
BuildTreeConsoleView eventView = getView(eventViewName, BuildTreeConsoleView.class);
|
||||
if (eventView != null) {
|
||||
UIUtil.invokeLaterIfNeeded(() -> {
|
||||
eventView.onEvent(event);
|
||||
});
|
||||
myLaterInvocator.offer(() -> eventView.onEvent(event));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.intellij.ui.content.impl.ContentImpl;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.TransferToEDTQueue;
|
||||
import com.intellij.util.ui.EdtInvocationManager;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
@@ -69,6 +70,8 @@ public class MultipleBuildsView implements BuildProgressListener, Disposable {
|
||||
private final AbstractViewManager myViewManager;
|
||||
private volatile Content myContent;
|
||||
private volatile DefaultActionGroup myToolbarActions;
|
||||
private volatile boolean myDisposed;
|
||||
private final TransferToEDTQueue<Runnable> myLaterInvocator;
|
||||
|
||||
public MultipleBuildsView(Project project,
|
||||
BuildContentManager buildContentManager,
|
||||
@@ -102,11 +105,16 @@ public class MultipleBuildsView implements BuildProgressListener, Disposable {
|
||||
myViewMap = ContainerUtil.newConcurrentMap();
|
||||
myBuildsMap = ContainerUtil.newConcurrentMap();
|
||||
myProgressWatcher = new ProgressWatcher();
|
||||
|
||||
myLaterInvocator = new TransferToEDTQueue<>("Multiple builds view queue", runnable -> {
|
||||
runnable.run();
|
||||
return true;
|
||||
}, o -> myDisposed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
|
||||
myDisposed = true;
|
||||
}
|
||||
|
||||
public Content getContent() {
|
||||
@@ -255,7 +263,7 @@ public class MultipleBuildsView implements BuildProgressListener, Disposable {
|
||||
if (myContent == null) {
|
||||
myPostponedRunnables.addAll(runOnEdt);
|
||||
if (isInitializeStarted.compareAndSet(false, true)) {
|
||||
UIUtil.invokeLaterIfNeeded(() -> {
|
||||
myLaterInvocator.offer(() -> {
|
||||
myBuildsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
myBuildsList.addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
@@ -311,7 +319,7 @@ public class MultipleBuildsView implements BuildProgressListener, Disposable {
|
||||
}
|
||||
}
|
||||
else {
|
||||
UIUtil.invokeLaterIfNeeded(() -> {
|
||||
myLaterInvocator.offer(() -> {
|
||||
for (Runnable runnable : runOnEdt) {
|
||||
runnable.run();
|
||||
}
|
||||
|
||||
+5
@@ -17,12 +17,17 @@ package com.intellij.codeInsight.daemon.impl.analysis;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiImportStaticStatement;
|
||||
import com.intellij.psi.PsiJavaCodeReferenceElement;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class ImportsHighlightUtil {
|
||||
public static final Key<Set<String>> IMPORTS_FROM_TEMPLATE = Key.create("IMPORT_FROM_FILE_TEMPLATE");
|
||||
|
||||
static HighlightInfo checkStaticOnDemandImportResolvesToClass(PsiImportStaticStatement statement) {
|
||||
if (statement.isOnDemand() && statement.resolveTargetClass() == null) {
|
||||
PsiJavaCodeReferenceElement ref = statement.getImportReference();
|
||||
|
||||
+6
-2
@@ -30,6 +30,7 @@ import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.PomNamedTarget;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
import com.intellij.psi.*;
|
||||
@@ -532,14 +533,17 @@ class PostHighlightingVisitor {
|
||||
}
|
||||
|
||||
private HighlightInfo registerRedundantImport(@NotNull PsiImportStatementBase importStatement, @NotNull HighlightDisplayKey unusedImportKey) {
|
||||
String description = InspectionsBundle.message("unused.import.statement");
|
||||
VirtualFile file = PsiUtilCore.getVirtualFile(myFile);
|
||||
Set<String> imports = file != null ? file.getCopyableUserData(ImportsHighlightUtil.IMPORTS_FROM_TEMPLATE) : null;
|
||||
boolean predefinedImport = imports != null && imports.contains(importStatement.getText());
|
||||
String description = !predefinedImport ? InspectionsBundle.message("unused.import.statement") : "Unused import (specified in template)";
|
||||
HighlightInfo info =
|
||||
HighlightInfo.newHighlightInfo(JavaHighlightInfoTypes.UNUSED_IMPORT).range(importStatement).descriptionAndTooltip(description)
|
||||
.create();
|
||||
|
||||
QuickFixAction.registerQuickFixAction(info, QuickFixFactory.getInstance().createOptimizeImportsFix(false), unusedImportKey);
|
||||
QuickFixAction.registerQuickFixAction(info, QuickFixFactory.getInstance().createEnableOptimizeImportsOnTheFlyFix(), unusedImportKey);
|
||||
myHasRedundantImports = true;
|
||||
if (!predefinedImport) myHasRedundantImports = true;
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,4 +129,6 @@ public interface DfaMemoryState {
|
||||
boolean isEphemeral();
|
||||
|
||||
boolean isEmptyStack();
|
||||
|
||||
void cleanUpTempVariables();
|
||||
}
|
||||
|
||||
+15
-1
@@ -38,6 +38,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
|
||||
public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
@@ -269,7 +270,8 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
|
||||
private DfaValue handleFlush(DfaVariableValue flushed, DfaValue value) {
|
||||
if (value instanceof DfaVariableValue && (value == flushed || myFactory.getVarFactory().getAllQualifiedBy(flushed).contains(value))) {
|
||||
Nullness nullability = isNotNull(value) ? Nullness.NOT_NULL : ((DfaVariableValue)value).getInherentNullability();
|
||||
Nullness nullability = isNotNull(value) ? Nullness.NOT_NULL :
|
||||
isUnknownState(value) ? Nullness.UNKNOWN : ((DfaVariableValue)value).getInherentNullability();
|
||||
return myFactory.createTypeValue(((DfaVariableValue)value).getVariableType(), nullability);
|
||||
}
|
||||
return value;
|
||||
@@ -631,6 +633,18 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
return myStack.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanUpTempVariables() {
|
||||
Predicate<DfaVariableValue> sharesState = var ->
|
||||
getConstantValue(var) == null &&
|
||||
StreamEx.of(getEquivalentValues(var)).without(var).select(DfaVariableValue.class).findFirst().isPresent();
|
||||
List<DfaVariableValue> values = StreamEx.ofKeys(myVariableStates)
|
||||
.filter(var -> ControlFlowAnalyzer.isTempVariable(var.getPsiVariable()))
|
||||
.remove(sharesState)
|
||||
.toList();
|
||||
values.forEach(this::flushVariable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean castTopOfStack(@NotNull DfaPsiType type) {
|
||||
DfaValue value = unwrap(peek());
|
||||
|
||||
@@ -665,10 +665,6 @@ class StateMerger {
|
||||
|
||||
@Override
|
||||
void removeFromState(@NotNull DfaMemoryStateImpl state) {
|
||||
if(!myPositive && state.isNotNull(myVar) && state.isNull(myArg)) {
|
||||
// merging "x == null" and "x != null" should be possible with marking "x" as nullable
|
||||
state.forceVariableFact(myVar, CAN_BE_NULL, true);
|
||||
}
|
||||
state.removeEquivalenceRelations(myVar);
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ public class FinishElementInstruction extends Instruction {
|
||||
state.flushVariable(value);
|
||||
}
|
||||
}
|
||||
state.cleanUpTempVariables();
|
||||
return nextInstruction(runner, state);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
@@ -115,16 +116,40 @@ public class PreferByKindWeigher extends LookupElementWeigher {
|
||||
return psiClass -> preferClassIf(InheritanceUtil.isInheritor(psiClass, CommonClassNames.JAVA_LANG_AUTO_CLOSEABLE));
|
||||
}
|
||||
|
||||
if (psiElement().withParents(PsiJavaCodeReferenceElement.class, PsiAnnotation.class).accepts(position)) {
|
||||
final PsiAnnotation annotation = PsiTreeUtil.getParentOfType(position, PsiAnnotation.class);
|
||||
assert annotation != null;
|
||||
final PsiAnnotation.TargetType[] targets = AnnotationTargetUtil.getTargetsForLocation(annotation.getOwner());
|
||||
return psiClass -> preferClassIf(psiClass.isAnnotationType() && AnnotationTargetUtil.findAnnotationTarget(psiClass, targets) != null);
|
||||
PsiElement parent = position.getParent();
|
||||
if (parent instanceof PsiJavaCodeReferenceElement) {
|
||||
PsiElement refParent = parent.getParent();
|
||||
if (refParent instanceof PsiAnnotation) {
|
||||
PsiAnnotation.TargetType[] targets = AnnotationTargetUtil.getTargetsForLocation(((PsiAnnotation)refParent).getOwner());
|
||||
return psiClass -> preferClassIf(psiClass.isAnnotationType() && AnnotationTargetUtil.findAnnotationTarget(psiClass, targets) != null);
|
||||
}
|
||||
if (refParent instanceof PsiTypeElement) {
|
||||
List<PsiClass> bounds = getTypeBounds((PsiTypeElement)refParent);
|
||||
return psiClass -> preferClassIf(ContainerUtil.exists(bounds, bound -> InheritanceUtil.isInheritorOrSelf(psiClass, bound, true)));
|
||||
}
|
||||
}
|
||||
|
||||
return aClass -> MyResult.classNameOrGlobalStatic;
|
||||
}
|
||||
|
||||
private static List<PsiClass> getTypeBounds(PsiTypeElement typeElement) {
|
||||
PsiElement typeParent = typeElement.getParent();
|
||||
if (typeParent instanceof PsiReferenceParameterList) {
|
||||
int index = Arrays.asList(((PsiReferenceParameterList)typeParent).getTypeParameterElements()).indexOf(typeElement);
|
||||
PsiElement listParent = typeParent.getParent();
|
||||
if (index >= 0 && listParent instanceof PsiJavaCodeReferenceElement) {
|
||||
PsiElement target = ((PsiJavaCodeReferenceElement)listParent).resolve();
|
||||
if (target instanceof PsiClass) {
|
||||
PsiTypeParameter[] typeParameters = ((PsiClass)target).getTypeParameters();
|
||||
if (index < typeParameters.length) {
|
||||
return ContainerUtil.mapNotNull(typeParameters[index].getExtendsListTypes(), PsiUtil::resolveClassInType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
static boolean isExceptionPosition(PsiElement position) {
|
||||
return IN_CATCH_TYPE.accepts(position) || IN_MULTI_CATCH_TYPE.accepts(position) ||
|
||||
INSIDE_METHOD_THROWS_CLAUSE.accepts(position) ||
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.testIntegration.createTest;
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.CodeInsightUtil;
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.ImportsHighlightUtil;
|
||||
import com.intellij.codeInsight.template.Template;
|
||||
import com.intellij.ide.fileTemplates.FileTemplate;
|
||||
import com.intellij.ide.fileTemplates.FileTemplateDescriptor;
|
||||
@@ -31,10 +32,12 @@ import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.GlobalSearchScopesCore;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.refactoring.util.classMembers.MemberInfo;
|
||||
import com.intellij.testIntegration.TestFramework;
|
||||
import com.intellij.testIntegration.TestIntegrationUtils;
|
||||
@@ -70,7 +73,8 @@ public class JavaTestGenerator implements TestGenerator {
|
||||
addSuperClass(targetClass, project, superClassName);
|
||||
}
|
||||
|
||||
Editor editor = CodeInsightUtil.positionCursorAtLBrace(project, targetClass.getContainingFile(), targetClass);
|
||||
PsiFile file = targetClass.getContainingFile();
|
||||
Editor editor = CodeInsightUtil.positionCursorAtLBrace(project, file, targetClass);
|
||||
addTestMethods(editor,
|
||||
targetClass,
|
||||
d.getTargetClass(),
|
||||
@@ -78,6 +82,24 @@ public class JavaTestGenerator implements TestGenerator {
|
||||
d.getSelectedMethods(),
|
||||
d.shouldGeneratedBefore(),
|
||||
d.shouldGeneratedAfter());
|
||||
|
||||
if (file instanceof PsiJavaFile) {
|
||||
PsiImportList list = ((PsiJavaFile)file).getImportList();
|
||||
if (list != null) {
|
||||
PsiImportStatementBase[] importStatements = list.getAllImportStatements();
|
||||
if (importStatements.length > 0) {
|
||||
VirtualFile virtualFile = PsiUtilCore.getVirtualFile(list);
|
||||
if (virtualFile != null) {
|
||||
Set<String> imports = new HashSet<>();
|
||||
for (PsiImportStatementBase base : importStatements) {
|
||||
imports.add(base.getText());
|
||||
}
|
||||
virtualFile.putCopyableUserData(ImportsHighlightUtil.IMPORTS_FROM_TEMPLATE, imports);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return targetClass;
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.psi.impl.source;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -75,13 +77,25 @@ public class PsiJavaModuleImpl extends JavaStubPsiElement<PsiJavaModuleStub> imp
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterable<PsiUsesStatement> getUses() {
|
||||
return psiTraverser().children(this).filter(PsiUsesStatement.class);
|
||||
PsiJavaModuleStub stub = getGreenStub();
|
||||
if (stub != null) {
|
||||
return JBIterable.of(stub.getChildrenByType(JavaElementType.USES_STATEMENT, PsiUsesStatement.EMPTY_ARRAY));
|
||||
}
|
||||
else {
|
||||
return psiTraverser().children(this).filter(PsiUsesStatement.class);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterable<PsiProvidesStatement> getProvides() {
|
||||
return psiTraverser().children(this).filter(PsiProvidesStatement.class);
|
||||
PsiJavaModuleStub stub = getGreenStub();
|
||||
if (stub != null) {
|
||||
return JBIterable.of(stub.getChildrenByType(JavaElementType.PROVIDES_STATEMENT, PsiProvidesStatement.EMPTY_ARRAY));
|
||||
}
|
||||
else {
|
||||
return psiTraverser().children(this).filter(PsiProvidesStatement.class);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
public class BlaExecutor implements BasicExecutor<Bla<caret>> {
|
||||
}
|
||||
|
||||
interface BasicExecutor<T extends Exception> {
|
||||
}
|
||||
|
||||
class BlaOperation extends Exception {
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
// IDEA-172844
|
||||
abstract class SimpleClass {
|
||||
|
||||
@Nullable
|
||||
protected MyType findSelfOrInnerByNonQualifiedName() {
|
||||
MyType nearestOuter = getOwnerParentOfType(MyType.class);
|
||||
if (nearestOuter != null) {
|
||||
MyType currentOuter = nearestOuter;
|
||||
while (currentOuter.getOuterClass() != null) { // False positive error here
|
||||
currentOuter = currentOuter.getOuterClass();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
abstract MyType getOwnerParentOfType(Class<MyType> apexPsiTypeDeclarationClass);
|
||||
|
||||
static abstract class MyType {
|
||||
|
||||
@Nullable
|
||||
abstract MyType getOuterClass();
|
||||
}
|
||||
}
|
||||
+1
@@ -1775,6 +1775,7 @@ class Foo {
|
||||
myFixture.addClass("package foo.bar.goo; class Foo {}")
|
||||
myFixture.configureByText "a.java", "class Foo { { foo.b<caret> } }"
|
||||
def items = myFixture.completeBasic()
|
||||
joinCompletion()
|
||||
if (items != null) { // completion took a bit longer, and the single item wasn't inserted automatically
|
||||
assert myFixture.lookupElementStrings == ['bar']
|
||||
myFixture.type('\n')
|
||||
|
||||
+4
@@ -845,4 +845,8 @@ class Foo {
|
||||
checkPreferredItems 0, 'IllegalArgumentException', 'IllegalAccessException', 'IllegalStateException'
|
||||
}
|
||||
|
||||
void testPreferExpectedTypeArguments() {
|
||||
checkPreferredItems 0, 'BlaOperation'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -582,5 +582,6 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
|
||||
public void testPrimitiveNull() { doTest(); }
|
||||
public void testLessThanRelations() { doTest(); }
|
||||
public void testAdvancedArrayAccess() { doTest(); }
|
||||
public void testNullableGetterInLoop() { doTest(); }
|
||||
public void testNullabilityBasics() { doTest(); }
|
||||
}
|
||||
|
||||
+4
-2
@@ -1,4 +1,6 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.structuralsearch;
|
||||
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
@@ -31,7 +33,7 @@ public class IdeaOpenApiClassFinder extends NonClasspathClassFinder {
|
||||
.map(PathManager::getJarPathForClass)
|
||||
.filter(Objects::nonNull)
|
||||
.map(File::new)
|
||||
.map(lfs::refreshAndFindFileByIoFile)
|
||||
.map(lfs::findFileByIoFile)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
+16
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.codeInspection.offlineViewer;
|
||||
|
||||
@@ -16,10 +16,12 @@ import com.intellij.codeInspection.reference.RefEntity;
|
||||
import com.intellij.codeInspection.reference.RefModule;
|
||||
import com.intellij.codeInspection.ui.InspectionToolPresentation;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.injection.InjectedLanguageManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
@@ -140,7 +142,20 @@ class OfflineDescriptorResolveResult {
|
||||
final PsiElementVisitor visitor = localTool.buildVisitor(holder, true, session);
|
||||
localTool.inspectionStarted(session, false);
|
||||
final PsiElement[] elementsInRange = getElementsIntersectingRange(containingFile, startOffset, endOffset);
|
||||
InjectedLanguageManager injectedLanguageManager = InjectedLanguageManager.getInstance(context.getProject());
|
||||
for (PsiElement element : elementsInRange) {
|
||||
List<Pair<PsiElement, TextRange>> injectedPsiFiles = injectedLanguageManager.getInjectedPsiFiles(element);
|
||||
if (injectedPsiFiles != null) {
|
||||
for (Pair<PsiElement, TextRange> file : injectedPsiFiles) {
|
||||
file.getFirst().accept(new PsiRecursiveElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitElement(PsiElement element) {
|
||||
element.accept(visitor);
|
||||
super.visitElement(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
element.accept(visitor);
|
||||
}
|
||||
localTool.inspectionFinished(session, holder);
|
||||
|
||||
+2
-5
@@ -34,10 +34,7 @@ import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.platform.DirectoryProjectGenerator;
|
||||
import com.intellij.platform.PlatformProjectOpenProcessor;
|
||||
import com.intellij.platform.ProjectGeneratorPeer;
|
||||
import com.intellij.platform.ProjectTemplate;
|
||||
import com.intellij.platform.*;
|
||||
import com.intellij.platform.templates.ArchivedTemplatesFactory;
|
||||
import com.intellij.platform.templates.LocalArchivedTemplate;
|
||||
import com.intellij.platform.templates.TemplateProjectDirectoryGenerator;
|
||||
@@ -136,7 +133,7 @@ public class AbstractNewProjectStep<T> extends DefaultActionGroup implements Dum
|
||||
}
|
||||
|
||||
protected boolean shouldIgnore(@NotNull DirectoryProjectGenerator generator) {
|
||||
return false;
|
||||
return generator instanceof HideableProjectGenerator && ((HideableProjectGenerator)generator).isHidden();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -46,8 +46,9 @@ public class FileIncludeIndex extends FileBasedIndexExtension<FileIncludeIndex.K
|
||||
|
||||
private static final int BASE_VERSION = 5;
|
||||
|
||||
public static List<FileIncludeInfoImpl> getIncludes(VirtualFile file, GlobalSearchScope scope) {
|
||||
final List<FileIncludeInfoImpl> result = new ArrayList<>();
|
||||
@NotNull
|
||||
public static List<FileIncludeInfo> getIncludes(@NotNull VirtualFile file, @NotNull GlobalSearchScope scope) {
|
||||
final List<FileIncludeInfo> result = new ArrayList<>();
|
||||
FileBasedIndex.getInstance().processValues(INDEX_ID, new FileKey(file), file, (file1, value) -> {
|
||||
result.addAll(value);
|
||||
return true;
|
||||
@@ -55,7 +56,8 @@ public class FileIncludeIndex extends FileBasedIndexExtension<FileIncludeIndex.K
|
||||
return result;
|
||||
}
|
||||
|
||||
public static MultiMap<VirtualFile, FileIncludeInfoImpl> getIncludingFileCandidates(String fileName, GlobalSearchScope scope) {
|
||||
@NotNull
|
||||
public static MultiMap<VirtualFile, FileIncludeInfoImpl> getIncludingFileCandidates(String fileName, @NotNull GlobalSearchScope scope) {
|
||||
final MultiMap<VirtualFile, FileIncludeInfoImpl> result = new MultiMap<>();
|
||||
FileBasedIndex.getInstance().processValues(INDEX_ID, new IncludeKey(fileName), null, (file, value) -> {
|
||||
result.put(file, value);
|
||||
|
||||
@@ -76,8 +76,8 @@ public class FileIncludeManagerImpl extends FileIncludeManager {
|
||||
|
||||
public void processIncludes(PsiFile file, Processor<FileIncludeInfo> processor) {
|
||||
GlobalSearchScope scope = GlobalSearchScope.allScope(myProject);
|
||||
List<FileIncludeInfoImpl> infoList = FileIncludeIndex.getIncludes(file.getVirtualFile(), scope);
|
||||
for (FileIncludeInfoImpl info : infoList) {
|
||||
List<FileIncludeInfo> infoList = FileIncludeIndex.getIncludes(file.getVirtualFile(), scope);
|
||||
for (FileIncludeInfo info : infoList) {
|
||||
if (!processor.process(info)) {
|
||||
return;
|
||||
}
|
||||
@@ -101,21 +101,41 @@ public class FileIncludeManagerImpl extends FileIncludeManager {
|
||||
context = context.getOriginalFile();
|
||||
VirtualFile contextFile = context.getVirtualFile();
|
||||
if (contextFile == null) return;
|
||||
MultiMap<VirtualFile,FileIncludeInfoImpl> infoList = FileIncludeIndex.getIncludingFileCandidates(context.getName(), GlobalSearchScope.allScope(myProject));
|
||||
for (VirtualFile candidate : infoList.keySet()) {
|
||||
PsiFile psiFile = myPsiManager.findFile(candidate);
|
||||
if (psiFile == null || context.equals(psiFile)) continue;
|
||||
for (FileIncludeInfo info : infoList.get(candidate)) {
|
||||
PsiFileSystemItem item = resolveFileInclude(info, psiFile);
|
||||
if (item != null && contextFile.equals(item.getVirtualFile())) {
|
||||
if (!processor.process(Pair.create(candidate, info))) {
|
||||
return;
|
||||
|
||||
String originalName = context.getName();
|
||||
Collection<String> names = getPossibleIncludeNames(context, originalName);
|
||||
|
||||
GlobalSearchScope scope = GlobalSearchScope.allScope(myProject);
|
||||
for (String name : names) {
|
||||
MultiMap<VirtualFile,FileIncludeInfoImpl> infoList = FileIncludeIndex.getIncludingFileCandidates(name, scope);
|
||||
for (VirtualFile candidate : infoList.keySet()) {
|
||||
PsiFile psiFile = myPsiManager.findFile(candidate);
|
||||
if (psiFile == null || context.equals(psiFile)) continue;
|
||||
for (FileIncludeInfo info : infoList.get(candidate)) {
|
||||
PsiFileSystemItem item = resolveFileInclude(info, psiFile);
|
||||
if (item != null && contextFile.equals(item.getVirtualFile())) {
|
||||
if (!processor.process(Pair.create(candidate, info))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Collection<String> getPossibleIncludeNames(@NotNull PsiFile context, @NotNull String originalName) {
|
||||
Collection<String> names = ContainerUtil.newTroveSet();
|
||||
names.add(originalName);
|
||||
for (FileIncludeProvider provider : FileIncludeProvider.EP_NAME.getExtensions()) {
|
||||
String newName = provider.getIncludeName(context, originalName);
|
||||
if (newName != originalName) {
|
||||
names.add(newName);
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public FileIncludeManagerImpl(Project project, PsiManager psiManager, PsiFileFactory psiFileFactory,
|
||||
CachedValuesManager cachedValuesManager) {
|
||||
myProject = project;
|
||||
|
||||
@@ -57,4 +57,12 @@ public abstract class FileIncludeProvider {
|
||||
public int getVersion() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Possible name in included paths. For example if a provider returns FileIncludeInfos without file extensions
|
||||
*/
|
||||
@NotNull
|
||||
public String getIncludeName(@NotNull PsiFile file, @NotNull String originalName) {
|
||||
return originalName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.slicer;
|
||||
|
||||
@@ -21,6 +9,7 @@ import com.intellij.analysis.BaseAnalysisActionDialog;
|
||||
import com.intellij.codeInsight.CodeInsightActionHandler;
|
||||
import com.intellij.codeInsight.TargetElementUtil;
|
||||
import com.intellij.codeInsight.hint.HintManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
@@ -34,6 +23,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @author cdr
|
||||
*/
|
||||
public class SliceHandler implements CodeInsightActionHandler {
|
||||
private static final Logger LOG = Logger.getInstance(SliceHandler.class);
|
||||
private final boolean myDataFlowToThis;
|
||||
|
||||
public SliceHandler(boolean dataFlowToThis) {
|
||||
@@ -48,6 +38,12 @@ public class SliceHandler implements CodeInsightActionHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!expression.isPhysical()) {
|
||||
PsiFile expressionFile = expression.getContainingFile();
|
||||
LOG.error("Analyzed entity should be physical. " +
|
||||
"Analyzed element: " + expression.getText() + " (class = " + expression.getClass() + "), file = " + file +
|
||||
" expression file = " + expressionFile + " (class = " + expressionFile.getClass() + ")");
|
||||
}
|
||||
SliceManager sliceManager = SliceManager.getInstance(project);
|
||||
sliceManager.slice(expression,myDataFlowToThis, this);
|
||||
}
|
||||
|
||||
+4
-2
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ui.treeStructure.treetable;
|
||||
|
||||
import com.intellij.util.containers.TransferToEDTQueue;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.TreeExpansionEvent;
|
||||
import javax.swing.event.TreeExpansionListener;
|
||||
@@ -38,6 +39,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
public class TreeTableModelAdapter extends AbstractTableModel {
|
||||
|
||||
private final AtomicInteger modificationStamp = new AtomicInteger();
|
||||
private final TransferToEDTQueue<Runnable> laterInvocator =
|
||||
TransferToEDTQueue.createRunnableMerger("TreeTableModelAdapter later invocator");
|
||||
|
||||
private final JTree tree;
|
||||
private final TreeTableModel treeTableModel;
|
||||
@@ -128,8 +131,7 @@ public class TreeTableModelAdapter extends AbstractTableModel {
|
||||
*/
|
||||
protected void delayedFireTableDataChanged() {
|
||||
long stamp = modificationStamp.incrementAndGet();
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
laterInvocator.offer(() -> {
|
||||
if (stamp != modificationStamp.get()) return;
|
||||
fireTableDataChanged();
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# suppress inspection "UnusedProperty" for whole file
|
||||
darcula.selectionBackground=2F65CA
|
||||
Menu.arrowIcon=AllIcons.Mac.Tree_white_right_arrow
|
||||
Menu.arrowIcon=AllIcons.Mac.Tree_white_right_arrow
|
||||
SplitPaneUI=com.intellij.ide.ui.laf.darcula.ui.DarculaSplitPaneUI
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.ide.ui.laf.darcula.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.metal.MetalSplitPaneUI;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class DarculaSplitPaneUI extends MetalSplitPaneUI {
|
||||
|
||||
@SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"})
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new DarculaSplitPaneUI();
|
||||
}
|
||||
}
|
||||
@@ -602,16 +602,18 @@ public final class EditorUtil {
|
||||
scrollToTheEnd(editor, false);
|
||||
}
|
||||
|
||||
public static void scrollToTheEnd(@NotNull Editor editor, boolean verticalScrollOnly) {
|
||||
public static void scrollToTheEnd(@NotNull Editor editor, boolean preferVerticalScroll) {
|
||||
editor.getSelectionModel().removeSelection();
|
||||
int lastLine = Math.max(0, editor.getDocument().getLineCount() - 1);
|
||||
Document document = editor.getDocument();
|
||||
int lastLine = Math.max(0, document.getLineCount() - 1);
|
||||
if (editor.getCaretModel().getLogicalPosition().line == lastLine) {
|
||||
editor.getCaretModel().moveToOffset(editor.getDocument().getTextLength());
|
||||
editor.getCaretModel().moveToOffset(document.getTextLength());
|
||||
} else {
|
||||
editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(lastLine, 0));
|
||||
}
|
||||
ScrollingModel scrollingModel = editor.getScrollingModel();
|
||||
if (verticalScrollOnly) {
|
||||
if (preferVerticalScroll && document.getLineStartOffset(lastLine) == document.getLineEndOffset(lastLine)) {
|
||||
// don't move 'focus' to empty last line
|
||||
int scrollOffset;
|
||||
if (editor instanceof EditorEx) {
|
||||
JScrollBar verticalScrollBar = ((EditorEx)editor).getScrollPane().getVerticalScrollBar();
|
||||
|
||||
+5
-1
@@ -1,9 +1,12 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.openapi.wm.impl.status;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.PowerSaveMode;
|
||||
import com.intellij.idea.ActionsBundle;
|
||||
import com.intellij.internal.statistic.customUsageCollectors.actions.ActionsCollector;
|
||||
import com.intellij.notification.EventLog;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
@@ -687,6 +690,7 @@ public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidge
|
||||
ProgressSuspender suspender = Objects.requireNonNull(getSuspender());
|
||||
suspender.setSuspended(!suspender.isSuspended());
|
||||
updateProgressNow();
|
||||
ActionsCollector.getInstance().record(suspender.isSuspended() ? "Progress Paused" : "Progress Resumed");
|
||||
}).setFillBg(false);
|
||||
suspendButton.setVisible(false);
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ public class LeakHunter {
|
||||
backLink;
|
||||
System.out.println(message);
|
||||
System.out.println(";-----");
|
||||
UsefulTestCase.printThreadDump();
|
||||
|
||||
throw new AssertionError(message);
|
||||
});
|
||||
|
||||
+1
@@ -229,6 +229,7 @@ object GuiTestLocalLauncher {
|
||||
.plus("-Dapple.laf.useScreenMenuBar=${GuiTestOptions.useAppleScreenMenuBar()}")
|
||||
.plus("-Didea.is.internal=${GuiTestOptions.isInternal()}")
|
||||
.plus("-Didea.debug.mode=true")
|
||||
.plus("-Dnative.mac.file.chooser.enabled=false")
|
||||
.plus("-Didea.config.path=${GuiTestOptions.getConfigPath()}")
|
||||
.plus("-Didea.system.path=${GuiTestOptions.getSystemPath()}")
|
||||
.plus("-Dfile.encoding=${GuiTestOptions.getEncoding()}")
|
||||
|
||||
@@ -136,8 +136,9 @@ abstract class VcsPlatformTest : PlatformTestCase() {
|
||||
return true
|
||||
}
|
||||
|
||||
protected open fun refresh() {
|
||||
VfsUtil.markDirtyAndRefresh(false, true, false, testRootFile)
|
||||
@JvmOverloads
|
||||
protected open fun refresh(dir: VirtualFile = testRootFile) {
|
||||
VfsUtil.markDirtyAndRefresh(false, true, false, dir)
|
||||
}
|
||||
|
||||
protected fun updateChangeListManager() {
|
||||
|
||||
@@ -46,7 +46,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -251,8 +250,7 @@ public class XDebuggerManagerImpl extends XDebuggerManager implements Persistent
|
||||
@Override
|
||||
@NotNull
|
||||
public XDebugSession[] getDebugSessions() {
|
||||
final Collection<XDebugSessionImpl> sessions = mySessions.values();
|
||||
return sessions.toArray(new XDebugSessionImpl[sessions.size()]);
|
||||
return mySessions.values().toArray(new XDebugSessionImpl[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,7 +18,12 @@ package git4idea.log
|
||||
import com.intellij.openapi.vcs.Executor.cd
|
||||
import com.intellij.openapi.vcs.Executor.touch
|
||||
import com.intellij.openapi.vcs.changes.patch.BlobIndexUtil
|
||||
import git4idea.test.*
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import git4idea.test.GitSingleRepoTest
|
||||
import git4idea.test.add
|
||||
import git4idea.test.addCommit
|
||||
import git4idea.test.createFileStructure
|
||||
import java.nio.file.Paths
|
||||
|
||||
class GitSha1Test : GitSingleRepoTest() {
|
||||
var A_FILE = "a.txt"
|
||||
@@ -40,7 +45,7 @@ class GitSha1Test : GitSingleRepoTest() {
|
||||
|
||||
fun `test sha for del`() {
|
||||
cd(projectPath)
|
||||
val path = projectRoot.findChild(A_FILE)!!.path
|
||||
val path = Paths.get(projectPath, A_FILE)
|
||||
val expectedBefore = git("hash-object $path")
|
||||
git("rm $path")
|
||||
checkSha1ForSingleChange(expectedBefore, BlobIndexUtil.NOT_COMMITTED_HASH)
|
||||
@@ -48,8 +53,8 @@ class GitSha1Test : GitSingleRepoTest() {
|
||||
|
||||
fun `test sha for modified`() {
|
||||
cd(projectPath)
|
||||
val virtualFile = projectRoot.findChild(A_FILE)
|
||||
val path = virtualFile!!.path
|
||||
val path = Paths.get(projectPath, A_FILE)
|
||||
val virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(path.toFile())!!
|
||||
val expectedBefore = git("hash-object $path")
|
||||
setFileText(virtualFile, "echo content\n with line separator")
|
||||
checkSha1ForSingleChange(expectedBefore, git("hash-object $path"))
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package git4idea.tests
|
||||
|
||||
import com.intellij.openapi.util.SystemInfo
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.vcs.Executor.*
|
||||
import com.intellij.openapi.vcs.VcsException
|
||||
@@ -219,11 +220,13 @@ class GitCommitTest : GitSingleRepoTest() {
|
||||
fun `test commit case rename & don't commit a file which is both staged and unstaged, should reset and restore`() {
|
||||
`assume version where git reset returns 0 exit code on success `()
|
||||
|
||||
tac("c.java")
|
||||
tac("c.java", "initial")
|
||||
generateCaseRename("a.java", "A.java")
|
||||
echo("c.java", "staged")
|
||||
val STAGED_CONTENT = "staged"
|
||||
overwrite("c.java", STAGED_CONTENT)
|
||||
git("add c.java")
|
||||
overwrite("c.java", "unstaged")
|
||||
val UNSTAGED_CONTENT = "unstaged"
|
||||
overwrite("c.java", UNSTAGED_CONTENT)
|
||||
|
||||
val changes = assertChanges {
|
||||
rename("a.java", "A.java")
|
||||
@@ -241,11 +244,18 @@ class GitCommitTest : GitSingleRepoTest() {
|
||||
repo.assertStagedChanges {
|
||||
modified("c.java")
|
||||
}
|
||||
// this is intentional data loss: it is a rare case, while restoring both staged and unstaged part is not so easy,
|
||||
// so we are not doing it, at least until IDEA supports Git index
|
||||
// (which will mean that users will be able to produce such situation intentionally with a help of IDE).
|
||||
assertEquals("unstaged", git("show :c.java"))
|
||||
assertEquals("unstaged", FileUtil.loadFile(File(projectPath, "c.java")))
|
||||
|
||||
val expectedIndexContent = if (SystemInfo.isFileSystemCaseSensitive) {
|
||||
STAGED_CONTENT
|
||||
}
|
||||
else {
|
||||
// this is intentional data loss: it is a rare case, while restoring both staged and unstaged part is not so easy,
|
||||
// so we are not doing it, at least until IDEA supports Git index
|
||||
// (which will mean that users will be able to produce such situation intentionally with a help of IDE).
|
||||
UNSTAGED_CONTENT
|
||||
}
|
||||
assertEquals(expectedIndexContent, git("show :c.java"))
|
||||
assertEquals(UNSTAGED_CONTENT, FileUtil.loadFile(File(projectPath, "c.java")))
|
||||
}
|
||||
|
||||
fun `test commit case rename with additional non-staged changes should commit everything`() {
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.util.io.FileUtil.getRelativePath
|
||||
import com.intellij.openapi.vcs.Executor.cd
|
||||
import com.intellij.openapi.vcs.update.UpdatedFiles
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile
|
||||
import git4idea.config.GitVersion
|
||||
import git4idea.config.UpdateMethod
|
||||
@@ -164,6 +165,7 @@ class GitSubmoduleTest : GitPlatformTest() {
|
||||
addSubmodule(File(projectPath), submoduleUrl, relativePath)
|
||||
val rootPath = "${projectPath}/${relativePath ?: moduleName}"
|
||||
cd(rootPath)
|
||||
refresh(LocalFileSystem.getInstance().refreshAndFindFileByPath(rootPath)!!)
|
||||
setupDefaultUsername()
|
||||
return registerRepo(project, rootPath)
|
||||
}
|
||||
|
||||
+4
-1
@@ -1,4 +1,6 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package org.jetbrains.java.decompiler.code;
|
||||
|
||||
@SuppressWarnings({"unused", "SpellCheckingInspection"})
|
||||
@@ -70,6 +72,7 @@ public interface CodeConstants {
|
||||
int ACC_SYNTHETIC = 0x1000;
|
||||
int ACC_ANNOTATION = 0x2000;
|
||||
int ACC_ENUM = 0x4000;
|
||||
int ACC_MANDATED = 0x8000;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// CLASS FLAGS
|
||||
|
||||
+22
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package org.jetbrains.java.decompiler.main;
|
||||
|
||||
@@ -697,6 +697,15 @@ public class ClassWriter {
|
||||
}
|
||||
}
|
||||
|
||||
List<StructMethodParametersAttribute.Entry> methodParameters = null;
|
||||
if (DecompilerContext.getOption(IFernflowerPreferences.USE_METHOD_PARAMETERS)) {
|
||||
StructMethodParametersAttribute attr =
|
||||
(StructMethodParametersAttribute)mt.getAttribute(StructGeneralAttribute.ATTRIBUTE_METHOD_PARAMETERS);
|
||||
if (attr != null) {
|
||||
methodParameters = attr.getEntries();
|
||||
}
|
||||
}
|
||||
|
||||
int index = isEnum && init ? 3 : thisVar ? 1 : 0;
|
||||
int start = isEnum && init ? 2 : 0;
|
||||
for (int i = start; i < md.params.length; i++) {
|
||||
@@ -707,7 +716,10 @@ public class ClassWriter {
|
||||
|
||||
appendParameterAnnotations(buffer, mt, paramCount);
|
||||
|
||||
if (methodWrapper.varproc.getVarFinal(new VarVersionPair(index, 0)) == VarTypeProcessor.VAR_EXPLICIT_FINAL) {
|
||||
if (methodParameters != null && i < methodParameters.size()) {
|
||||
appendModifiers(buffer, methodParameters.get(i).myAccessFlags, CodeConstants.ACC_FINAL, isInterface, 0);
|
||||
}
|
||||
else if (methodWrapper.varproc.getVarFinal(new VarVersionPair(index, 0)) == VarTypeProcessor.VAR_EXPLICIT_FINAL) {
|
||||
buffer.append("final ");
|
||||
}
|
||||
|
||||
@@ -741,7 +753,14 @@ public class ClassWriter {
|
||||
}
|
||||
|
||||
buffer.append(' ');
|
||||
String parameterName = methodWrapper.varproc.getVarName(new VarVersionPair(index, 0));
|
||||
|
||||
String parameterName;
|
||||
if (methodParameters != null && i < methodParameters.size()) {
|
||||
parameterName = methodParameters.get(i).myName;
|
||||
}
|
||||
else {
|
||||
parameterName = methodWrapper.varproc.getVarName(new VarVersionPair(index, 0));
|
||||
}
|
||||
buffer.append(parameterName == null ? "param" + index : parameterName); // null iff decompiled with errors
|
||||
|
||||
paramCount++;
|
||||
|
||||
+5
-1
@@ -1,4 +1,6 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package org.jetbrains.java.decompiler.main.extern;
|
||||
|
||||
import org.jetbrains.java.decompiler.util.InterpreterUtil;
|
||||
@@ -25,6 +27,7 @@ public interface IFernflowerPreferences {
|
||||
String SYNTHETIC_NOT_SET = "nns";
|
||||
String UNDEFINED_PARAM_TYPE_OBJECT = "uto";
|
||||
String USE_DEBUG_VAR_NAMES = "udv";
|
||||
String USE_METHOD_PARAMETERS = "ump";
|
||||
String REMOVE_EMPTY_RANGES = "rer";
|
||||
String FINALLY_DEINLINE = "fdi";
|
||||
String IDEA_NOT_NULL_ANNOTATION = "inn";
|
||||
@@ -67,6 +70,7 @@ public interface IFernflowerPreferences {
|
||||
defaults.put(SYNTHETIC_NOT_SET, "0");
|
||||
defaults.put(UNDEFINED_PARAM_TYPE_OBJECT, "1");
|
||||
defaults.put(USE_DEBUG_VAR_NAMES, "1");
|
||||
defaults.put(USE_METHOD_PARAMETERS, "1");
|
||||
defaults.put(REMOVE_EMPTY_RANGES, "1");
|
||||
defaults.put(FINALLY_DEINLINE, "1");
|
||||
defaults.put(IDEA_NOT_NULL_ANNOTATION, "1");
|
||||
|
||||
+7
-1
@@ -1,4 +1,6 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package org.jetbrains.java.decompiler.struct.attr;
|
||||
|
||||
import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
|
||||
@@ -33,6 +35,7 @@ public class StructGeneralAttribute {
|
||||
public static final String ATTRIBUTE_SYNTHETIC = "Synthetic";
|
||||
public static final String ATTRIBUTE_DEPRECATED = "Deprecated";
|
||||
public static final String ATTRIBUTE_LINE_NUMBER_TABLE = "LineNumberTable";
|
||||
public static final String ATTRIBUTE_METHOD_PARAMETERS = "MethodParameters";
|
||||
|
||||
private String name;
|
||||
|
||||
@@ -81,6 +84,9 @@ public class StructGeneralAttribute {
|
||||
else if (ATTRIBUTE_LINE_NUMBER_TABLE.equals(name)) {
|
||||
attr = new StructLineNumberTableAttribute();
|
||||
}
|
||||
else if (ATTRIBUTE_METHOD_PARAMETERS.equals(name)) {
|
||||
attr = new StructMethodParametersAttribute();
|
||||
}
|
||||
else {
|
||||
// unsupported attribute
|
||||
return null;
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package org.jetbrains.java.decompiler.struct.attr;
|
||||
|
||||
import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
|
||||
import org.jetbrains.java.decompiler.util.DataInputFullStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
u1 parameters_count;
|
||||
{ u2 name_index;
|
||||
u2 access_flags;
|
||||
} parameters[parameters_count];
|
||||
*/
|
||||
public class StructMethodParametersAttribute extends StructGeneralAttribute {
|
||||
private List<Entry> myEntries;
|
||||
|
||||
@Override
|
||||
public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException {
|
||||
int len = data.readUnsignedByte();
|
||||
List<Entry> entries;
|
||||
if (len > 0) {
|
||||
entries = new ArrayList<>(len);
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
int nameIndex = data.readUnsignedShort();
|
||||
String name = nameIndex != 0 ? pool.getPrimitiveConstant(nameIndex).getString() : null;
|
||||
int access_flags = data.readUnsignedShort();
|
||||
entries.add(new Entry(name, access_flags));
|
||||
}
|
||||
}
|
||||
else {
|
||||
entries = Collections.emptyList();
|
||||
}
|
||||
myEntries = Collections.unmodifiableList(entries);
|
||||
}
|
||||
|
||||
public List<Entry> getEntries() {
|
||||
return myEntries;
|
||||
}
|
||||
|
||||
public static class Entry {
|
||||
public final String myName;
|
||||
public final int myAccessFlags;
|
||||
|
||||
public Entry(String name, int accessFlags) {
|
||||
myName = name;
|
||||
myAccessFlags = accessFlags;
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -1,4 +1,6 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package org.jetbrains.java.decompiler;
|
||||
|
||||
import org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler;
|
||||
@@ -45,6 +47,7 @@ public class SingleClassesTest {
|
||||
@Test public void testDeprecations() { doTest("pkg/TestDeprecations"); }
|
||||
@Test public void testExtendsList() { doTest("pkg/TestExtendsList"); }
|
||||
@Test public void testMethodParameters() { doTest("pkg/TestMethodParameters"); }
|
||||
@Test public void testMethodParametersAttr() { doTest("pkg/TestMethodParametersAttr"); }
|
||||
@Test public void testCodeConstructs() { doTest("pkg/TestCodeConstructs"); }
|
||||
@Test public void testConstants() { doTest("pkg/TestConstants"); }
|
||||
@Test public void testEnum() { doTest("pkg/TestEnum"); }
|
||||
|
||||
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,125 @@
|
||||
package decompiler;
|
||||
|
||||
public class TestMethodParametersAttr {
|
||||
TestMethodParametersAttr(int p01) {
|
||||
}// 19
|
||||
|
||||
void m1(int p02) {
|
||||
}// 20
|
||||
|
||||
static void m2(int p03) {
|
||||
}// 21
|
||||
|
||||
void local() {
|
||||
class Local {
|
||||
Local(int p31) {
|
||||
}// 36
|
||||
|
||||
void m(int p32) {
|
||||
}// 37
|
||||
}
|
||||
|
||||
}// 39
|
||||
|
||||
abstract static class C4 {
|
||||
abstract void m1(int p51);
|
||||
|
||||
abstract void m2(final int p52);
|
||||
}
|
||||
|
||||
abstract class C3 {
|
||||
abstract void m1(int p51);
|
||||
|
||||
abstract void m2(final int p52);
|
||||
}
|
||||
|
||||
interface I1 {
|
||||
void m1(int p41);
|
||||
|
||||
void m2(final int p42);
|
||||
}
|
||||
|
||||
static class C2 {
|
||||
C2(int p21) {
|
||||
}// 29
|
||||
|
||||
void m1(int p22) {
|
||||
}// 30
|
||||
|
||||
static void m2(int p23) {
|
||||
}// 31
|
||||
}
|
||||
|
||||
class C1 {
|
||||
C1(int p11) {
|
||||
}// 24
|
||||
|
||||
void m(int p12) {
|
||||
}// 25
|
||||
}
|
||||
}
|
||||
|
||||
class 'decompiler/TestMethodParametersAttr' {
|
||||
method '<init> (I)V' {
|
||||
4 4
|
||||
}
|
||||
|
||||
method 'm1 (I)V' {
|
||||
0 7
|
||||
}
|
||||
|
||||
method 'm2 (I)V' {
|
||||
0 10
|
||||
}
|
||||
|
||||
method 'local ()V' {
|
||||
0 21
|
||||
}
|
||||
}
|
||||
|
||||
class 'decompiler/TestMethodParametersAttr$1Local' {
|
||||
method '<init> (Ldecompiler/TestMethodParametersAttr;I)V' {
|
||||
9 15
|
||||
}
|
||||
|
||||
method 'm (I)V' {
|
||||
0 18
|
||||
}
|
||||
}
|
||||
|
||||
class 'decompiler/TestMethodParametersAttr$C2' {
|
||||
method '<init> (I)V' {
|
||||
4 43
|
||||
}
|
||||
|
||||
method 'm1 (I)V' {
|
||||
0 46
|
||||
}
|
||||
|
||||
method 'm2 (I)V' {
|
||||
0 49
|
||||
}
|
||||
}
|
||||
|
||||
class 'decompiler/TestMethodParametersAttr$C1' {
|
||||
method '<init> (Ldecompiler/TestMethodParametersAttr;I)V' {
|
||||
9 54
|
||||
}
|
||||
|
||||
method 'm (I)V' {
|
||||
0 57
|
||||
}
|
||||
}
|
||||
|
||||
Lines mapping:
|
||||
19 <-> 5
|
||||
20 <-> 8
|
||||
21 <-> 11
|
||||
24 <-> 55
|
||||
25 <-> 58
|
||||
29 <-> 44
|
||||
30 <-> 47
|
||||
31 <-> 50
|
||||
36 <-> 16
|
||||
37 <-> 19
|
||||
39 <-> 22
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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 decompiler;
|
||||
|
||||
// compile with java 8: javap -parameters TestMethodParametersAttr.java
|
||||
public class TestMethodParametersAttr {
|
||||
TestMethodParametersAttr(int p01) { }
|
||||
void m1(int p02) { }
|
||||
static void m2(int p03) { }
|
||||
|
||||
class C1 {
|
||||
C1(int p11) { }
|
||||
void m(int p12) { }
|
||||
}
|
||||
|
||||
static class C2 {
|
||||
C2(int p21) { }
|
||||
void m1(int p22) { }
|
||||
static void m2(int p23) { }
|
||||
}
|
||||
|
||||
void local() {
|
||||
class Local {
|
||||
Local(int p31) { }
|
||||
void m(int p32) { }
|
||||
}
|
||||
}
|
||||
|
||||
interface I1 {
|
||||
void m1(int p41);
|
||||
void m2(final int p42);
|
||||
}
|
||||
|
||||
abstract class C3 {
|
||||
abstract void m1(int p51);
|
||||
abstract void m2(final int p52);
|
||||
}
|
||||
|
||||
static abstract class C4 {
|
||||
abstract void m1(int p51);
|
||||
abstract void m2(final int p52);
|
||||
}
|
||||
}
|
||||
+4
-7
@@ -20,12 +20,10 @@ import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
import com.intellij.execution.configurations.ParametersList;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.externalSystem.service.execution.cmd.ParametersListLexer;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.FixedSizeButton;
|
||||
import com.intellij.openapi.ui.LabeledComponent;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
import com.intellij.ui.PanelWithAnchor;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
@@ -33,7 +31,6 @@ import com.intellij.util.TextFieldCompletionProvider;
|
||||
import com.intellij.util.execution.ParametersListUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsManager;
|
||||
import org.jetbrains.idea.maven.utils.MavenUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -117,10 +114,10 @@ public class MavenRunnerParametersPanel implements PanelWithAnchor {
|
||||
data.setWorkingDirPath(workingDirComponent.getComponent().getText());
|
||||
|
||||
List<String> commandLine = ParametersListUtil.parse(goalsComponent.getComponent().getText());
|
||||
int pomFileNameIndex = commandLine.indexOf("-f");
|
||||
if (pomFileNameIndex != -1) {
|
||||
if (pomFileNameIndex + 1 < commandLine.size()) {
|
||||
data.setPomFileName(commandLine.remove(pomFileNameIndex + 1));
|
||||
int pomFileNameIndex = 1 + commandLine.indexOf("-f");
|
||||
if (pomFileNameIndex != 0) {
|
||||
if (pomFileNameIndex < commandLine.size()) {
|
||||
data.setPomFileName(commandLine.remove(pomFileNameIndex));
|
||||
}
|
||||
commandLine.remove(pomFileNameIndex);
|
||||
}
|
||||
|
||||
+20
-1
@@ -30,6 +30,7 @@ import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.PathUtil;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import com.intellij.util.execution.ParametersListUtil;
|
||||
import icons.MavenIcons;
|
||||
@@ -38,6 +39,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.maven.execution.MavenEditGoalDialog;
|
||||
import org.jetbrains.idea.maven.execution.MavenRunner;
|
||||
import org.jetbrains.idea.maven.execution.MavenRunnerParameters;
|
||||
import org.jetbrains.idea.maven.model.MavenConstants;
|
||||
import org.jetbrains.idea.maven.model.MavenExplicitProfiles;
|
||||
import org.jetbrains.idea.maven.project.MavenProject;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsManager;
|
||||
@@ -91,6 +93,11 @@ public class MavenBeforeRunTasksProvider extends BeforeRunTaskProvider<MavenBefo
|
||||
String pomXmlPath = task.getProjectPath();
|
||||
if (StringUtil.isEmpty(pomXmlPath)) return null;
|
||||
|
||||
String pomFileName = getPomFileName(task.getGoal());
|
||||
if (!pomFileName.equals(PathUtil.getFileName(pomXmlPath))) { // fix corrupted configuration
|
||||
pomXmlPath = PathUtil.getParentPath(pomXmlPath) + "/" + pomFileName;
|
||||
}
|
||||
|
||||
VirtualFile file = LocalFileSystem.getInstance().findFileByPath(pomXmlPath);
|
||||
if (file == null) return null;
|
||||
|
||||
@@ -136,7 +143,7 @@ public class MavenBeforeRunTasksProvider extends BeforeRunTaskProvider<MavenBefo
|
||||
return false;
|
||||
}
|
||||
|
||||
task.setProjectPath(dialog.getWorkDirectory() + "/pom.xml");
|
||||
task.setProjectPath(dialog.getWorkDirectory() + "/" + getPomFileName(dialog.getGoals()));
|
||||
task.setGoal(dialog.getGoals());
|
||||
return true;
|
||||
}
|
||||
@@ -206,4 +213,16 @@ public class MavenBeforeRunTasksProvider extends BeforeRunTaskProvider<MavenBefo
|
||||
targetDone.waitFor();
|
||||
return result[0];
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getPomFileName(@Nullable String goals) {
|
||||
if (goals != null) {
|
||||
List<String> commandLine = ParametersListUtil.parse(goals);
|
||||
int pomFileNameIndex = 1 + commandLine.indexOf("-f");
|
||||
if (pomFileNameIndex != 0 && pomFileNameIndex < commandLine.size()) {
|
||||
return commandLine.get(pomFileNameIndex);
|
||||
}
|
||||
}
|
||||
return MavenConstants.POM_XML;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-4
@@ -1,6 +1,6 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o.
|
||||
// Use of this source code is governed by the Apache 2.0 license that can be
|
||||
// found in the LICENSE file.
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.lang.properties;
|
||||
|
||||
import com.intellij.lang.properties.psi.PropertiesFile;
|
||||
@@ -180,7 +180,8 @@ public class PropertiesImplUtil extends PropertiesUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static IProperty getProperty(PsiElement element) {
|
||||
@Nullable
|
||||
public static IProperty getProperty(@Nullable PsiElement element) {
|
||||
if (element instanceof IProperty) {
|
||||
return (IProperty)element;
|
||||
}
|
||||
|
||||
+13
-16
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package com.intellij.lang.properties.editor;
|
||||
@@ -29,6 +17,7 @@ import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -41,6 +30,7 @@ public class ResourceBundlePropertyStructureViewElement implements StructureView
|
||||
private static final TextAttributesKey GROUP_KEY;
|
||||
|
||||
public static final String PROPERTY_GROUP_KEY_TEXT = "<property>";
|
||||
@NotNull
|
||||
private final IProperty myProperty;
|
||||
private String myPresentableName;
|
||||
|
||||
@@ -53,12 +43,19 @@ public class ResourceBundlePropertyStructureViewElement implements StructureView
|
||||
|
||||
private volatile InspectedPropertyProblems myInspectedPropertyProblems;
|
||||
|
||||
public ResourceBundlePropertyStructureViewElement(IProperty property) {
|
||||
public ResourceBundlePropertyStructureViewElement(@NotNull IProperty property) {
|
||||
myProperty = property;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IProperty getProperty() {
|
||||
return myProperty.getPsiElement().isValid() ? myProperty : null;
|
||||
return getPsiElement() != null ? myProperty : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiElement getPsiElement() {
|
||||
PsiElement element = myProperty.getPsiElement();
|
||||
return element.isValid() ? element : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -124,7 +121,7 @@ public class ResourceBundlePropertyStructureViewElement implements StructureView
|
||||
final TextAttributesKey baseAttrKey =
|
||||
(myPresentableName != null && myPresentableName.isEmpty()) ? GROUP_KEY : PropertiesHighlighter.PROPERTY_KEY;
|
||||
final TextAttributes baseAttrs = colorsScheme.getAttributes(baseAttrKey);
|
||||
if (getProperty().getPsiElement().isValid()) {
|
||||
if (getPsiElement() != null) {
|
||||
if (myInspectedPropertyProblems != null) {
|
||||
TextAttributes highlightingAttributes = myInspectedPropertyProblems.getTextAttributes(colorsScheme);
|
||||
if (highlightingAttributes != null) {
|
||||
|
||||
+2
-13
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.lang.properties.editor;
|
||||
|
||||
@@ -96,6 +84,7 @@ public class PropertiesCopyHandler extends CopyHandlerDelegateBase {
|
||||
@Override
|
||||
public void doCopy(PsiElement[] elements, PsiDirectory defaultTargetDirectory) {
|
||||
final IProperty representative = PropertiesImplUtil.getProperty(elements[0]);
|
||||
if (representative == null) return;
|
||||
final String key = representative.getKey();
|
||||
if (key == null) {
|
||||
return;
|
||||
|
||||
+13
-25
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package com.intellij.lang.properties.editor;
|
||||
@@ -205,8 +193,11 @@ public class ResourceBundleEditor extends UserDataHolderBase implements Document
|
||||
TreeElement[] children = myStructureViewComponent.getTreeModel().getRoot().getChildren();
|
||||
if (children.length != 0) {
|
||||
TreeElement child = children[0];
|
||||
String propName = ((ResourceBundlePropertyStructureViewElement)child).getProperty().getUnescapedKey();
|
||||
setState(new ResourceBundleEditorState(propName));
|
||||
IProperty property = ((ResourceBundlePropertyStructureViewElement)child).getProperty();
|
||||
if (property != null) {
|
||||
String propName = property.getUnescapedKey();
|
||||
setState(new ResourceBundleEditorState(propName));
|
||||
}
|
||||
}
|
||||
myDataProviderPanel = new DataProviderPanel(splitPanel);
|
||||
|
||||
@@ -302,17 +293,14 @@ public class ResourceBundleEditor extends UserDataHolderBase implements Document
|
||||
while (!toCheck.isEmpty()) {
|
||||
TreeElement element = toCheck.pop();
|
||||
PsiElement value = element instanceof ResourceBundlePropertyStructureViewElement
|
||||
? ((ResourceBundlePropertyStructureViewElement)element).getProperty().getPsiElement()
|
||||
? ((ResourceBundlePropertyStructureViewElement)element).getPsiElement()
|
||||
: null;
|
||||
if (value != null) {
|
||||
final IProperty property = PropertiesImplUtil.getProperty(value);
|
||||
if (propertyName.equals(property.getUnescapedKey())) {
|
||||
myStructureViewComponent.select(property, true);
|
||||
selectionChanged();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
final IProperty property = PropertiesImplUtil.getProperty(value);
|
||||
if (property != null && propertyName.equals(property.getUnescapedKey())) {
|
||||
myStructureViewComponent.select(property, true);
|
||||
selectionChanged();
|
||||
return;
|
||||
} else {
|
||||
for (TreeElement treeElement : element.getChildren()) {
|
||||
toCheck.push(treeElement);
|
||||
}
|
||||
|
||||
+6
-17
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.lang.properties.editor;
|
||||
|
||||
@@ -101,9 +89,10 @@ public class ResourceBundleEditorHighlighter implements BackgroundEditorHighligh
|
||||
while (!queue.isEmpty()) {
|
||||
final TreeElement treeElement = queue.pullFirst();
|
||||
if (treeElement instanceof ResourceBundlePropertyStructureViewElement) {
|
||||
ResourceBundlePropertyStructureViewElement node = (ResourceBundlePropertyStructureViewElement)treeElement;
|
||||
final String key = node.getProperty().getKey();
|
||||
LOG.assertTrue(key != null);
|
||||
IProperty property = ((ResourceBundlePropertyStructureViewElement)treeElement).getProperty();
|
||||
if (property == null) continue;
|
||||
final String key = property.getKey();
|
||||
if (key == null) continue;
|
||||
SortedSet<HighlightInfoType> highlightTypes = new TreeSet<>(Comparator.comparing(t -> t.getSeverity(null)));
|
||||
List<Pair<ResourceBundleEditorProblemDescriptor, HighlightDisplayKey>> allDescriptors =
|
||||
new SmartList<>();
|
||||
@@ -124,7 +113,7 @@ public class ResourceBundleEditorHighlighter implements BackgroundEditorHighligh
|
||||
}
|
||||
}
|
||||
}
|
||||
node.setInspectedPropertyProblems(allDescriptors.isEmpty()
|
||||
((ResourceBundlePropertyStructureViewElement)treeElement).setInspectedPropertyProblems(allDescriptors.isEmpty()
|
||||
? null
|
||||
: new InspectedPropertyProblems(allDescriptors.toArray(new Pair[allDescriptors.size()]),
|
||||
highlightTypes));
|
||||
|
||||
+8
-17
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.lang.properties.refactoring.rename;
|
||||
|
||||
@@ -33,6 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class RenamePropertyProcessor extends RenamePsiElementProcessor {
|
||||
@Override
|
||||
@@ -44,15 +33,17 @@ public class RenamePropertyProcessor extends RenamePsiElementProcessor {
|
||||
@Override
|
||||
public void prepareRenaming(final PsiElement element, final String newName,
|
||||
final Map<PsiElement, String> allRenames) {
|
||||
ResourceBundle resourceBundle = PropertiesImplUtil.getProperty(element).getPropertiesFile().getResourceBundle();
|
||||
ResourceBundle resourceBundle = Objects.requireNonNull(PropertiesImplUtil.getProperty(element)).getPropertiesFile().getResourceBundle();
|
||||
|
||||
final Map<PsiElement, String> allRenamesCopy = new LinkedHashMap<>(allRenames);
|
||||
allRenames.clear();
|
||||
allRenamesCopy.forEach((key, value) -> {
|
||||
final IProperty property = PropertiesImplUtil.getProperty(key);
|
||||
final List<IProperty> properties = PropertiesUtil.findAllProperties(resourceBundle, property.getUnescapedKey());
|
||||
for (final IProperty toRename : properties) {
|
||||
allRenames.put(toRename.getPsiElement(), value);
|
||||
if (property != null) {
|
||||
final List<IProperty> properties = PropertiesUtil.findAllProperties(resourceBundle, property.getUnescapedKey());
|
||||
for (final IProperty toRename : properties) {
|
||||
allRenames.put(toRename.getPsiElement(), value);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+3
-15
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -82,7 +70,7 @@ public class ResourceBundleFromEditorRenameHandler implements RenameHandler {
|
||||
group.getPresentableName(),
|
||||
group.getPrefix().length() - group.getPresentableName().length());
|
||||
} else if (selectedElement instanceof ResourceBundlePropertyStructureViewElement) {
|
||||
final PsiElement psiElement = ((ResourceBundlePropertyStructureViewElement)selectedElement).getProperty().getPsiElement();
|
||||
final PsiElement psiElement = ((ResourceBundlePropertyStructureViewElement)selectedElement).getPsiElement();
|
||||
ResourceBundleRenameUtil.renameResourceBundleKey(psiElement, project);
|
||||
} else if (selectedElement instanceof ResourceBundleFileStructureViewElement) {
|
||||
ResourceBundleRenameUtil.renameResourceBundleBaseName(((ResourceBundleFileStructureViewElement)selectedElement).getValue(), project);
|
||||
@@ -104,7 +92,7 @@ public class ResourceBundleFromEditorRenameHandler implements RenameHandler {
|
||||
return ((PropertiesStructureViewElement)treeElement).getValue().getPsiElement();
|
||||
}
|
||||
if (treeElement instanceof ResourceBundlePropertyStructureViewElement) {
|
||||
return ((ResourceBundlePropertyStructureViewElement)treeElement).getProperty().getPsiElement();
|
||||
return ((ResourceBundlePropertyStructureViewElement)treeElement).getPsiElement();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
@@ -108,7 +108,7 @@ public class PydevConsoleCommunication extends AbstractConsoleCommunication impl
|
||||
private PythonDebugConsoleCommunication myDebugCommunication;
|
||||
private boolean myNeedsMore = false;
|
||||
|
||||
private PythonConsoleView myConsoleView;
|
||||
private @Nullable PythonConsoleView myConsoleView;
|
||||
private List<PyFrameListener> myFrameListeners = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
|
||||
/**
|
||||
@@ -234,7 +234,9 @@ public class PydevConsoleCommunication extends AbstractConsoleCommunication impl
|
||||
return execNotifyAboutMagic(params);
|
||||
}
|
||||
else if ("ShowConsole".equals(method)) {
|
||||
myConsoleView.setConsoleEnabled(true);
|
||||
if (myConsoleView != null) {
|
||||
myConsoleView.setConsoleEnabled(true);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
else {
|
||||
@@ -401,7 +403,7 @@ public class PydevConsoleCommunication extends AbstractConsoleCommunication impl
|
||||
return; //TODO: handle text input and other cases
|
||||
}
|
||||
nextResponse = null;
|
||||
if (waitingForInput && myConsoleView.isInitialized()) {
|
||||
if (waitingForInput && myConsoleView != null && myConsoleView.isInitialized()) {
|
||||
inputReceived = command.getText();
|
||||
waitingForInput = false;
|
||||
//the thread that we started in the last exec is still alive if we were waiting for an input.
|
||||
@@ -791,7 +793,7 @@ public class PydevConsoleCommunication extends AbstractConsoleCommunication impl
|
||||
}
|
||||
}
|
||||
|
||||
public void setConsoleView(PythonConsoleView consoleView) {
|
||||
public void setConsoleView(@Nullable PythonConsoleView consoleView) {
|
||||
myConsoleView = consoleView;
|
||||
}
|
||||
|
||||
|
||||
@@ -607,8 +607,9 @@ public class PydevConsoleRunnerImpl implements PydevConsoleRunner {
|
||||
// Init console view
|
||||
myConsoleView = createConsoleView();
|
||||
if (myConsoleView != null) {
|
||||
((JComponent)myConsoleView).setBorder(new SideBorder(JBColor.border(), SideBorder.LEFT));
|
||||
myConsoleView.setBorder(new SideBorder(JBColor.border(), SideBorder.LEFT));
|
||||
}
|
||||
myPydevConsoleCommunication.setConsoleView(myConsoleView);
|
||||
myProcessHandler = createProcessHandler(process);
|
||||
|
||||
myConsoleExecuteActionHandler = createExecuteActionHandler();
|
||||
|
||||
+7
-16
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.codeInsight.highlighting;
|
||||
|
||||
@@ -39,15 +27,18 @@ public class HtmlClosingTagErrorFilter extends HighlightErrorFilter {
|
||||
if (psiFile == null || psiFile.getViewProvider().getBaseLanguage() != HTMLLanguage.INSTANCE
|
||||
&& HTMLLanguage.INSTANCE != element.getLanguage()) return true;
|
||||
|
||||
return !skip(element);
|
||||
}
|
||||
|
||||
public static boolean skip(@NotNull PsiErrorElement element) {
|
||||
final PsiElement[] children = element.getChildren();
|
||||
if (children.length > 0) {
|
||||
if (children[0] instanceof XmlToken && XmlTokenType.XML_END_TAG_START == ((XmlToken)children[0]).getTokenType()) {
|
||||
if (XmlErrorMessages.message("xml.parsing.closing.tag.matches.nothing").equals(element.getErrorDescription())) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user