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:
@@ -15,12 +15,11 @@
|
||||
*/
|
||||
package com.intellij.debugger;
|
||||
|
||||
import com.intellij.debugger.impl.DebuggerManagerImpl;
|
||||
import com.intellij.debugger.settings.DebuggerSettings;
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.ExecutionResult;
|
||||
import com.intellij.execution.configurations.RemoteConnection;
|
||||
import com.intellij.execution.configurations.RemoteState;
|
||||
import com.intellij.execution.configurations.RunProfileState;
|
||||
import com.intellij.execution.configurations.SearchScopeProvider;
|
||||
import com.intellij.execution.configurations.*;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -31,6 +30,7 @@ public class DefaultDebugEnvironment implements DebugEnvironment {
|
||||
private final boolean myPollConnection;
|
||||
private final ExecutionEnvironment environment;
|
||||
private final RunProfileState state;
|
||||
private final boolean myNeedParametersSet;
|
||||
|
||||
public DefaultDebugEnvironment(@NotNull ExecutionEnvironment environment, @NotNull RunProfileState state, RemoteConnection remoteConnection, boolean pollConnection) {
|
||||
this.environment = environment;
|
||||
@@ -39,10 +39,19 @@ public class DefaultDebugEnvironment implements DebugEnvironment {
|
||||
myPollConnection = pollConnection;
|
||||
|
||||
mySearchScope = SearchScopeProvider.createSearchScope(environment.getProject(), environment.getRunProfile());
|
||||
myNeedParametersSet = remoteConnection.isServerMode() && remoteConnection.isUseSockets() && "0".equals(remoteConnection.getAddress());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecutionResult createExecutionResult() throws ExecutionException {
|
||||
// debug port may have changed, reinit parameters just in case
|
||||
if (myNeedParametersSet && state instanceof JavaCommandLine) {
|
||||
DebuggerManagerImpl.createDebugParameters(((JavaCommandLine)state).getJavaParameters(),
|
||||
true,
|
||||
DebuggerSettings.SOCKET_TRANSPORT,
|
||||
myRemoteConnection.getAddress(),
|
||||
false);
|
||||
}
|
||||
return state.execute(environment.getExecutor(), environment.getRunner());
|
||||
}
|
||||
|
||||
|
||||
@@ -493,7 +493,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
if (address == null) {
|
||||
throw new CantRunException(DebuggerBundle.message("error.no.debug.listen.port"));
|
||||
}
|
||||
// negative port number means the caller leaves to debugger to decide at which port to listen
|
||||
// zero port number means the caller leaves to debugger to decide at which port to listen
|
||||
//noinspection HardCodedStringLiteral
|
||||
final Connector.Argument portArg = myConnection.isUseSockets() ? myArguments.get("port") : myArguments.get("name");
|
||||
if (portArg != null) {
|
||||
@@ -504,7 +504,13 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
if (timeoutArg != null) {
|
||||
timeoutArg.setValue("0"); // wait forever
|
||||
}
|
||||
connector.startListening(myArguments);
|
||||
String listeningAddress = connector.startListening(myArguments);
|
||||
String port = StringUtil.substringAfter(listeningAddress, ":");
|
||||
if (port != null) {
|
||||
listeningAddress = port;
|
||||
}
|
||||
myConnection.setAddress(listeningAddress);
|
||||
|
||||
myDebugProcessDispatcher.getMulticaster().connectorIsReady();
|
||||
try {
|
||||
return connector.accept(myArguments);
|
||||
|
||||
@@ -73,8 +73,12 @@ public class GenericDebuggerRunner extends JavaPatchableProgramRunner<GenericDeb
|
||||
isPollConnection = ((RemoteConnectionCreator)state).isPollConnection();
|
||||
}
|
||||
if (connection == null) {
|
||||
connection =
|
||||
DebuggerManagerImpl.createDebugParameters(parameters, true, DebuggerSettings.getInstance().DEBUGGER_TRANSPORT, "", false);
|
||||
int transport = DebuggerSettings.getInstance().DEBUGGER_TRANSPORT;
|
||||
connection = DebuggerManagerImpl.createDebugParameters(parameters,
|
||||
true,
|
||||
transport,
|
||||
transport == DebuggerSettings.SOCKET_TRANSPORT ? "0" : "",
|
||||
false);
|
||||
isPollConnection = true;
|
||||
}
|
||||
return attachVirtualMachine(state, environment, connection, isPollConnection);
|
||||
|
||||
+200
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Pavel.Dolgov
|
||||
*/
|
||||
public class SimplifyStreamApiCallChainsInspection extends BaseJavaBatchLocalInspectionTool {
|
||||
public static final Logger LOG = Logger.getInstance("#" + SimplifyStreamApiCallChainsInspection.class.getName());
|
||||
|
||||
public static final String FOR_EACH_METHOD = "forEach";
|
||||
public static final String STREAM_METHOD = "stream";
|
||||
public static final String AS_LIST_METHOD = "asList";
|
||||
public static final String OF_METHOD = "of";
|
||||
|
||||
@Override
|
||||
public boolean isEnabledByDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!PsiUtil.isLanguageLevel8OrHigher(holder.getFile())) {
|
||||
return PsiElementVisitor.EMPTY_VISITOR;
|
||||
}
|
||||
|
||||
return new JavaElementVisitor() {
|
||||
@Override
|
||||
public void visitMethodCallExpression(PsiMethodCallExpression methodCall) {
|
||||
if (isCallOf(methodCall, CommonClassNames.JAVA_UTIL_COLLECTION, STREAM_METHOD, 0)) {
|
||||
final PsiMethodCallExpression qualifierCall = getQualifierMethodCall(methodCall);
|
||||
if (isCallOf(qualifierCall, CommonClassNames.JAVA_UTIL_ARRAYS, AS_LIST_METHOD, 1)) {
|
||||
final PsiExpression[] argumentExpressions = qualifierCall.getArgumentList().getExpressions();
|
||||
if (argumentExpressions.length == 1 && argumentExpressions[0].getType() instanceof PsiArrayType) {
|
||||
holder.registerProblem(methodCall, null, "Arrays.asList().stream() can be replaced with Arrays.stream()",
|
||||
new ArraysAsListSingleArrayFix());
|
||||
}
|
||||
else {
|
||||
holder.registerProblem(methodCall, null, "Arrays.asList().stream() can be replaced with Stream.of()",
|
||||
new ArraysAsListVarargFix());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (isCallOf(methodCall, CommonClassNames.JAVA_UTIL_STREAM_STREAM, FOR_EACH_METHOD, 1)) {
|
||||
final PsiMethodCallExpression qualifierCall = getQualifierMethodCall(methodCall);
|
||||
if (isCallOf(qualifierCall, CommonClassNames.JAVA_UTIL_COLLECTION, STREAM_METHOD, 0)) {
|
||||
holder.registerProblem(methodCall, getCallChainRange(methodCall, qualifierCall),
|
||||
"Collection.stream().forEach() can be replaced with Collection.forEach()",
|
||||
new CollectionForEachFix());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static PsiMethodCallExpression getQualifierMethodCall(PsiMethodCallExpression methodCall) {
|
||||
final PsiExpression qualifierExpression = methodCall.getMethodExpression().getQualifierExpression();
|
||||
if (qualifierExpression instanceof PsiMethodCallExpression) {
|
||||
return (PsiMethodCallExpression)qualifierExpression;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected TextRange getCallChainRange(@NotNull PsiMethodCallExpression expression,
|
||||
@NotNull PsiMethodCallExpression qualifierExpression) {
|
||||
final PsiReferenceExpression qualifierMethodExpression = qualifierExpression.getMethodExpression();
|
||||
final PsiElement qualifierNameElement = qualifierMethodExpression.getReferenceNameElement();
|
||||
final int startOffset = (qualifierNameElement != null ? qualifierNameElement : qualifierMethodExpression).getTextOffset();
|
||||
final int endOffset = expression.getMethodExpression().getTextRange().getEndOffset();
|
||||
return new TextRange(startOffset, endOffset).shiftRight(-expression.getTextOffset());
|
||||
}
|
||||
|
||||
@Contract("null, _, _, _ -> false")
|
||||
protected static boolean isCallOf(@Nullable PsiMethodCallExpression expression,
|
||||
@NotNull String className,
|
||||
@NotNull String methodName,
|
||||
int parametersCount) {
|
||||
if (expression == null) return false;
|
||||
final PsiMethod method = expression.resolveMethod();
|
||||
if (method != null && methodName.equals(method.getName()) && method.getParameterList().getParametersCount() == parametersCount) {
|
||||
final PsiClass containingClass = method.getContainingClass();
|
||||
if (containingClass != null && className.equals(containingClass.getQualifiedName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static abstract class CallChainFixBase implements LocalQuickFix {
|
||||
@Nls
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return getFamilyName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
final PsiElement element = descriptor.getStartElement();
|
||||
if (element instanceof PsiMethodCallExpression) {
|
||||
if (!FileModificationService.getInstance().preparePsiElementForWrite(element.getContainingFile())) return;
|
||||
final PsiMethodCallExpression expression = (PsiMethodCallExpression)element;
|
||||
final PsiExpression forEachMethodQualifier = expression.getMethodExpression().getQualifierExpression();
|
||||
if (forEachMethodQualifier instanceof PsiMethodCallExpression) {
|
||||
final PsiMethodCallExpression previousExpression = (PsiMethodCallExpression)forEachMethodQualifier;
|
||||
final PsiExpression qualifierExpression = previousExpression.getMethodExpression().getQualifierExpression();
|
||||
|
||||
if (qualifierExpression != null) {
|
||||
final String text = createExpressionText(expression, previousExpression, qualifierExpression);
|
||||
final PsiExpression newElement = JavaPsiFacade.getElementFactory(project).createExpressionFromText(text, null);
|
||||
final PsiElement shortenedElement = JavaCodeStyleManager.getInstance(project).shortenClassReferences(newElement);
|
||||
element.replace(shortenedElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected abstract String createExpressionText(@NotNull PsiMethodCallExpression methodCall,
|
||||
@NotNull PsiMethodCallExpression qualifierCall,
|
||||
@NotNull PsiExpression qualifierExpression);
|
||||
}
|
||||
|
||||
private static class ArraysAsListVarargFix extends CallChainFixBase {
|
||||
|
||||
@Nls
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Replace Arrays.asList().stream() with Stream.of()";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected String createExpressionText(@NotNull PsiMethodCallExpression methodCall,
|
||||
@NotNull PsiMethodCallExpression qualifierCall,
|
||||
@NotNull PsiExpression qualifierExpression) {
|
||||
return (CommonClassNames.JAVA_UTIL_STREAM_STREAM + "." + OF_METHOD) + qualifierCall.getArgumentList().getText();
|
||||
}
|
||||
}
|
||||
|
||||
private static class ArraysAsListSingleArrayFix extends CallChainFixBase {
|
||||
@Nls
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Replace Arrays.asList().stream() with Arrays.stream()";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected String createExpressionText(@NotNull PsiMethodCallExpression methodCall,
|
||||
@NotNull PsiMethodCallExpression qualifierCall,
|
||||
@NotNull PsiExpression qualifierExpression) {
|
||||
return (CommonClassNames.JAVA_UTIL_ARRAYS + "." + STREAM_METHOD) + qualifierCall.getArgumentList().getText();
|
||||
}
|
||||
}
|
||||
|
||||
private static class CollectionForEachFix extends CallChainFixBase {
|
||||
@Nls
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Replace Collection.stream().forEach() with Collection.forEach()";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String createExpressionText(@NotNull PsiMethodCallExpression methodCall,
|
||||
@NotNull PsiMethodCallExpression qualifierCall,
|
||||
@NotNull PsiExpression qualifierExpression) {
|
||||
return qualifierExpression.getText() + "." + FOR_EACH_METHOD + methodCall.getArgumentList().getText();
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
@@ -38,6 +38,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.SuggestedNameInfo;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.PsiPolyExpressionUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
@@ -318,6 +319,7 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction/*, Hig
|
||||
buf.append(presentableText);
|
||||
}
|
||||
else {
|
||||
if (PsiPolyExpressionUtil.isPolyExpression(expression)) return null;
|
||||
PsiType exprType = RefactoringUtil.getTypeByExpression(expression);
|
||||
if (exprType == null) return null;
|
||||
if (exprType instanceof PsiDisjunctionType) {
|
||||
@@ -391,6 +393,7 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction/*, Hig
|
||||
}
|
||||
else if (expression != null) {
|
||||
if (varargParam != null && pi >= parameters.length) return false;
|
||||
if (PsiPolyExpressionUtil.isPolyExpression(expression)) return false;
|
||||
PsiType exprType = RefactoringUtil.getTypeByExpression(expression);
|
||||
if (exprType == null) return false;
|
||||
if (exprType instanceof PsiDisjunctionType) {
|
||||
|
||||
+12
-3
@@ -110,8 +110,17 @@ public class CreateMethodFromMethodReferenceFix extends CreateFromUsageBaseFix {
|
||||
expression = getMethodReference();
|
||||
LOG.assertTrue(expression.isValid());
|
||||
|
||||
if (!expression.isConstructor() && shouldCreateStaticMember(expression, targetClass)) {
|
||||
PsiUtil.setModifierProperty(method, PsiModifier.STATIC, true);
|
||||
boolean shouldBeAbstract = false;
|
||||
if (!expression.isConstructor()) {
|
||||
if (shouldCreateStaticMember(expression, targetClass)) {
|
||||
PsiUtil.setModifierProperty(method, PsiModifier.STATIC, true);
|
||||
}
|
||||
else if (targetClass.isInterface()) {
|
||||
shouldBeAbstract = true;
|
||||
PsiCodeBlock body = method.getBody();
|
||||
assert body != null;
|
||||
body.delete();
|
||||
}
|
||||
}
|
||||
|
||||
final PsiElement context = PsiTreeUtil.getParentOfType(expression, PsiClass.class, PsiMethod.class);
|
||||
@@ -126,7 +135,7 @@ public class CreateMethodFromMethodReferenceFix extends CreateFromUsageBaseFix {
|
||||
|
||||
final PsiSubstitutor substitutor = LambdaUtil.getSubstitutor(interfaceMethod, classResolveResult);
|
||||
final ExpectedTypeInfo[] expectedTypes = {new ExpectedTypeInfoImpl(interfaceReturnType, ExpectedTypeInfo.TYPE_OR_SUBTYPE, interfaceReturnType, TailType.NONE, null, ExpectedTypeInfoImpl.NULL)};
|
||||
CreateMethodFromUsageFix.doCreate(targetClass, method, false,
|
||||
CreateMethodFromUsageFix.doCreate(targetClass, method, shouldBeAbstract,
|
||||
ContainerUtil.map2List(interfaceMethod.getParameterList().getParameters(), parameter -> Pair.create(null, substitutor.substitute(parameter.getType()))),
|
||||
PsiSubstitutor.EMPTY,
|
||||
expectedTypes, context);
|
||||
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.generation.surroundWith;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtil;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiStatement;
|
||||
import com.intellij.psi.PsiWhiteSpace;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class JavaSurroundWithStatementRangeAdjuster implements SurroundWithRangeAdjuster {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TextRange adjustSurroundWithRange(PsiFile file, TextRange selectedRange) {
|
||||
return selectedRange;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TextRange adjustSurroundWithRange(PsiFile file, TextRange selectedRange, boolean hasSelection) {
|
||||
if (!hasSelection) {
|
||||
int startOffset = selectedRange.getStartOffset();
|
||||
int endOffset = selectedRange.getEndOffset();
|
||||
if (CodeInsightUtil.findStatementsInRange(file, startOffset, endOffset).length == 0) {
|
||||
PsiElement elementAtLineStart = PsiTreeUtil.skipSiblingsForward(file.findElementAt(startOffset), PsiWhiteSpace.class);
|
||||
if (elementAtLineStart instanceof PsiStatement) {
|
||||
return elementAtLineStart.getTextRange();
|
||||
}
|
||||
}
|
||||
}
|
||||
return selectedRange;
|
||||
}
|
||||
}
|
||||
@@ -47,13 +47,15 @@ import com.intellij.psi.util.PsiTreeUtil
|
||||
import com.sun.tools.doclint.DocLint
|
||||
import java.io.File
|
||||
|
||||
class JavadocHtmlLintAnnotator : ExternalAnnotator<JavadocHtmlLintAnnotator.Info, JavadocHtmlLintAnnotator.Result>() {
|
||||
class JavadocHtmlLintAnnotator(private val manual: Boolean = false) :
|
||||
ExternalAnnotator<JavadocHtmlLintAnnotator.Info, JavadocHtmlLintAnnotator.Result>() {
|
||||
|
||||
data class Info(val file: PsiFile)
|
||||
data class Anno(val row: Int, val col: Int, val error: Boolean, val message: String)
|
||||
data class Result(val annotations: List<Anno>)
|
||||
|
||||
override fun collectInformation(file: PsiFile): Info? =
|
||||
if (isJava8SourceFile(file) && file.text.contains("/**") && isToolEnabled(file)) Info(file) else null
|
||||
if (isJava8SourceFile(file) && "/**" in file.text && isToolEnabled(file)) Info(file) else null
|
||||
|
||||
override fun doAnnotate(collectedInfo: Info): Result? {
|
||||
val file = collectedInfo.file.virtualFile!!
|
||||
@@ -116,7 +118,7 @@ class JavadocHtmlLintAnnotator : ExternalAnnotator<JavadocHtmlLintAnnotator.Info
|
||||
file.virtualFile != null && ProjectFileIndex.SERVICE.getInstance(file.project).isInSourceContent(file.virtualFile)
|
||||
|
||||
private fun isToolEnabled(file: PsiFile) =
|
||||
InspectionProjectProfileManager.getInstance(file.project).inspectionProfile.isToolEnabled(key.value, file)
|
||||
manual || InspectionProjectProfileManager.getInstance(file.project).inspectionProfile.isToolEnabled(key.value, file)
|
||||
|
||||
private fun createTempFile(bytes: ByteArray): File {
|
||||
val tempFile = FileUtil.createTempFile(File(PathManager.getTempPath()), "javadocHtmlLint", ".java")
|
||||
|
||||
@@ -20,8 +20,6 @@ import com.intellij.codeInspection.LocalInspectionTool
|
||||
import com.intellij.codeInspection.ProblemsHolder
|
||||
import com.intellij.codeInspection.SuppressQuickFix
|
||||
import com.intellij.codeInspection.ex.UnfairLocalInspectionTool
|
||||
import com.intellij.lang.ExternalLanguageAnnotators
|
||||
import com.intellij.lang.java.JavaLanguage
|
||||
import com.intellij.psi.PsiElement
|
||||
|
||||
class JavadocHtmlLintInspection : LocalInspectionTool(), UnfairLocalInspectionTool {
|
||||
@@ -29,9 +27,7 @@ class JavadocHtmlLintInspection : LocalInspectionTool(), UnfairLocalInspectionTo
|
||||
val SHORT_NAME = "JavadocHtmlLint"
|
||||
}
|
||||
|
||||
private val annotator = lazy {
|
||||
ExternalLanguageAnnotators.INSTANCE.allForLanguage(JavaLanguage.INSTANCE).find { it is JavadocHtmlLintAnnotator }
|
||||
}
|
||||
private val annotator = lazy { JavadocHtmlLintAnnotator(true) }
|
||||
|
||||
override fun buildVisitor(holder: ProblemsHolder, onTheFly: Boolean) = ExternalAnnotatorInspectionVisitor(holder, annotator.value, onTheFly)
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@ public class JavaPullUpHelper implements PullUpHelper<MemberInfo> {
|
||||
RefactoringUtil.replaceMovedMemberTypeParameters(methodCopy, PsiUtil.typeParametersIterable(mySourceClass), substitutor, elementFactory);
|
||||
|
||||
Language language = myTargetSuperClass.getLanguage();
|
||||
final PsiMethod superClassMethod = myTargetSuperClass.findMethodBySignature(methodCopy, false);
|
||||
final PsiMethod superClassMethod = MethodSignatureUtil.findMethodBySuperSignature(myTargetSuperClass, method.getSignature(substitutor), false);
|
||||
if (superClassMethod != null && superClassMethod.findDeepestSuperMethods().length == 0 ||
|
||||
method.findSuperMethods(myTargetSuperClass).length == 0) {
|
||||
deleteOverrideAnnotationIfFound(methodCopy);
|
||||
|
||||
@@ -47,6 +47,7 @@ import com.intellij.util.containers.EmptyIterable;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import org.intellij.lang.annotations.MagicConstant;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -1069,12 +1070,14 @@ public final class PsiUtil extends PsiUtilCore {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Contract("null, _ -> null")
|
||||
@Nullable
|
||||
public static PsiType extractIterableTypeParameter(@Nullable PsiType psiType, final boolean eraseTypeParameter) {
|
||||
final PsiType type = substituteTypeParameter(psiType, CommonClassNames.JAVA_LANG_ITERABLE, 0, eraseTypeParameter);
|
||||
return type != null ? type : substituteTypeParameter(psiType, CommonClassNames.JAVA_UTIL_COLLECTION, 0, eraseTypeParameter);
|
||||
}
|
||||
|
||||
@Contract("null, _, _, _ -> null")
|
||||
@Nullable
|
||||
public static PsiType substituteTypeParameter(@Nullable final PsiType psiType, @NotNull final String superClass, final int typeParamIndex,
|
||||
final boolean eraseTypeParameter) {
|
||||
|
||||
@@ -663,6 +663,10 @@ public class RedundantCastUtil {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (operand instanceof PsiFunctionalExpression && !castTo.equals(PsiTypesUtil.getExpectedTypeByParent(parent))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (arrayAccessAtTheLeftSideOfAssignment(parent, typeCast)) {
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import java.util.function.Supplier;
|
||||
|
||||
class Test {
|
||||
{
|
||||
Object o = true ? ((Supplier<String>) () -> "") : null;
|
||||
Supplier<String> s1 = true ? ((<warning descr="Casting '() -> \"\"' to 'Supplier<String>' is redundant">Supplier<String></warning>) () -> "") : null;
|
||||
Supplier<String> s2 = true ? ((A) () -> "") : null;
|
||||
}
|
||||
|
||||
interface A extends Supplier<String> {}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Change 1st parameter of method 'foo' from 'ArrayList<String>' to 'HashSet<E>'" "false"
|
||||
// "<html> Change signature of foo(<s>ArrayList<String></s> <b>HashSet<E></b>)</html>" "false"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "<html> Change signature of foo(<s>boolean</s> <b>HashSet<E></b>)</html>" "false"
|
||||
import java.util.*;
|
||||
class IntentionIssue {
|
||||
void foo(boolean b) {}
|
||||
void foo(ArrayList<String> lst) {}
|
||||
|
||||
void bar() {
|
||||
foo(new Hash<caret>Set<>());
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Create method 'fooBar'" "true"
|
||||
class FooBar {
|
||||
interface A {
|
||||
void fooBar();
|
||||
}
|
||||
void m(A a){
|
||||
Runnable r = a::fooBar;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// "Create method 'fooBar'" "true"
|
||||
class FooBar {
|
||||
interface A {}
|
||||
void m(A a){
|
||||
Runnable r = a::foo<caret>Bar;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
{
|
||||
<caret> for(int i = 0; i< 9; i++) {
|
||||
System.out.println("42");
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Test {
|
||||
{
|
||||
if () {
|
||||
for(int i = 0; i< 9; i++) {
|
||||
System.out.println("42");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Replace Arrays.asList().stream() with Arrays.stream()" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
class AsListArrayStream {
|
||||
String max(String[] args) {
|
||||
return Arrays.stream(args).max(String::compareTo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Replace Arrays.asList().stream() with Stream.of()" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
class AsListLiteralStream {
|
||||
Stream<String> abc() {
|
||||
return Stream.of("a", "b", "c");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Replace Collection.stream().forEach() with Collection.forEach()" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
class Test {
|
||||
void print() {
|
||||
Collection<Character> def = Arrays.asList('d', 'e', 'f');
|
||||
def.forEach(c -> System.out.print(" " + c));
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace Collection.stream().forEach() with Collection.forEach()" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
class Test {
|
||||
void print() {
|
||||
Collection<Character> def = Arrays.asList('d', 'e', 'f');
|
||||
def.forEach(System.out::print);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Replace Arrays.asList().stream() with Arrays.stream()" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
class AsListArrayStream {
|
||||
String max(String[] args) {
|
||||
return Arrays.asL<caret>ist(args).stream().max(String::compareTo);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace Arrays.asList().stream() with Stream.of()" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
class AsListLiteralStream {
|
||||
Stream<String> abc() {
|
||||
return Arrays.asList("a", "b", "c").stre<caret>am();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace Collection.stream().forEach() with Collection.forEach()" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
class Test {
|
||||
void print() {
|
||||
Collection<Character> def = Arrays.asList('d', 'e', 'f');
|
||||
def.st<caret>ream().forEach(c -> System.out.print(" " + c));
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace Collection.stream().forEach() with Collection.forEach()" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
class Test {
|
||||
void print() {
|
||||
Collection<Character> def = Arrays.asList('d', 'e', 'f');
|
||||
def.stream().forE<caret>ach(System.out::print);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
abstract class C<T> {
|
||||
abstract void foo(T t);
|
||||
|
||||
@Override
|
||||
void foo(T t) {
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -80,6 +80,7 @@ public class LambdaRedundantCastTest extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
|
||||
public void testInvalidResolveWithoutCast() { doTest();}
|
||||
public void testCastInConditionalBranch() { doTest();}
|
||||
|
||||
public void testRejectReturnTypeChange() throws Exception {
|
||||
doTest();
|
||||
|
||||
+3
@@ -19,6 +19,9 @@ import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class ChangeMethodSignatureFromUsage8Test extends LightQuickFixParameterizedTestCase {
|
||||
|
||||
public void test() throws Exception { doAllTests(); }
|
||||
|
||||
+4
@@ -96,6 +96,10 @@ public class JavaSurroundWithTest extends LightCodeInsightTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testSurroundWithStatementWithoutSelection() throws Exception {
|
||||
doTest(new JavaWithIfSurrounder());
|
||||
}
|
||||
|
||||
public void testSurroundNonExpressionWithParenthesis() throws Exception {
|
||||
doTest(new JavaWithParenthesesSurrounder());
|
||||
}
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Pavel.Dolgov
|
||||
*/
|
||||
public class SimplifyStreamApiCallChainsInspectionTest extends LightQuickFixParameterizedTestCase {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected LocalInspectionTool[] configureLocalInspectionTools() {
|
||||
return new LocalInspectionTool[]{new SimplifyStreamApiCallChainsInspection()};
|
||||
}
|
||||
|
||||
public void test() throws Exception {
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return IdeaTestUtil.getMockJdk18();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/inspection/streamApiCallChains";
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.navigation
|
||||
|
||||
import com.intellij.ide.actions.GotoFileItemProvider
|
||||
import com.intellij.ide.util.gotoByName.ChooseByNamePopup
|
||||
import com.intellij.ide.util.gotoByName.GotoClassModel2
|
||||
import com.intellij.ide.util.gotoByName.GotoFileModel
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.ReadAction
|
||||
import com.intellij.openapi.module.ModuleUtilCore
|
||||
import com.intellij.openapi.module.StdModuleTypes
|
||||
import com.intellij.openapi.roots.ModuleRootModificationUtil
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.testFramework.PsiTestUtil
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase
|
||||
import org.jetbrains.annotations.NotNull
|
||||
/**
|
||||
@@ -42,6 +49,21 @@ class ChooseByNameHddTest extends JavaCodeInsightFixtureTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void "test prefer same-named classes visible in current module"() {
|
||||
int moduleCount = 10
|
||||
def modules = (0..moduleCount-1).collect {
|
||||
PsiTestUtil.addModule(project, StdModuleTypes.JAVA, "mod$it", myFixture.tempDirFixture.findOrCreateDir("mod$it"))
|
||||
}
|
||||
ModuleRootModificationUtil.addDependency(myFixture.module, modules[2])
|
||||
(0..moduleCount-1).each { myFixture.addFileToProject("mod$it/Foo.java", "class Foo {}") }
|
||||
|
||||
def place = myFixture.addClass("class A {}")
|
||||
def popup = ReadAction.compute { ChooseByNamePopup.createPopup(project, new GotoClassModel2(project), place) }
|
||||
def resultModules = ChooseByNameTest.calcPopupElements(popup, 'Foo').collect { ModuleUtilCore.findModuleForPsiElement(it).name }
|
||||
assert resultModules[0] == 'mod2'
|
||||
popup.close(false)
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean runInDispatchThread() {
|
||||
return false
|
||||
|
||||
@@ -112,6 +112,7 @@ public class ChangeSignatureGestureTest extends LightCodeInsightFixtureTestCase
|
||||
public void testAddParamChangeReturnType() {
|
||||
doTest(() -> {
|
||||
myFixture.type("int param");
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
CaretModel model = myFixture.getEditor().getCaretModel();
|
||||
PsiElement element = myFixture.getElementAtCaret();
|
||||
PsiMethod method = PsiTreeUtil.getParentOfType(element, PsiMethod.class, false);
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.google.gson.stream.MalformedJsonException;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
@@ -50,6 +49,7 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.http.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.builtInWebServer.BuiltInWebServerKt;
|
||||
import org.jetbrains.io.NettyKt;
|
||||
import org.jetbrains.io.Responses;
|
||||
|
||||
@@ -178,6 +178,10 @@ public abstract class RestService extends HttpRequestHandler {
|
||||
|
||||
// e.g. upsource trust to configured host
|
||||
protected boolean isHostTrusted(@NotNull FullHttpRequest request) throws InterruptedException, InvocationTargetException {
|
||||
if (BuiltInWebServerKt.isSignedRequest(request)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String referrer = NettyKt.getOrigin(request);
|
||||
if (referrer == null) {
|
||||
referrer = NettyKt.getReferrer(request);
|
||||
@@ -199,8 +203,6 @@ public abstract class RestService extends HttpRequestHandler {
|
||||
else {
|
||||
isTrusted.set(trustedOrigins.getIfPresent(host));
|
||||
}
|
||||
} else if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
isTrusted.set(Boolean.TRUE); // make the tests pass
|
||||
}
|
||||
|
||||
if (isTrusted.isNull()) {
|
||||
|
||||
@@ -64,9 +64,11 @@ internal class RestApiTest : BuiltInServerTestCase() {
|
||||
val column = manager.annotation?.column ?: -1
|
||||
|
||||
var connection = URL("$serviceUrl?file=${manager.filePath ?: ""}&line=$line&column=$column").openConnection() as HttpURLConnection
|
||||
BuiltInServerManager.getInstance().configureRequestToWebServer(connection)
|
||||
assertThat(HttpResponseStatus.valueOf(connection.responseCode)).isEqualTo(expectedStatus)
|
||||
|
||||
connection = URL("$serviceUrl").openConnection() as HttpURLConnection
|
||||
BuiltInServerManager.getInstance().configureRequestToWebServer(connection)
|
||||
connection.requestMethod = "POST"
|
||||
connection.doOutput = true
|
||||
JsonWriter(connection.outputStream.bufferedWriter()).use {
|
||||
|
||||
@@ -54,7 +54,6 @@ public abstract class PsiCachedValue<T> extends CachedValueBase<T> {
|
||||
o instanceof PsiModificationTracker ||
|
||||
o == PsiModificationTracker.MODIFICATION_COUNT ||
|
||||
o == PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT ||
|
||||
o == PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT ||
|
||||
o == PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT;
|
||||
}
|
||||
});
|
||||
|
||||
+9
-4
@@ -153,14 +153,16 @@ public class LayeredLexerEditorHighlighter extends LexerEditorHighlighter {
|
||||
|
||||
protected boolean updateLayers() { return false; }
|
||||
|
||||
@SuppressWarnings("NonSynchronizedMethodOverridesSynchronizedMethod")
|
||||
@Override
|
||||
public void documentChanged(DocumentEvent e) {
|
||||
// do NOT synchronize before updateLayers due to deadlock with PsiLock
|
||||
boolean changed = updateLayers();
|
||||
|
||||
//noinspection SynchronizeOnThis
|
||||
synchronized (this) {
|
||||
if (changed) {
|
||||
setText(e.getDocument().getImmutableCharSequence());
|
||||
super.setText(e.getDocument().getImmutableCharSequence());
|
||||
}
|
||||
else {
|
||||
super.documentChanged(e);
|
||||
@@ -174,11 +176,14 @@ public class LayeredLexerEditorHighlighter extends LexerEditorHighlighter {
|
||||
// do NOT synchronize before updateLayers due to deadlock with PsiLock
|
||||
final boolean changed = updateLayers();
|
||||
|
||||
//noinspection SynchronizeOnThis
|
||||
synchronized (this) {
|
||||
if (changed) {
|
||||
CharSequence text = myText;
|
||||
myText = null;
|
||||
setText(text);
|
||||
Document document = getDocument();
|
||||
if (document != null) {
|
||||
myText = null;
|
||||
super.setText(document.getImmutableCharSequence());
|
||||
}
|
||||
}
|
||||
return new LayeredHighlighterIteratorImpl(startOffset);
|
||||
}
|
||||
|
||||
+3
@@ -28,4 +28,7 @@ public interface SurroundWithRangeAdjuster {
|
||||
ExtensionPointName<SurroundWithRangeAdjuster> EP_NAME = ExtensionPointName.create("com.intellij.codeInsight.surroundWithRangeAdjuster");
|
||||
|
||||
@Nullable TextRange adjustSurroundWithRange(PsiFile file, TextRange selectedRange);
|
||||
@Nullable default TextRange adjustSurroundWithRange(PsiFile file, TextRange selectedRange, boolean hasSelection) {
|
||||
return adjustSurroundWithRange(file, selectedRange);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,18 +140,7 @@ public class TargetElementUtil extends TargetElementUtilBase {
|
||||
|
||||
private static PsiFile getFile(Project project, Document document) {
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document);
|
||||
|
||||
if (file != null) {
|
||||
if (ApplicationManager.getApplication().isDispatchThread()) {
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
}
|
||||
|
||||
if (file instanceof PsiCompiledFile) {
|
||||
file = ((PsiCompiledFile)file).getDecompiledPsiFile();
|
||||
}
|
||||
}
|
||||
|
||||
return file;
|
||||
return file instanceof PsiCompiledFile ? ((PsiCompiledFile)file).getDecompiledPsiFile() : file;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-2
@@ -94,7 +94,8 @@ public class SurroundWithHandler implements CodeInsightActionHandler {
|
||||
@Nullable
|
||||
public static List<AnAction> buildSurroundActions(final Project project, final Editor editor, PsiFile file, @Nullable Surrounder surrounder){
|
||||
SelectionModel selectionModel = editor.getSelectionModel();
|
||||
if (!selectionModel.hasSelection()) {
|
||||
boolean hasSelection = selectionModel.hasSelection();
|
||||
if (!hasSelection) {
|
||||
selectionModel.selectLineAtCaret();
|
||||
}
|
||||
int startOffset = selectionModel.getSelectionStart();
|
||||
@@ -109,7 +110,7 @@ public class SurroundWithHandler implements CodeInsightActionHandler {
|
||||
|
||||
TextRange textRange = new TextRange(startOffset, endOffset);
|
||||
for(SurroundWithRangeAdjuster adjuster: Extensions.getExtensions(SurroundWithRangeAdjuster.EP_NAME)) {
|
||||
textRange = adjuster.adjustSurroundWithRange(file, textRange);
|
||||
textRange = adjuster.adjustSurroundWithRange(file, textRange, hasSelection);
|
||||
if (textRange == null) return null;
|
||||
}
|
||||
startOffset = textRange.getStartOffset();
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ public abstract class TemplateLanguageErrorFilter extends HighlightErrorFilter {
|
||||
|
||||
protected boolean isKnownSubLanguage(@NotNull final Language language) {
|
||||
for (Language knownLanguage : knownLanguageSet) {
|
||||
if (language.is(knownLanguage)) {
|
||||
if (language.is(knownLanguage) || knownLanguage.getDialects().contains(language)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,8 @@ public class ParameterInfoComponent extends JPanel {
|
||||
private final Font NORMAL_FONT;
|
||||
private final Font BOLD_FONT;
|
||||
|
||||
private static final Border BACKGROUND_BORDER = BorderFactory.createLineBorder(BACKGROUND_COLOR);
|
||||
private static final Border LAST_ITEM_BORDER = BorderFactory.createEmptyBorder();
|
||||
private static final Border BOTTOM_BORDER = new SideBorder(new JBColor(JBColor.LIGHT_GRAY, Gray._90), SideBorder.BOTTOM);
|
||||
|
||||
protected int myWidthLimit = 500;
|
||||
|
||||
@@ -166,14 +167,14 @@ public class ParameterInfoComponent extends JPanel {
|
||||
Color background) {
|
||||
final String resultedText =
|
||||
myPanels[i].setup(text, myEscapeFunction, highlightStartOffset, highlightEndOffset, isDisabled, strikeout, isDisabledBeforeHighlight, background);
|
||||
myPanels[i].setBorder(isLastParameterOwner() ? BACKGROUND_BORDER : new SideBorder(new JBColor(JBColor.LIGHT_GRAY, Gray._90), SideBorder.BOTTOM));
|
||||
myPanels[i].setBorder(isLastParameterOwner() ? LAST_ITEM_BORDER : BOTTOM_BORDER);
|
||||
return resultedText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String setupUIComponentPresentation(final String[] texts, final EnumSet<Flag>[] flags, final Color background) {
|
||||
final String resultedText = myPanels[i].setup(texts, myEscapeFunction, flags, background);
|
||||
myPanels[i].setBorder(isLastParameterOwner() ? BACKGROUND_BORDER : new SideBorder(new JBColor(JBColor.LIGHT_GRAY, Gray._90), SideBorder.BOTTOM));
|
||||
myPanels[i].setBorder(isLastParameterOwner() ? LAST_ITEM_BORDER : BOTTOM_BORDER);
|
||||
return resultedText;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,12 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: cdr
|
||||
* Date: Aug 6, 2007
|
||||
* Time: 3:09:55 PM
|
||||
*/
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.ide.DataManager;
|
||||
@@ -38,7 +32,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.encoding.ChangeFileEncodingAction;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingUtil;
|
||||
@@ -104,7 +97,7 @@ public class LossyEncodingInspection extends LocalInspectionTool {
|
||||
// no sense in checking transparently decoded file: all characters there are already safely encoded
|
||||
if (charset instanceof Native2AsciiCharset) return null;
|
||||
|
||||
List<ProblemDescriptor> descriptors = new SmartList<ProblemDescriptor>();
|
||||
List<ProblemDescriptor> descriptors = new SmartList<>();
|
||||
boolean ok = checkFileLoadedInWrongEncoding(file, manager, isOnTheFly, virtualFile, charset, descriptors);
|
||||
if (ok) {
|
||||
checkIfCharactersWillBeLostAfterSave(file, manager, isOnTheFly, text, charset, descriptors);
|
||||
@@ -173,11 +166,11 @@ public class LossyEncodingInspection extends LocalInspectionTool {
|
||||
@NotNull List<ProblemDescriptor> descriptors) {
|
||||
int errorCount = 0;
|
||||
int start = -1;
|
||||
CharBuffer buffer = CharBuffer.wrap(text); // temp buffer for encoding/decoding back a char or a surrogate pair.
|
||||
for (int i = 0; i <= text.length(); i++) {
|
||||
char c = i >= text.length() ? 0 : text.charAt(i);
|
||||
char next = i + 1 >= text.length() ? 0 : text.charAt(i + 1);
|
||||
char prev = i == 0 ? 0 : text.charAt(i - 1);
|
||||
if (i == text.length() || isRepresentable(c, next, prev, charset)) {
|
||||
int end = Character.isHighSurrogate(c) && i<text.length()-1 ? i + 2 : i+1;
|
||||
if (i == text.length() || isRepresentable(buffer, i, end, charset)) {
|
||||
if (start != -1) {
|
||||
TextRange range = new TextRange(start, i);
|
||||
String message = InspectionsBundle.message("unsupported.character.for.the.charset", charset);
|
||||
@@ -192,17 +185,22 @@ public class LossyEncodingInspection extends LocalInspectionTool {
|
||||
else if (start == -1) {
|
||||
start = i;
|
||||
}
|
||||
if (end != i+1) {
|
||||
i++; // skip surrogate low
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isRepresentable(final char c, final char next, char prev, @NotNull Charset charset) {
|
||||
if (charset == CharsetToolkit.UTF8_CHARSET) {
|
||||
if (Character.isSurrogatePair(c, next) || Character.isSurrogatePair(prev, c)) return true;
|
||||
}
|
||||
String str = String.valueOf(c);
|
||||
ByteBuffer out = charset.encode(str);
|
||||
private static boolean isRepresentable(@NotNull CharBuffer srcBuffer,
|
||||
int start,
|
||||
int end,
|
||||
@NotNull Charset charset) {
|
||||
srcBuffer.position(start);
|
||||
srcBuffer.limit(end);
|
||||
ByteBuffer out = charset.encode(srcBuffer);
|
||||
CharBuffer buffer = charset.decode(out);
|
||||
return str.equals(buffer.toString());
|
||||
srcBuffer.position(start);
|
||||
return buffer.equals(srcBuffer);
|
||||
}
|
||||
|
||||
private static class ReloadInAnotherEncodingFix extends ChangeEncodingFix {
|
||||
@@ -246,7 +244,7 @@ public class LossyEncodingInspection extends LocalInspectionTool {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static DataContext createDataContext(Editor editor, Component component, VirtualFile selectedFile, Project project) {
|
||||
static DataContext createDataContext(Editor editor, Component component, VirtualFile selectedFile, Project project) {
|
||||
DataContext parent = DataManager.getInstance().getDataContext(component);
|
||||
DataContext context = SimpleDataContext.getSimpleContext(PlatformDataKeys.CONTEXT_COMPONENT.getName(), editor == null ? null : editor.getComponent(), parent);
|
||||
DataContext projectContext = SimpleDataContext.getSimpleContext(CommonDataKeys.PROJECT.getName(), project, context);
|
||||
|
||||
+10
-12
@@ -638,19 +638,17 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
|
||||
}
|
||||
}
|
||||
|
||||
ReadAction.run(() -> {
|
||||
for (GlobalInspectionContextExtension extension : myExtensions.values()) {
|
||||
try {
|
||||
extension.performPostRunActivities(needRepeatSearchRequest, this);
|
||||
}
|
||||
catch (ProcessCanceledException | IndexNotReadyException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
for (GlobalInspectionContextExtension extension : myExtensions.values()) {
|
||||
try {
|
||||
extension.performPostRunActivities(needRepeatSearchRequest, this);
|
||||
}
|
||||
});
|
||||
catch (ProcessCanceledException | IndexNotReadyException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
if (myView == null && !ReadAction.compute(() -> InspectionResultsView.hasProblems(globalTools, this, createContentProvider())).booleanValue()) {
|
||||
return;
|
||||
|
||||
@@ -178,7 +178,14 @@ public final class LanguageConsoleBuilder {
|
||||
|
||||
@NotNull
|
||||
public LanguageConsoleView build(@NotNull Project project, @NotNull Language language) {
|
||||
GutteredLanguageConsole consoleView = new GutteredLanguageConsole(new MyHelper(project, language.getDisplayName() + " Console", language, psiFileFactory), gutterContentProvider);
|
||||
return build(project, language, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public LanguageConsoleView build(@NotNull Project project, @NotNull Language language, @Nullable VirtualFile virtualFileToReuse) {
|
||||
final VirtualFile virtualFile =
|
||||
virtualFileToReuse != null ? virtualFileToReuse : new LightVirtualFile(language.getDisplayName() + " Console", language, "");
|
||||
GutteredLanguageConsole consoleView = new GutteredLanguageConsole(new MyHelper(project, virtualFile, psiFileFactory), gutterContentProvider);
|
||||
if (oneLineInput) {
|
||||
consoleView.getConsoleEditor().setOneLineMode(true);
|
||||
}
|
||||
@@ -204,8 +211,10 @@ public final class LanguageConsoleBuilder {
|
||||
|
||||
GutteredLanguageConsole console;
|
||||
|
||||
public MyHelper(@NotNull Project project, @NotNull String title, @NotNull Language language, @Nullable PairFunction<VirtualFile, Project, PsiFile> psiFileFactory) {
|
||||
super(project, new LightVirtualFile(title, language, ""));
|
||||
public MyHelper(@NotNull Project project,
|
||||
@NotNull VirtualFile virtualFile,
|
||||
@Nullable PairFunction<VirtualFile, Project, PsiFile> psiFileFactory) {
|
||||
super(project, virtualFile);
|
||||
this.psiFileFactory = psiFileFactory;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.psi.util.proximity;
|
||||
|
||||
import com.intellij.openapi.util.NotNullLazyKey;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.ProximityLocation;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class InResolveScopeWeigher extends ProximityWeigher {
|
||||
private static final NotNullLazyKey<GlobalSearchScope, ProximityLocation> PLACE_SCOPE = NotNullLazyKey.create("placeScope", location -> {
|
||||
PsiElement position = location.getPosition();
|
||||
return position == null ? GlobalSearchScope.EMPTY_SCOPE : position.getResolveScope();
|
||||
});
|
||||
|
||||
|
||||
@Override
|
||||
public Comparable weigh(@NotNull final PsiElement element, @NotNull final ProximityLocation location) {
|
||||
VirtualFile elementFile = PsiUtilCore.getVirtualFile(element);
|
||||
return elementFile != null && PLACE_SCOPE.getValue(location).contains(elementFile);
|
||||
}
|
||||
}
|
||||
+12
-4
@@ -81,6 +81,8 @@ public class CopyFilesOrDirectoriesDialog extends DialogWrapper {
|
||||
private JLabel myInformationLabel;
|
||||
private TextFieldWithHistoryWithBrowseButton myTargetDirectoryField;
|
||||
private JCheckBox myOpenFilesInEditor = createOpenInEditorCB();
|
||||
private boolean myUnknownFileType = false;
|
||||
|
||||
private JTextField myNewNameField;
|
||||
private final PsiElement[] myElements;
|
||||
private final Project myProject;
|
||||
@@ -248,7 +250,9 @@ public class CopyFilesOrDirectoriesDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
public boolean openInEditor() {
|
||||
return myOpenFilesInEditor.isSelected();
|
||||
return myOpenFilesInEditor.isVisible() &&
|
||||
myOpenFilesInEditor.isSelected() &&
|
||||
!myUnknownFileType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -266,12 +270,16 @@ public class CopyFilesOrDirectoriesDialog extends DialogWrapper {
|
||||
return;
|
||||
}
|
||||
|
||||
if (myFileCopy && FileTypeChooser.getKnownFileTypeOrAssociate(myTargetDirectory.getVirtualFile(), newName, myProject) == null) {
|
||||
return;
|
||||
if (myFileCopy) {
|
||||
if (FileTypeChooser.getKnownFileTypeOrAssociate(myTargetDirectory.getVirtualFile(), newName, myProject) == null) {
|
||||
myUnknownFileType = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
saveOpenInEditorState(myOpenFilesInEditor.isSelected());
|
||||
if (myOpenFilesInEditor.isVisible()) {
|
||||
saveOpenInEditorState(myOpenFilesInEditor.isSelected());
|
||||
}
|
||||
if (myShowDirectoryField) {
|
||||
final String targetDirectoryName = myTargetDirectoryField.getChildComponent().getText();
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -180,7 +181,16 @@ public abstract class ExtractIncludeFileBase<T extends PsiElement> implements Re
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file, DataContext dataContext) {
|
||||
myIncludingFile = file;
|
||||
try {
|
||||
myIncludingFile = file;
|
||||
doInvoke(project, editor, file);
|
||||
}
|
||||
finally {
|
||||
myIncludingFile = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void doInvoke(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
if (!editor.getSelectionModel().hasSelection()) {
|
||||
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("no.selection"));
|
||||
CommonRefactoringUtil.showErrorHint(project, editor, message, getRefactoringName(), HELP_ID);
|
||||
@@ -250,6 +260,8 @@ public abstract class ExtractIncludeFileBase<T extends PsiElement> implements Re
|
||||
return extractFileType.getDefaultExtension();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@TestOnly
|
||||
public boolean isValidRange(final T firstToExtract, final T lastToExtract) {
|
||||
return verifyChildRange(firstToExtract, lastToExtract);
|
||||
}
|
||||
|
||||
@@ -76,12 +76,9 @@ public class KeymapUtil {
|
||||
if (!acceleratorText.isEmpty()) {
|
||||
s += ", " + acceleratorText;
|
||||
}
|
||||
} else if (shortcut instanceof PressureShortcut) {
|
||||
s += shortcut.toString();
|
||||
}
|
||||
else if (shortcut instanceof MouseShortcut) {
|
||||
MouseShortcut mouseShortcut = (MouseShortcut)shortcut;
|
||||
s = getMouseShortcutText(mouseShortcut.getButton(), mouseShortcut.getModifiers(), mouseShortcut.getClickCount());
|
||||
s = getMouseShortcutText((MouseShortcut)shortcut);
|
||||
}
|
||||
else if (shortcut instanceof KeyboardModifierGestureShortcut) {
|
||||
final KeyboardModifierGestureShortcut gestureShortcut = (KeyboardModifierGestureShortcut)shortcut;
|
||||
@@ -106,6 +103,11 @@ public class KeymapUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getMouseShortcutText(@NotNull MouseShortcut shortcut) {
|
||||
if (shortcut instanceof PressureShortcut) return shortcut.toString();
|
||||
return getMouseShortcutText(shortcut.getButton(), shortcut.getModifiers(), shortcut.getClickCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param button target mouse button
|
||||
* @param modifiers modifiers used within the target click
|
||||
|
||||
@@ -113,7 +113,7 @@ public class LoadingDecorator {
|
||||
}
|
||||
}
|
||||
|
||||
private void _startLoading(final boolean takeSnapshot) {
|
||||
protected void _startLoading(final boolean takeSnapshot) {
|
||||
myLoadingLayer.setVisible(true, takeSnapshot);
|
||||
}
|
||||
|
||||
|
||||
@@ -138,6 +138,7 @@ public class IdeEventQueue extends EventQueue {
|
||||
|
||||
private boolean myKeyboardBusy;
|
||||
private boolean myDispatchingFocusEvent;
|
||||
private boolean myWinMetaPressed;
|
||||
|
||||
private int myInputMethodLock;
|
||||
|
||||
@@ -370,6 +371,9 @@ public class IdeEventQueue extends EventQueue {
|
||||
e = fixNonEnglishKeyboardLayouts(e);
|
||||
|
||||
e = mapEvent(e);
|
||||
if (Registry.is("keymap.windows.as.meta")) {
|
||||
e = mapMetaState(e);
|
||||
}
|
||||
|
||||
boolean wasInputEvent = myIsInInputEvent;
|
||||
myIsInInputEvent = e instanceof InputEvent || e instanceof InputMethodEvent || e instanceof WindowEvent || e instanceof ActionEvent;
|
||||
@@ -530,6 +534,38 @@ public class IdeEventQueue extends EventQueue {
|
||||
return e;
|
||||
}
|
||||
|
||||
private AWTEvent mapMetaState(AWTEvent e) {
|
||||
if (myWinMetaPressed) {
|
||||
Application app = ApplicationManager.getApplication();
|
||||
if (app == null || !app.isActive()) {
|
||||
myWinMetaPressed = false;
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
if (e instanceof KeyEvent) {
|
||||
KeyEvent ke = (KeyEvent)e;
|
||||
if (ke.getKeyCode() == KeyEvent.VK_WINDOWS) {
|
||||
if (ke.getID() == KeyEvent.KEY_PRESSED) myWinMetaPressed = true;
|
||||
if (ke.getID() == KeyEvent.KEY_RELEASED) myWinMetaPressed = false;
|
||||
return new KeyEvent(ke.getComponent(), ke.getID(), ke.getWhen(), ke.getModifiers(), KeyEvent.VK_META, ke.getKeyChar(),
|
||||
ke.getKeyLocation());
|
||||
}
|
||||
if (myWinMetaPressed) {
|
||||
return new KeyEvent(ke.getComponent(), ke.getID(), ke.getWhen(), ke.getModifiers() | InputEvent.META_MASK, ke.getKeyCode(),
|
||||
ke.getKeyChar(), ke.getKeyLocation());
|
||||
}
|
||||
}
|
||||
|
||||
if (myWinMetaPressed && e instanceof MouseEvent && ((MouseEvent)e).getButton() != 0) {
|
||||
MouseEvent me = (MouseEvent)e;
|
||||
return new MouseEvent(me.getComponent(), me.getID(), me.getWhen(), me.getModifiers() | InputEvent.META_MASK, me.getX(), me.getY(),
|
||||
me.getClickCount(), me.isPopupTrigger(), me.getButton());
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
public void _dispatchEvent(@NotNull AWTEvent e, boolean typeAheadFlushing) {
|
||||
if (e.getID() == MouseEvent.MOUSE_DRAGGED) {
|
||||
DnDManagerImpl dndManager = (DnDManagerImpl)DnDManager.getInstance();
|
||||
|
||||
+3
-1
@@ -91,7 +91,9 @@ public class AsyncEditorLoader {
|
||||
|
||||
@Override
|
||||
public void onCanceled(@NotNull ProgressIndicator indicator) {
|
||||
scheduleBackgroundLoading(false);
|
||||
if (!Disposer.isDisposed(myTextEditor) && !myProject.isDisposed()) {
|
||||
scheduleBackgroundLoading(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+6
-11
@@ -17,17 +17,19 @@ package com.intellij.openapi.keymap.impl.ui;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.MouseShortcut;
|
||||
import com.intellij.openapi.actionSystem.PressureShortcut;
|
||||
import com.intellij.openapi.keymap.KeyMapBundle;
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
/**
|
||||
* @author Vladimir Kondratyev
|
||||
@@ -66,16 +68,9 @@ final class MouseShortcutDialog extends ShortcutDialog<MouseShortcut> {
|
||||
myText.setForeground(MouseShortcutPanel.FOREGROUND);
|
||||
myText.setText(KeyMapBundle.message("dialog.mouse.pad.default.text"));
|
||||
}
|
||||
else if (shortcut instanceof PressureShortcut) {
|
||||
myText.setForeground(UIUtil.getLabelForeground());
|
||||
myText.setText(KeyMapBundle.message("dialog.mouse.pad.shortcut.text", shortcut.toString()));
|
||||
}
|
||||
else {
|
||||
myText.setForeground(UIUtil.getLabelForeground());
|
||||
myText.setText(KeyMapBundle.message("dialog.mouse.pad.shortcut.text", KeymapUtil.getMouseShortcutText(
|
||||
shortcut.getButton(),
|
||||
shortcut.getModifiers(),
|
||||
shortcut.getClickCount())));
|
||||
myText.setText(KeyMapBundle.message("dialog.mouse.pad.shortcut.text", KeymapUtil.getMouseShortcutText(shortcut)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-25
@@ -16,14 +16,12 @@
|
||||
package com.intellij.openapi.keymap.impl.ui;
|
||||
|
||||
import com.intellij.openapi.actionSystem.MouseShortcut;
|
||||
import com.intellij.openapi.actionSystem.PressureShortcut;
|
||||
import com.intellij.openapi.actionSystem.Shortcut;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.mac.MacGestureSupportForMouseShortcutPanel;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
@@ -37,34 +35,33 @@ public final class MouseShortcutPanel extends ShortcutPanel<MouseShortcut> {
|
||||
static final JBColor BORDER = new JBColor(0xDEDEDE, 0x383B3D);
|
||||
|
||||
private final int myClickCount;
|
||||
private boolean myPressureTouch = false;
|
||||
private MouseShortcut myMouseShortcut = null;
|
||||
|
||||
private final MouseAdapter myMouseListener = new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseWheelMoved(MouseWheelEvent event) {
|
||||
mousePressed(event);
|
||||
setShortcutIfNeeded(toMouseShortcut(event));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent event) {
|
||||
myPressureTouch = false;
|
||||
myMouseShortcut = toMouseShortcut(event);
|
||||
}
|
||||
|
||||
private MouseShortcut toMouseShortcut(MouseEvent event) {
|
||||
int button = MouseShortcut.getButton(event);
|
||||
int clickCount = event instanceof MouseWheelEvent ? 1 : event.getClickCount();
|
||||
if (0 <= button && clickCount <= myClickCount) {
|
||||
int modifiers = event.getModifiersEx();
|
||||
myMouseShortcut = new MouseShortcut(button, modifiers, clickCount);
|
||||
return new MouseShortcut(button, modifiers, clickCount);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent event) {
|
||||
event.consume();
|
||||
|
||||
if (myPressureTouch) {
|
||||
return;
|
||||
}
|
||||
setShortcut(myMouseShortcut);
|
||||
setShortcutIfNeeded(myMouseShortcut);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -74,28 +71,20 @@ public final class MouseShortcutPanel extends ShortcutPanel<MouseShortcut> {
|
||||
addMouseListener(myMouseListener);
|
||||
addMouseWheelListener(myMouseListener);
|
||||
if (SystemInfo.isJavaVersionAtLeast("1.8") && SystemInfo.isMacIntel64 && SystemInfo.isJetbrainsJvm && Registry.is("ide.mac.forceTouch")) {
|
||||
new MacGestureSupportForMouseShortcutPanel(this, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myPressureTouch = true;
|
||||
}
|
||||
});
|
||||
new MacGestureSupportForMouseShortcutPanel(this, () -> myMouseShortcut = null);
|
||||
}
|
||||
setBackground(BACKGROUND);
|
||||
setOpaque(true);
|
||||
}
|
||||
|
||||
void setShortcut(MouseShortcut shortcut) {
|
||||
Shortcut old = getShortcut();
|
||||
public void setShortcut(MouseShortcut shortcut) {
|
||||
MouseShortcut old = getShortcut();
|
||||
if (old != null || shortcut != null) {
|
||||
super.setShortcut(shortcut);
|
||||
}
|
||||
}
|
||||
|
||||
public void setShortcut(PressureShortcut shortcut) {
|
||||
Shortcut old = getShortcut();
|
||||
if (old != null || shortcut != null) {
|
||||
super.setShortcut(shortcut);
|
||||
}
|
||||
private void setShortcutIfNeeded(MouseShortcut shortcut) {
|
||||
if (shortcut != null) setShortcut(shortcut);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-15
@@ -19,7 +19,6 @@ import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.IdeEventQueue;
|
||||
import com.intellij.openapi.actionSystem.KeyboardShortcut;
|
||||
import com.intellij.openapi.actionSystem.MouseShortcut;
|
||||
import com.intellij.openapi.actionSystem.PressureShortcut;
|
||||
import com.intellij.openapi.actionSystem.Shortcut;
|
||||
import com.intellij.openapi.keymap.KeyMapBundle;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
@@ -68,27 +67,15 @@ final class ShortcutFilteringPanel extends JPanel {
|
||||
if (ShortcutFilteringPanel.this == event.getSource()) {
|
||||
if (value instanceof KeyboardShortcut) {
|
||||
KeyboardShortcut shortcut = (KeyboardShortcut)value;
|
||||
myMousePanel.setShortcut((MouseShortcut)null);
|
||||
myMousePanel.setShortcut(null);
|
||||
myKeyboardPanel.setShortcut(shortcut);
|
||||
if (null != shortcut.getSecondKeyStroke()) {
|
||||
myKeyboardPanel.mySecondStrokeEnable.setSelected(true);
|
||||
}
|
||||
}
|
||||
else if (value instanceof PressureShortcut) {
|
||||
String text = "Power Touch";
|
||||
MouseShortcut shortcut = (PressureShortcut)value;
|
||||
myMousePanel.setShortcut(shortcut);
|
||||
myKeyboardPanel.setShortcut(null);
|
||||
myKeyboardPanel.myFirstStroke.setText(text);
|
||||
myKeyboardPanel.mySecondStroke.setText(null);
|
||||
myKeyboardPanel.mySecondStroke.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
MouseShortcut shortcut = value instanceof MouseShortcut ? (MouseShortcut)value : null;
|
||||
String text = shortcut == null ? null : KeymapUtil.getMouseShortcutText(
|
||||
shortcut.getButton(),
|
||||
shortcut.getModifiers(),
|
||||
shortcut.getClickCount());
|
||||
String text = shortcut == null ? null : KeymapUtil.getMouseShortcutText(shortcut);
|
||||
myMousePanel.setShortcut(shortcut);
|
||||
myKeyboardPanel.setShortcut(null);
|
||||
myKeyboardPanel.myFirstStroke.setText(text);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.intellij.openapi.progress;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.progress.impl.BackgroundableProcessIndicator;
|
||||
@@ -40,7 +41,8 @@ public class BackgroundTaskQueue {
|
||||
@NotNull private final String myTitle;
|
||||
@NotNull private final QueueProcessor<TaskData> myProcessor;
|
||||
|
||||
private boolean myForceAsyncInTests = false;
|
||||
@NotNull private final Object TEST_TASK_LOCK = new Object();
|
||||
private volatile boolean myForceAsyncInTests = false;
|
||||
|
||||
public BackgroundTaskQueue(@Nullable Project project, @NotNull String title) {
|
||||
myTitle = title;
|
||||
@@ -49,8 +51,20 @@ public class BackgroundTaskQueue {
|
||||
|
||||
myProcessor = new QueueProcessor<TaskData>((data, continuation) -> {
|
||||
Task.Backgroundable task = data.task;
|
||||
|
||||
ProgressIndicator indicator = data.indicator;
|
||||
if (indicator == null) {
|
||||
if (ApplicationManager.getApplication().isHeadlessEnvironment()) {
|
||||
indicator = new EmptyProgressIndicator();
|
||||
}
|
||||
else {
|
||||
// BackgroundableProcessIndicator should be created from EDT
|
||||
indicator = new BackgroundableProcessIndicator(task);
|
||||
}
|
||||
}
|
||||
|
||||
ModalityState modalityState = data.modalityState;
|
||||
if (modalityState == null) modalityState = ModalityState.NON_MODAL;
|
||||
|
||||
if (StringUtil.isEmptyOrSpaces(task.getTitle())) {
|
||||
task.setTitle(myTitle);
|
||||
@@ -91,24 +105,21 @@ public class BackgroundTaskQueue {
|
||||
}
|
||||
|
||||
public void run(@NotNull Task.Backgroundable task, @Nullable ModalityState modalityState, @Nullable ProgressIndicator indicator) {
|
||||
if (modalityState == null) modalityState = ModalityState.NON_MODAL;
|
||||
if (indicator == null) {
|
||||
if (ApplicationManager.getApplication().isHeadlessEnvironment()) {
|
||||
indicator = new EmptyProgressIndicator();
|
||||
}
|
||||
else {
|
||||
indicator = new BackgroundableProcessIndicator(task);
|
||||
}
|
||||
TaskData taskData = new TaskData(task, modalityState, indicator);
|
||||
if (!myForceAsyncInTests && ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
runTaskInCurrentThread(taskData);
|
||||
}
|
||||
else {
|
||||
myProcessor.add(taskData, modalityState);
|
||||
}
|
||||
myProcessor.add(new TaskData(task, modalityState, indicator), modalityState);
|
||||
}
|
||||
|
||||
private static class TaskData {
|
||||
@NotNull public final Task.Backgroundable task;
|
||||
@NotNull public final ModalityState modalityState;
|
||||
@NotNull public final ProgressIndicator indicator;
|
||||
@Nullable public final ModalityState modalityState;
|
||||
@Nullable public final ProgressIndicator indicator;
|
||||
|
||||
public TaskData(@NotNull Task.Backgroundable task, @NotNull ModalityState modalityState, @NotNull ProgressIndicator indicator) {
|
||||
public TaskData(@NotNull Task.Backgroundable task, @Nullable ModalityState modalityState, @Nullable ProgressIndicator indicator) {
|
||||
this.task = task;
|
||||
this.modalityState = modalityState;
|
||||
this.indicator = indicator;
|
||||
@@ -117,7 +128,6 @@ public class BackgroundTaskQueue {
|
||||
|
||||
@TestOnly
|
||||
public void setForceAsyncInTests(boolean value, @Nullable Disposable disposable) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
myForceAsyncInTests = value;
|
||||
if (disposable != null) {
|
||||
Disposer.register(disposable, new Disposable() {
|
||||
@@ -128,4 +138,55 @@ public class BackgroundTaskQueue {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void runTaskInCurrentThread(@NotNull TaskData data) {
|
||||
Task.Backgroundable task = data.task;
|
||||
|
||||
ProgressIndicator indicator = data.indicator;
|
||||
if (indicator == null) indicator = new EmptyProgressIndicator();
|
||||
|
||||
ModalityState modalityState = data.modalityState;
|
||||
if (modalityState == null) modalityState = ModalityState.NON_MODAL;
|
||||
|
||||
boolean processCanceled = false;
|
||||
Exception exception = null;
|
||||
try {
|
||||
synchronized (TEST_TASK_LOCK) {
|
||||
task.run(indicator);
|
||||
}
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
processCanceled = true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
exception = e;
|
||||
}
|
||||
|
||||
final boolean finalCanceled = processCanceled || indicator.isCanceled();
|
||||
final Exception finalException = exception;
|
||||
Runnable finishTask = () -> {
|
||||
try {
|
||||
if (finalException != null) {
|
||||
task.onError(finalException);
|
||||
}
|
||||
else if (finalCanceled) {
|
||||
task.onCancel();
|
||||
}
|
||||
else {
|
||||
task.onSuccess();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
task.onFinished();
|
||||
}
|
||||
};
|
||||
|
||||
Application application = ApplicationManager.getApplication();
|
||||
if (application.isDispatchThread()) {
|
||||
finishTask.run();
|
||||
}
|
||||
else {
|
||||
application.invokeLater(finishTask, modalityState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -479,6 +479,12 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
|
||||
}
|
||||
|
||||
private class AnCancelAction extends AnAction implements DumbAware {
|
||||
|
||||
@Override
|
||||
public boolean startInTransaction() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
|
||||
|
||||
@@ -449,6 +449,10 @@ public final class ToolWindowsPane extends JBLayeredPane implements Disposable {
|
||||
return myBottomStripe.isVisible() ? myBottomStripe.getHeight() : 0;
|
||||
}
|
||||
|
||||
public boolean isBottomSideToolWindowsVisible() {
|
||||
return getComponentAt(ToolWindowAnchor.BOTTOM) != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
Stripe getStripeFor(String id) {
|
||||
ToolWindow window = myManager.getToolWindow(id);
|
||||
|
||||
+7
-1
@@ -37,6 +37,7 @@ import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.openapi.wm.StatusBar;
|
||||
import com.intellij.openapi.wm.StatusBarWidget;
|
||||
import com.intellij.openapi.wm.ex.ProgressIndicatorEx;
|
||||
import com.intellij.openapi.wm.impl.ToolWindowsPane;
|
||||
import com.intellij.ui.BalloonLayoutImpl;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.TabbedPaneWrapper;
|
||||
@@ -434,7 +435,7 @@ public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidge
|
||||
public RelativePoint recalculateLocation(Balloon object) {
|
||||
Component c = getAnchor(pane);
|
||||
int y = c.getHeight() - 45;
|
||||
if (balloonLayout != null) {
|
||||
if (balloonLayout != null && !isBottomSideToolWindowsVisible(pane)) {
|
||||
Component component = balloonLayout.getTopBalloonComponent();
|
||||
if (component != null) {
|
||||
y = SwingUtilities.convertPoint(component, 0, -45, c).y;
|
||||
@@ -465,6 +466,11 @@ public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidge
|
||||
return ex == null ? pane : ex.getSplitters();
|
||||
}
|
||||
|
||||
private static boolean isBottomSideToolWindowsVisible(@NotNull JRootPane parent) {
|
||||
ToolWindowsPane pane = UIUtil.findComponentOfType(parent, ToolWindowsPane.class);
|
||||
return pane != null && pane.isBottomSideToolWindowsVisible();
|
||||
}
|
||||
|
||||
public Couple<String> setText(@Nullable final String text, @Nullable final String requestor) {
|
||||
if (StringUtil.isEmpty(text) && !Comparing.equal(requestor, myCurrentRequestor) && !EventLog.LOG_REQUESTOR.equals(requestor)) {
|
||||
return Couple.of(myInfoPanel.getText(), myCurrentRequestor);
|
||||
|
||||
@@ -752,12 +752,12 @@
|
||||
</option>
|
||||
<option name="LOG_WARNING_OUTPUT">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="ffa500" deuteranopia="a89c11" protanopia="a89c11"/>
|
||||
<option name="FOREGROUND" value="a66f00" deuteranopia="a89c11" protanopia="a89c11"/>
|
||||
</value>
|
||||
</option>
|
||||
<option name="LOG_ERROR_OUTPUT">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="ff0000" deuteranopia="d95716" protanopia="d95716"/>
|
||||
<option name="FOREGROUND" value="cd0000" deuteranopia="d95716" protanopia="d95716"/>
|
||||
<option name="FONT_TYPE" deuteranopia="bold" protanopia="bold"/>
|
||||
</value>
|
||||
</option>
|
||||
@@ -1691,7 +1691,7 @@
|
||||
</option>
|
||||
<option name="LOG_ERROR_OUTPUT">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="ff6b68" deuteranopia="bd693c" protanopia="bd693c"/>
|
||||
<option name="FOREGROUND" value="cc666e" deuteranopia="bd693c" protanopia="bd693c"/>
|
||||
<option name="FONT_TYPE" deuteranopia="bold" protanopia="bold"/>
|
||||
</value>
|
||||
</option>
|
||||
|
||||
@@ -523,8 +523,10 @@
|
||||
order="after sameDirectory"/>
|
||||
<weigher key="proximity" implementationClass="com.intellij.psi.util.proximity.SameModuleWeigher" id="sameModule"
|
||||
order="after sameLogicalRoot"/>
|
||||
<weigher key="proximity" implementationClass="com.intellij.psi.util.proximity.SdkOrLibraryWeigher" id="sdkOrLibrary"
|
||||
<weigher key="proximity" implementationClass="com.intellij.psi.util.proximity.InResolveScopeWeigher" id="inResolveScope"
|
||||
order="after sameModule"/>
|
||||
<weigher key="proximity" implementationClass="com.intellij.psi.util.proximity.SdkOrLibraryWeigher" id="sdkOrLibrary"
|
||||
order="after inResolveScope"/>
|
||||
|
||||
<weigher key="completion" implementationClass="com.intellij.codeInsight.completion.PriorityWeigher" id="priority" order="first"/>
|
||||
<weigher key="completion" implementationClass="com.intellij.codeInsight.completion.StatisticsWeigher" id="stats"
|
||||
|
||||
+36
-11
@@ -18,6 +18,8 @@ package com.intellij.execution.process;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.io.BaseOutputReader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
@@ -29,14 +31,21 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class BinaryOSProcessHandlerTest {
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
TestBinaryOSProcessHandler handler = new TestBinaryOSProcessHandler(launchTest());
|
||||
handler.startNotify();
|
||||
assertTrue(handler.waitFor(60 * 1000));
|
||||
assertEquals(0, handler.exitCode);
|
||||
assertThat(handler.stdErr.toString()).isEqualTo(Runner.TEXT);
|
||||
assertThat(handler.getOutput()).containsExactly(Runner.BYTES);
|
||||
@Test public void testBlocking() { doTest(true); }
|
||||
@Test public void testNonBlocking() { doTest(false); }
|
||||
|
||||
private static void doTest(boolean blocking) {
|
||||
try {
|
||||
TestBinaryOSProcessHandler handler = new TestBinaryOSProcessHandler(launchTest(), blocking);
|
||||
handler.startNotify();
|
||||
assertTrue(handler.waitFor(60 * 1000));
|
||||
assertEquals(0, handler.exitCode);
|
||||
assertThat(handler.stdErr.toString()).isEqualTo(Runner.TEXT);
|
||||
assertThat(handler.getOutput()).containsExactly(Runner.BYTES);
|
||||
}
|
||||
catch (URISyntaxException | IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static Process launchTest() throws URISyntaxException, IOException {
|
||||
@@ -54,10 +63,18 @@ public class BinaryOSProcessHandlerTest {
|
||||
|
||||
private static class TestBinaryOSProcessHandler extends BinaryOSProcessHandler {
|
||||
private final StringBuilder stdErr = new StringBuilder();
|
||||
private final boolean blocking;
|
||||
private int exitCode = -1;
|
||||
|
||||
public TestBinaryOSProcessHandler(Process process) {
|
||||
public TestBinaryOSProcessHandler(Process process, boolean blocking) {
|
||||
super(process, "test", null);
|
||||
this.blocking = blocking;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected BaseOutputReader.Options readerOptions() {
|
||||
return blocking ? BaseOutputReader.Options.BLOCKING : BaseOutputReader.Options.NON_BLOCKING;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,10 +94,18 @@ public class BinaryOSProcessHandlerTest {
|
||||
public static class Runner {
|
||||
private static final String TEXT = "some\ntext";
|
||||
private static final byte[] BYTES = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
private static final int PACKET_SIZE = 4;
|
||||
private static final int SEND_TIMEOUT = 500;
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
@SuppressWarnings("BusyWait")
|
||||
public static void main(String[] args) throws IOException, InterruptedException {
|
||||
System.err.print(TEXT);
|
||||
System.out.write(BYTES);
|
||||
|
||||
for (int offset = 0; offset < BYTES.length; offset += PACKET_SIZE) {
|
||||
int n = Math.min(PACKET_SIZE, BYTES.length - offset);
|
||||
System.out.write(BYTES, offset, n);
|
||||
Thread.sleep(SEND_TIMEOUT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,7 +21,6 @@ import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.PlatformTestCase;
|
||||
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase;
|
||||
@@ -97,7 +96,7 @@ public class PersistenceStressTest extends LightPlatformCodeInsightFixtureTestCa
|
||||
Future<Boolean> submit = submit(map);
|
||||
futures.add(submit);
|
||||
}
|
||||
Future<?> waitFuture = myThreadPool.submit((Runnable)() -> {
|
||||
Future<?> waitFuture = myThreadPool.submit(() -> {
|
||||
try {
|
||||
while (ContainerUtil.find(futures, STILL_RUNNING) != null) {
|
||||
Thread.sleep(100);
|
||||
|
||||
+1
-1
@@ -3453,7 +3453,7 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
|
||||
" final int var3;" +
|
||||
" }" +
|
||||
"}";
|
||||
assertEquals("parameters and local variables are not package local", 1, findMatchesCount(source, "@Modifier(\"packageLocal\") '_T '_a;"));
|
||||
assertEquals("parameters and local variables are not package-private", 1, findMatchesCount(source, "@Modifier(\"packageLocal\") '_T '_a;"));
|
||||
assertEquals("any variable can be final", 3, findMatchesCount(source, "@Modifier(\"final\") '_T '_a;"));
|
||||
assertEquals("parameters and local variables are not instance fields", 1, findMatchesCount(source, "@Modifier(\"Instance\") '_T '_a;"));
|
||||
}
|
||||
|
||||
@@ -280,6 +280,7 @@ find.search.in.project.files=true
|
||||
structureView.coalesceTime=500
|
||||
|
||||
keymap.show.alias.actions=false
|
||||
keymap.windows.as.meta=true
|
||||
frameworks.download.libraries.server.url=http://pluginsrepo-test:8080
|
||||
caches.indexerThreadsCount=-1
|
||||
navBar.updateMergeTime=100
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,10 +15,7 @@
|
||||
*/
|
||||
package com.intellij.execution;
|
||||
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
@@ -29,7 +26,6 @@ import java.util.List;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
public class CommandLineWrapperUtil {
|
||||
@NotNull
|
||||
@@ -38,40 +34,21 @@ public class CommandLineWrapperUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File createClasspathJarFile(Manifest manifest, List<String> pathList, final boolean notEscape) throws IOException {
|
||||
final Attributes attributes = manifest.getMainAttributes();
|
||||
attributes.put(Attributes.Name.MANIFEST_VERSION, "1.0");
|
||||
@SuppressWarnings({"deprecation", "IOResourceOpenedButNotSafelyClosed"})
|
||||
public static File createClasspathJarFile(Manifest manifest, List<String> pathList, boolean notEscape) throws IOException {
|
||||
manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
|
||||
|
||||
final Ref<IOException> ex = new Ref<IOException>();
|
||||
final String classPathAttribute = StringUtil.join(pathList, new Function<String, String>() {
|
||||
@Override
|
||||
public String fun(String path) {
|
||||
final File classpathElement = new File(path);
|
||||
try {
|
||||
return (notEscape ? classpathElement.toURL() : classpathElement.toURI().toURL()).toString();
|
||||
}
|
||||
catch (IOException e) {
|
||||
ex.set(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}, " ");
|
||||
|
||||
final IOException thrownException = ex.get();
|
||||
if (thrownException != null) {
|
||||
throw thrownException;
|
||||
StringBuilder classPath = new StringBuilder();
|
||||
for (String path : pathList) {
|
||||
if (classPath.length() > 0) classPath.append(' ');
|
||||
File classpathElement = new File(path);
|
||||
String url = (notEscape ? classpathElement.toURL() : classpathElement.toURI().toURL()).toString();
|
||||
classPath.append(url);
|
||||
}
|
||||
attributes.put(Attributes.Name.CLASS_PATH, classPathAttribute);
|
||||
manifest.getMainAttributes().put(Attributes.Name.CLASS_PATH, classPath.toString());
|
||||
|
||||
File jarFile = FileUtil.createTempFile("classpath", ".jar", true);
|
||||
ZipOutputStream jarPlugin = null;
|
||||
try {
|
||||
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(jarFile));
|
||||
jarPlugin = new JarOutputStream(out, manifest);
|
||||
}
|
||||
finally {
|
||||
if (jarPlugin != null) jarPlugin.close();
|
||||
}
|
||||
new JarOutputStream(new BufferedOutputStream(new FileOutputStream(jarFile)), manifest).close();
|
||||
return jarFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,6 +68,36 @@ public abstract class BaseDataReader {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Please don't override this method as the BseOSProcessProcessHandler assumes that it can be two reading modes: blocking and non-blocking.
|
||||
* Implement {@link #readAvailableBlocking} and {@link #readAvailableNonBlocking} instead.
|
||||
*
|
||||
*
|
||||
* If the process handler assumes that reader handles the blocking mode, while it doesn't, it will result into premature stream close.
|
||||
*
|
||||
* @return true in case any data was read
|
||||
* @throws IOException if an exception during IO happened
|
||||
*/
|
||||
protected boolean readAvailable() throws IOException {
|
||||
return mySleepingPolicy == SleepingPolicy.BLOCKING ? readAvailableBlocking() : readAvailableNonBlocking();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Non-blocking read returns the control back to the process handler when there is no data to read.
|
||||
*
|
||||
*/
|
||||
protected boolean readAvailableNonBlocking() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reader in a blocking mode blocks on IO read operation until data is received. It exits the method only after stream is closed.
|
||||
*/
|
||||
protected boolean readAvailableBlocking() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected abstract Future<?> executeOnPooledThread(@NotNull Runnable runnable);
|
||||
|
||||
@@ -158,7 +188,6 @@ public abstract class BaseDataReader {
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean readAvailable() throws IOException;
|
||||
protected abstract void close() throws IOException;
|
||||
|
||||
public void stop() {
|
||||
|
||||
@@ -178,11 +178,6 @@ public abstract class BaseOutputReader extends BaseDataReader {
|
||||
line.setLength(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean readAvailable() throws IOException {
|
||||
return mySleepingPolicy == SleepingPolicy.BLOCKING ? readAvailableBlocking() : readAvailableNonBlocking();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void close() throws IOException {
|
||||
myReader.close();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,16 +33,32 @@ public abstract class BinaryOutputReader extends BaseDataReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean readAvailable() throws IOException {
|
||||
protected boolean readAvailableNonBlocking() throws IOException {
|
||||
byte[] buffer = myBuffer;
|
||||
|
||||
boolean read = false;
|
||||
while (myStream.available() > 0) {
|
||||
int n = myStream.read(buffer);
|
||||
if (n <= 0) break;
|
||||
read = true;
|
||||
|
||||
onBinaryAvailable(buffer, n);
|
||||
int n;
|
||||
while (myStream.available() > 0 && (n = myStream.read(buffer)) >= 0) {
|
||||
if (n > 0) {
|
||||
read = true;
|
||||
onBinaryAvailable(buffer, n);
|
||||
}
|
||||
}
|
||||
|
||||
return read;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final boolean readAvailableBlocking() throws IOException {
|
||||
byte[] buffer = myBuffer;
|
||||
boolean read = false;
|
||||
|
||||
int n;
|
||||
while ((n = myStream.read(buffer)) >= 0) {
|
||||
if (n > 0) {
|
||||
read = true;
|
||||
onBinaryAvailable(buffer, n);
|
||||
}
|
||||
}
|
||||
|
||||
return read;
|
||||
@@ -54,4 +70,4 @@ public abstract class BinaryOutputReader extends BaseDataReader {
|
||||
protected void close() throws IOException {
|
||||
myStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ import com.intellij.ui.components.panels.Wrapper;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.AsyncProcessIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.table.ComponentsListFocusTraversalPolicy;
|
||||
import com.intellij.vcs.CommittedChangeListForRevision;
|
||||
@@ -114,7 +113,13 @@ public class MainFrame extends JPanel implements DataProvider, Disposable {
|
||||
toolbarsAndTable.add(myDetailsSplitter, BorderLayout.CENTER);
|
||||
|
||||
ProgressStripe progressStripe =
|
||||
new ProgressStripe(toolbarsAndTable, toolbars, this, ProgressWindow.DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS);
|
||||
new ProgressStripe(toolbarsAndTable, toolbars, this, ProgressWindow.DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS) {
|
||||
@Override
|
||||
public void updateUI() {
|
||||
super.updateUI();
|
||||
if (myDecorator != null && myLogData.getProgress().isRunning()) startLoadingImmediately();
|
||||
}
|
||||
};
|
||||
myLogData.getProgress().addProgressIndicatorListener(new VcsLogProgress.ProgressListener() {
|
||||
@Override
|
||||
public void progressStarted() {
|
||||
|
||||
@@ -17,10 +17,11 @@ package com.intellij.vcs.log.ui.frame;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.ui.LoadingDecorator;
|
||||
import com.intellij.ui.components.JBLoadingPanel;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.NotNullComputable;
|
||||
import com.intellij.ui.components.JBPanel;
|
||||
import com.intellij.ui.components.panels.NonOpaquePanel;
|
||||
import com.intellij.util.ui.AsyncProcessIcon;
|
||||
import icons.VcsLogIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -28,30 +29,93 @@ import java.awt.*;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
|
||||
public class ProgressStripe extends JBLoadingPanel {
|
||||
public ProgressStripe(@NotNull JComponent component, @NotNull JComponent toolbar, @NotNull Disposable parent, int startDelayMs) {
|
||||
super(new BorderLayout(), panel -> new MyLoadingDecorator(component, toolbar, panel, parent, startDelayMs));
|
||||
setLoadingText("");
|
||||
add(component);
|
||||
public class ProgressStripe extends JBPanel {
|
||||
@NotNull
|
||||
private final JBPanel myPanel;
|
||||
private final NotNullComputable<MyLoadingDecorator> myCreateLoadingDecorator;
|
||||
protected MyLoadingDecorator myDecorator;
|
||||
|
||||
public ProgressStripe(@NotNull JComponent targetComponent, @NotNull JComponent toolbar, @NotNull Disposable parent, int startDelayMs) {
|
||||
super(new BorderLayout());
|
||||
myPanel = new JBPanel(new BorderLayout());
|
||||
myPanel.setOpaque(false);
|
||||
myPanel.add(targetComponent);
|
||||
|
||||
myCreateLoadingDecorator = () -> {
|
||||
Disposable disposable = Disposer.newDisposable();
|
||||
Disposer.register(parent, disposable);
|
||||
return new MyLoadingDecorator(targetComponent, toolbar, myPanel, disposable, startDelayMs);
|
||||
};
|
||||
createLoadingDecorator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUI() {
|
||||
super.updateUI();
|
||||
if (myCreateLoadingDecorator != null) {
|
||||
if (myDecorator != null) {
|
||||
remove(myDecorator.getComponent());
|
||||
myDecorator.dispose();
|
||||
}
|
||||
createLoadingDecorator();
|
||||
}
|
||||
}
|
||||
|
||||
private void createLoadingDecorator() {
|
||||
myDecorator = myCreateLoadingDecorator.compute();
|
||||
add(myDecorator.getComponent(), BorderLayout.CENTER);
|
||||
myDecorator.setLoadingText("");
|
||||
}
|
||||
|
||||
public void startLoading() {
|
||||
myDecorator.startLoading(false);
|
||||
}
|
||||
|
||||
public void startLoadingImmediately() {
|
||||
myDecorator.startLoadingImmediately();
|
||||
}
|
||||
|
||||
public void stopLoading() {
|
||||
myDecorator.stopLoading();
|
||||
}
|
||||
|
||||
private static class MyLoadingDecorator extends LoadingDecorator {
|
||||
@NotNull
|
||||
private final Disposable myDisposable;
|
||||
@NotNull
|
||||
private final JComponent myToolbar;
|
||||
@NotNull
|
||||
private final ComponentAdapter myListener;
|
||||
private Box.Filler myFiller;
|
||||
|
||||
public MyLoadingDecorator(@NotNull JComponent component,
|
||||
@NotNull JComponent toolbar,
|
||||
@NotNull JPanel contentPanel,
|
||||
@NotNull Disposable parent,
|
||||
@NotNull Disposable disposable,
|
||||
int startDelayMs) {
|
||||
super(contentPanel, parent, startDelayMs, false, StripesAnimatedIcon.generateIcon(component));
|
||||
toolbar.addComponentListener(new ComponentAdapter() {
|
||||
super(contentPanel, disposable, startDelayMs, false, ProgressStripeIcon.generateIcon(component));
|
||||
myDisposable = disposable;
|
||||
myToolbar = toolbar;
|
||||
myListener = new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
super.componentResized(e);
|
||||
Dimension dimension = new Dimension(0, toolbar.getHeight() - VcsLogIcons.Stripes.getIconHeight() / 2);
|
||||
myFiller.changeShape(dimension, dimension, dimension);
|
||||
adjustFiller();
|
||||
}
|
||||
});
|
||||
};
|
||||
myToolbar.addComponentListener(myListener);
|
||||
adjustFiller();
|
||||
}
|
||||
|
||||
private void adjustFiller() {
|
||||
if (myFiller != null && myToolbar.getHeight() != 0) {
|
||||
Dimension dimension = new Dimension(0, myToolbar.getHeight() - ProgressStripeIcon.getHeight() / 2);
|
||||
myFiller.changeShape(dimension, dimension, dimension);
|
||||
}
|
||||
}
|
||||
|
||||
public void startLoadingImmediately() {
|
||||
_startLoading(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,5 +132,10 @@ public class ProgressStripe extends JBLoadingPanel {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
myToolbar.removeComponentListener(myListener);
|
||||
Disposer.dispose(myDisposable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.vcs.log.ui.frame;
|
||||
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.util.IconUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.AsyncProcessIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import icons.VcsLogIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.util.List;
|
||||
|
||||
public class ProgressStripeIcon {
|
||||
private static final int TRANSLATE = 1;
|
||||
private static final Icon STRIPES = VcsLogIcons.Stripes;
|
||||
|
||||
private static class StripesIcon implements Icon {
|
||||
@NotNull
|
||||
private final JComponent myReferenceComponent;
|
||||
private final int myShift;
|
||||
@NotNull
|
||||
private final Icon myCropIcon;
|
||||
private final Icon myIcon;
|
||||
|
||||
public StripesIcon(@NotNull JComponent component, int shift, @NotNull Icon icon) {
|
||||
myReferenceComponent = component;
|
||||
myShift = shift;
|
||||
|
||||
myIcon = icon;
|
||||
myCropIcon = IconUtil.cropIcon(icon, new Rectangle(myIcon.getIconWidth() - myShift, 0, myShift, icon.getIconHeight()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
myCropIcon.paintIcon(c, g, x, y);
|
||||
int shift = myShift;
|
||||
while (shift < getIconWidth()) {
|
||||
myIcon.paintIcon(c, g, x + shift, y);
|
||||
shift += myIcon.getIconWidth();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconWidth() {
|
||||
return myReferenceComponent.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconHeight() {
|
||||
return myIcon.getIconHeight();
|
||||
}
|
||||
}
|
||||
|
||||
private static class GradientIcon implements Icon {
|
||||
private static final JBColor DARK_BLUE = new JBColor(0x4d9ff8, 0x525659);
|
||||
private static final JBColor LIGHT_BLUE = new JBColor(0x90c2f8, 0x5e6266);
|
||||
static final int GRADIENT_WIDTH = JBUI.scale(128);
|
||||
@NotNull
|
||||
private final JComponent myReferenceComponent;
|
||||
private final int myShift;
|
||||
|
||||
private GradientIcon(@NotNull JComponent component, int shift) {
|
||||
myReferenceComponent = component;
|
||||
myShift = shift;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
Graphics2D g2 = (Graphics2D)g;
|
||||
int shift = myShift - 2 * GRADIENT_WIDTH;
|
||||
while (shift < getIconWidth()) {
|
||||
paint(g2, x, y, shift);
|
||||
shift += 2 * GRADIENT_WIDTH;
|
||||
}
|
||||
}
|
||||
|
||||
public void paint(Graphics2D g2, int x, int y, int shift) {
|
||||
g2.setPaint(new GradientPaint(x + shift, y, DARK_BLUE, x + shift + GRADIENT_WIDTH, y, LIGHT_BLUE));
|
||||
g2.fill(new Rectangle(x + shift, y, GRADIENT_WIDTH, getIconHeight()));
|
||||
g2.setPaint(new GradientPaint(x + shift + GRADIENT_WIDTH, y, LIGHT_BLUE, x + shift + 2 * GRADIENT_WIDTH, y, DARK_BLUE));
|
||||
g2.fill(new Rectangle(x + shift + GRADIENT_WIDTH, y, GRADIENT_WIDTH, getIconHeight()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconWidth() {
|
||||
return myReferenceComponent.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconHeight() {
|
||||
return STRIPES.getIconHeight();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static AsyncProcessIcon generateIcon(@NotNull JComponent component) {
|
||||
List<Icon> result = ContainerUtil.newArrayList();
|
||||
if (UIUtil.isUnderAquaBasedLookAndFeel() && !UIUtil.isUnderDarcula()) {
|
||||
for (int i = 0; i < 2 * GradientIcon.GRADIENT_WIDTH; i += JBUI.scale(TRANSLATE)) {
|
||||
result.add(new GradientIcon(component, i));
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < STRIPES.getIconWidth(); i += JBUI.scale(TRANSLATE)) {
|
||||
result.add(new StripesIcon(component, i, STRIPES));
|
||||
}
|
||||
result = ContainerUtil.reverse(result);
|
||||
}
|
||||
|
||||
Icon passive = result.get(0);
|
||||
AsyncProcessIcon icon = new AsyncProcessIcon("ProgressWithStripes", result.toArray(new Icon[result.size()]), passive) {
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(component.getWidth(), passive.getIconHeight());
|
||||
}
|
||||
};
|
||||
component.addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
super.componentResized(e);
|
||||
icon.revalidate();
|
||||
}
|
||||
});
|
||||
return icon;
|
||||
}
|
||||
|
||||
public static int getHeight() {
|
||||
return STRIPES.getIconHeight();
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.vcs.log.ui.frame;
|
||||
|
||||
import com.intellij.util.IconUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.AsyncProcessIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import icons.VcsLogIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.util.List;
|
||||
|
||||
public class StripesAnimatedIcon implements Icon {
|
||||
private static final Icon STRIPES = VcsLogIcons.Stripes;
|
||||
private static final int TRANSLATE = 1;
|
||||
|
||||
@NotNull
|
||||
private final JComponent myReferenceComponent;
|
||||
private final int myShift;
|
||||
@NotNull
|
||||
private final Icon myCropIcon;
|
||||
|
||||
public StripesAnimatedIcon(@NotNull JComponent component, int shift) {
|
||||
myReferenceComponent = component;
|
||||
myShift = shift;
|
||||
|
||||
myCropIcon = IconUtil.cropIcon(STRIPES, new Rectangle(STRIPES.getIconWidth() - myShift, 0, myShift, STRIPES.getIconHeight()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
myCropIcon.paintIcon(c, g, x, y);
|
||||
int shift = myShift;
|
||||
while (shift < getIconWidth()) {
|
||||
STRIPES.paintIcon(c, g, x + shift, y);
|
||||
shift += STRIPES.getIconWidth();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconWidth() {
|
||||
return myReferenceComponent.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconHeight() {
|
||||
return STRIPES.getIconHeight();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static AsyncProcessIcon generateIcon(@NotNull JComponent component) {
|
||||
List<Icon> result = ContainerUtil.newArrayList();
|
||||
for (int i = 0; i < STRIPES.getIconWidth(); i += JBUI.scale(TRANSLATE)) {
|
||||
result.add(new StripesAnimatedIcon(component, i));
|
||||
}
|
||||
AsyncProcessIcon icon = new AsyncProcessIcon("ProgressWithStripes", result.toArray(new Icon[result.size()]), result.get(0)) {
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(component.getWidth(), STRIPES.getIconHeight());
|
||||
}
|
||||
};
|
||||
component.addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
super.componentResized(e);
|
||||
icon.revalidate();
|
||||
}
|
||||
});
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
@@ -109,6 +109,7 @@ public abstract class XDebugProcess {
|
||||
/**
|
||||
* @deprecated Use {@link #startForceStepInto(XSuspendContext)} instead
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@Deprecated
|
||||
public void startForceStepInto(){
|
||||
//noinspection deprecation
|
||||
@@ -123,8 +124,7 @@ public abstract class XDebugProcess {
|
||||
* Do not call this method directly. Use {@link XDebugSession#forceStepInto} instead
|
||||
*/
|
||||
public void startForceStepInto(@Nullable XSuspendContext context) {
|
||||
//noinspection deprecation
|
||||
startForceStepInto();
|
||||
startStepInto(context);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+19
-20
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010 Bas Leijdekkers
|
||||
* Copyright 2010-2016 Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,14 +17,16 @@ package com.siyeh.ig.numeric;
|
||||
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiLiteralExpression;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.PsiReplacementUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class ConvertOctalLiteralToDecimalFix
|
||||
extends InspectionGadgetsFix {
|
||||
class ConvertOctalLiteralToDecimalFix extends InspectionGadgetsFix {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
@@ -34,24 +36,21 @@ class ConvertOctalLiteralToDecimalFix
|
||||
@Override
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"convert.octal.literal.to.decimal.literal.quickfix");
|
||||
return InspectionGadgetsBundle.message("convert.octal.literal.to.decimal.literal.quickfix");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doFix(Project project, ProblemDescriptor descriptor)
|
||||
throws IncorrectOperationException {
|
||||
protected void doFix(Project project, ProblemDescriptor descriptor) {
|
||||
final PsiElement element = descriptor.getPsiElement();
|
||||
if (!(element instanceof PsiLiteralExpression)) return;
|
||||
|
||||
final Object value = ((PsiLiteralExpression)element).getValue();
|
||||
if (value == null) return;
|
||||
|
||||
final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
|
||||
final PsiElementFactory factory = psiFacade.getElementFactory();
|
||||
final PsiExpression decimalNumber =
|
||||
factory.createExpressionFromText(value.toString(),
|
||||
element);
|
||||
element.replace(decimalNumber);
|
||||
if (!(element instanceof PsiLiteralExpression)) {
|
||||
return;
|
||||
}
|
||||
final PsiLiteralExpression literalExpression = (PsiLiteralExpression)element;
|
||||
final Object value = literalExpression.getValue();
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
final String decimalText = value + (PsiType.LONG.equals(literalExpression.getType()) ? "L" : "");
|
||||
PsiReplacementUtil.replaceExpression(literalExpression, decimalText);
|
||||
}
|
||||
}
|
||||
|
||||
+10
-19
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010 Bas Leijdekkers
|
||||
* Copyright 2010-2016 Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,13 +17,11 @@ package com.siyeh.ig.numeric;
|
||||
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementFactory;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.psi.PsiLiteralExpression;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.PsiReplacementUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class RemoveLeadingZeroFix extends InspectionGadgetsFix {
|
||||
@@ -31,8 +29,7 @@ class RemoveLeadingZeroFix extends InspectionGadgetsFix {
|
||||
@Override
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"remove.leading.zero.to.make.decimal.quickfix");
|
||||
return InspectionGadgetsBundle.message("remove.leading.zero.to.make.decimal.quickfix");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -42,11 +39,10 @@ class RemoveLeadingZeroFix extends InspectionGadgetsFix {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doFix(Project project, ProblemDescriptor descriptor)
|
||||
throws IncorrectOperationException {
|
||||
final PsiElement element = descriptor.getPsiElement();
|
||||
final String text = element.getText();
|
||||
final int max = text.length() - 1;
|
||||
protected void doFix(Project project, ProblemDescriptor descriptor) {
|
||||
final PsiLiteralExpression literal = (PsiLiteralExpression)descriptor.getPsiElement();
|
||||
final String text = literal.getText();
|
||||
final int max = text.length() - (PsiType.LONG.equals(literal.getType()) ? 2 : 1);
|
||||
if (max < 1) {
|
||||
return;
|
||||
}
|
||||
@@ -54,12 +50,7 @@ class RemoveLeadingZeroFix extends InspectionGadgetsFix {
|
||||
while (index < max && (text.charAt(index) == '0' || text.charAt(index) == '_')) {
|
||||
index++;
|
||||
}
|
||||
final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
|
||||
final PsiElementFactory factory = psiFacade.getElementFactory();
|
||||
final String textWithoutLeadingZeros = text.substring(index);
|
||||
final PsiExpression decimalNumber =
|
||||
factory.createExpressionFromText(textWithoutLeadingZeros,
|
||||
element);
|
||||
element.replace(decimalNumber);
|
||||
PsiReplacementUtil.replaceExpression(literal, textWithoutLeadingZeros);
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
class C {{
|
||||
long l = 0L;
|
||||
}}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
class C {{
|
||||
long l = <caret>00L;
|
||||
}}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
class C {
|
||||
long l = 0L;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
class C {
|
||||
long l = <caret>00L;
|
||||
}
|
||||
@@ -25,16 +25,24 @@ public class OctalLiteralFixesTest extends IGQuickFixesTestCase {
|
||||
myFixture.enableInspections(new OctalLiteralInspection());
|
||||
}
|
||||
|
||||
public void testConvertOctalToDecimal1() {
|
||||
doTest("ConvertToDecimal1", InspectionGadgetsBundle.message("convert.octal.literal.to.decimal.literal.quickfix"));
|
||||
public void testConvertToDecimal1() {
|
||||
doTest(InspectionGadgetsBundle.message("convert.octal.literal.to.decimal.literal.quickfix"));
|
||||
}
|
||||
|
||||
public void testConvertOctalToDecimal2() {
|
||||
doTest("ConvertToDecimal2", InspectionGadgetsBundle.message("convert.octal.literal.to.decimal.literal.quickfix"));
|
||||
public void testConvertToDecimal2() {
|
||||
doTest(InspectionGadgetsBundle.message("convert.octal.literal.to.decimal.literal.quickfix"));
|
||||
}
|
||||
|
||||
public void testConvertOctalToDecimalLong() {
|
||||
doTest(InspectionGadgetsBundle.message("convert.octal.literal.to.decimal.literal.quickfix"));
|
||||
}
|
||||
|
||||
public void testRemoveLeadingZero() {
|
||||
doTest("RemoveLeadingZero", InspectionGadgetsBundle.message("remove.leading.zero.to.make.decimal.quickfix"));
|
||||
doTest(InspectionGadgetsBundle.message("remove.leading.zero.to.make.decimal.quickfix"));
|
||||
}
|
||||
|
||||
public void testRemoveLeadingZeroLong() {
|
||||
doTest(InspectionGadgetsBundle.message("remove.leading.zero.to.make.decimal.quickfix"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -168,7 +168,7 @@ public class GitVcs extends AbstractVcs<CommittedChangeList> {
|
||||
* @param task the task to run
|
||||
*/
|
||||
public static void runInBackground(Task.Backgroundable task) {
|
||||
task.queue();
|
||||
UIUtil.invokeLaterIfNeeded(() -> task.queue());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+38
-1
@@ -540,7 +540,7 @@ public class GradleDependenciesImportingTest extends GradleImportingTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
@TargetVersions("2.5+")
|
||||
@TargetVersions("2.6+")
|
||||
public void testProjectSubstitutions() throws Exception {
|
||||
createSettingsFile("include 'core'\n" +
|
||||
"include 'service'\n" +
|
||||
@@ -644,4 +644,41 @@ public class GradleDependenciesImportingTest extends GradleImportingTestCase {
|
||||
assertModuleLibDepScope("project", "Gradle: junit:junit:4.11", DependencyScope.COMPILE);
|
||||
assertModuleLibDepScope("project", "Gradle: org.hamcrest:hamcrest-core:1.3", DependencyScope.PROVIDED, DependencyScope.RUNTIME);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TargetVersions("2.0+")
|
||||
public void testProvidedTransitiveDependencies() throws Exception {
|
||||
createSettingsFile("include 'projectA', 'projectB', 'projectC' ");
|
||||
importProject(
|
||||
"project(':projectA') {\n" +
|
||||
" apply plugin: 'java'\n" +
|
||||
"}\n" +
|
||||
"project(':projectB') {\n" +
|
||||
" apply plugin: 'java'\n" +
|
||||
" dependencies {\n" +
|
||||
" compile project(':projectA')\n" +
|
||||
" }\n" +
|
||||
"}\n" +
|
||||
"project(':projectC') {\n" +
|
||||
" apply plugin: 'war'\n" +
|
||||
" dependencies {\n" +
|
||||
" providedCompile project(':projectB')\n" +
|
||||
" }\n" +
|
||||
"}"
|
||||
);
|
||||
|
||||
assertModules("project", "projectA", "projectA_main", "projectA_test", "projectB", "projectB_main", "projectB_test", "projectC", "projectC_main", "projectC_test");
|
||||
|
||||
assertModuleModuleDepScope("projectB_main", "projectA_main", DependencyScope.COMPILE);
|
||||
assertModuleModuleDepScope("projectC_main", "projectA_main", DependencyScope.PROVIDED);
|
||||
assertModuleModuleDepScope("projectC_main", "projectB_main", DependencyScope.PROVIDED);
|
||||
|
||||
importProjectUsingSingeModulePerGradleProject();
|
||||
assertModules("project", "projectA", "projectB", "projectC");
|
||||
assertModuleModuleDepScope("projectB", "projectA", DependencyScope.COMPILE);
|
||||
if(GradleVersion.version(gradleVersion).compareTo(GradleVersion.version("2.5")) >= 0) {
|
||||
assertModuleModuleDepScope("projectC", "projectA", DependencyScope.PROVIDED);
|
||||
}
|
||||
assertModuleModuleDepScope("projectC", "projectB", DependencyScope.PROVIDED);
|
||||
}
|
||||
}
|
||||
|
||||
+9
-4
@@ -58,7 +58,7 @@ import java.util.regex.Pattern
|
||||
class DependencyResolverImpl implements DependencyResolver {
|
||||
|
||||
private static isArtifactResolutionQuerySupported = GradleVersion.current() >= GradleVersion.version("2.0")
|
||||
private static isDependencySubstitutionsSupported = GradleVersion.current() >= GradleVersion.version("2.5")
|
||||
private static isDependencySubstitutionsSupported = GradleVersion.current() > GradleVersion.version("2.5")
|
||||
|
||||
@NotNull
|
||||
private final Project myProject
|
||||
@@ -143,10 +143,15 @@ class DependencyResolverImpl implements DependencyResolver {
|
||||
Map<ComponentIdentifier, ComponentArtifactsResult> componentResultsMap = [:];
|
||||
componentResults.each { componentResultsMap.put(it.id, it) }
|
||||
|
||||
Multimap<ModuleComponentIdentifier, ProjectDependency> configurationProjectDependencies = ArrayListMultimap.create()
|
||||
configuration.incoming.dependencies.findAll { it instanceof ProjectDependency }.each {
|
||||
configurationProjectDependencies.put(toComponentIdentifier(it.group, it.name, it.version), it as ProjectDependency)
|
||||
def projectDeps
|
||||
projectDeps = { Configuration conf, map = ArrayListMultimap.create() ->
|
||||
conf.incoming.dependencies.findAll { it instanceof ProjectDependency }.each { it ->
|
||||
map.put(toComponentIdentifier(it.group, it.name, it.version), it as ProjectDependency)
|
||||
projectDeps((it as ProjectDependency).projectConfiguration, map)
|
||||
}
|
||||
map
|
||||
}
|
||||
Multimap<ModuleComponentIdentifier, ProjectDependency> configurationProjectDependencies = projectDeps(configuration)
|
||||
|
||||
ResolutionResult resolutionResult = configuration.incoming.resolutionResult
|
||||
if(!configuration.resolvedConfiguration.hasError()) {
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ public abstract class AbstractModelBuilderTest {
|
||||
|
||||
public static final Object[][] SUPPORTED_GRADLE_VERSIONS = {
|
||||
{"1.9"}, /*{"1.10"}, {"1.11"},*/ {"1.12"},
|
||||
{"2.0"}, /*{"2.1"}, {"2.2"} , {"2.3"}, {"2.4"}, {"2.5"}, {"2.6"}, {"2.7"}, {"2.8"},*/ {"2.9"}, /*{"2.10"}, {"2.11"}, {"2.12"},*/ {"2.13"}
|
||||
{"2.0"}, /*{"2.1"}, {"2.2"} , {"2.3"}, {"2.4"}, */{"2.5"}, /*{"2.6"}, {"2.7"}, {"2.8"},*/ {"2.9"}, /*{"2.10"}, {"2.11"}, {"2.12"},*/ {"2.13"}
|
||||
};
|
||||
public static final String BASE_GRADLE_VERSION = String.valueOf(SUPPORTED_GRADLE_VERSIONS[SUPPORTED_GRADLE_VERSIONS.length - 1][0]);
|
||||
|
||||
|
||||
+7
-2
@@ -54,6 +54,7 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod;
|
||||
@@ -115,8 +116,12 @@ public class GroovyPostHighlightingPass extends TextEditorHighlightingPass {
|
||||
myFile.accept(new PsiRecursiveElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitElement(PsiElement element) {
|
||||
if (element instanceof GrReferenceElement) {
|
||||
for (GroovyResolveResult result : ((GrReferenceElement)element).multiResolve(true)) {
|
||||
if (element instanceof GrReferenceExpression && !((GrReferenceElement)element).isQualified()) {
|
||||
GroovyResolveResult[] results = ((GrReferenceExpression)element).multiResolve(false);
|
||||
if (results.length == 0) {
|
||||
results = ((GrReferenceExpression)element).multiResolve(true);
|
||||
}
|
||||
for (GroovyResolveResult result : results) {
|
||||
PsiElement resolved = result.getElement();
|
||||
if (resolved instanceof GrParameter && resolved.getContainingFile() == myFile) {
|
||||
usedParams.put((GrParameter)resolved, Boolean.TRUE);
|
||||
|
||||
@@ -118,9 +118,9 @@ public abstract class DslPointcut<T,V> {
|
||||
|
||||
@Override
|
||||
List<GdslType> matches(GdslType src, ProcessingContext context) {
|
||||
final PsiFile placeFile = context.get(GdslUtil.INITIAL_CONTEXT).getPlaceFile();
|
||||
final PsiFile placeFile = context.get(GdslUtil.INITIAL_CONTEXT).justGetPlaceFile();
|
||||
if (ClassContextFilter.isSubtype(src.psiType, placeFile, (String)arg)) {
|
||||
return Arrays.asList(src);
|
||||
return Collections.singletonList(src);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+7
-21
@@ -15,14 +15,10 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.dsl.toplevel;
|
||||
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.patterns.ElementPattern;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.plugins.groovy.dsl.GroovyClassDescriptor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.ClassUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
|
||||
|
||||
@@ -31,27 +27,17 @@ import java.util.Map;
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class ClassContextFilter implements ContextFilter {
|
||||
private final Condition<Pair<PsiType, PsiFile>> myPattern;
|
||||
public class ClassContextFilter {
|
||||
|
||||
public ClassContextFilter(Condition<Pair<PsiType, PsiFile>> pattern) {
|
||||
myPattern = pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(GroovyClassDescriptor descriptor, ProcessingContext ctx) {
|
||||
return myPattern.value(Pair.create(descriptor.getPsiType(), descriptor.getPlaceFile()));
|
||||
}
|
||||
|
||||
public static ClassContextFilter fromClassPattern(final ElementPattern pattern) {
|
||||
return new ClassContextFilter(pair -> {
|
||||
final PsiType type = pair.first;
|
||||
public static ContextFilter fromClassPattern(ElementPattern pattern) {
|
||||
return (descriptor, ctx) -> {
|
||||
PsiType type = descriptor.getPsiType();
|
||||
return type instanceof PsiClassType && pattern.accepts(((PsiClassType)type).resolve());
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
public static ClassContextFilter subtypeOf(final String typeText) {
|
||||
return new ClassContextFilter(p -> isSubtype(p.first, p.second, typeText));
|
||||
public static ContextFilter subtypeOf(String typeText) {
|
||||
return (descriptor, ctx) -> isSubtype(descriptor.getPsiType(), descriptor.justGetPlaceFile(), typeText);
|
||||
}
|
||||
|
||||
public static boolean isSubtype(PsiType checked, PsiFile placeFile, String typeText) {
|
||||
|
||||
+2
-2
@@ -459,7 +459,7 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl<GrExpressi
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private GroovyResolveResult[] doPolyResolve(@SuppressWarnings("UnusedParameters") boolean incompleteCode) {
|
||||
private GroovyResolveResult[] doPolyResolve(boolean incompleteCode) {
|
||||
final PsiElement nameElement = getReferenceNameElement();
|
||||
final String name = getReferenceName();
|
||||
if (name == null || nameElement == null) return GroovyResolveResult.EMPTY_ARRAY;
|
||||
@@ -511,7 +511,7 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl<GrExpressi
|
||||
.setAllVariants(allVariants)
|
||||
.setUpToArgument(upToArgument)
|
||||
.build(this);
|
||||
new GrReferenceResolveRunner(this, processor).resolveImpl();
|
||||
GrReferenceResolveRunnerKt.resolveReferenceExpression(this, processor);
|
||||
return processor.getCandidatesArray();
|
||||
}
|
||||
|
||||
|
||||
-176
@@ -1,176 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.SpreadState;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GrTraitType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiManager;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.ClosureParameterEnhancer;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.ClosureMissingMethodContributor;
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint;
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.processors.GroovyResolverProcessor;
|
||||
|
||||
/**
|
||||
* @author Medvedev Max
|
||||
*/
|
||||
public class GrReferenceResolveRunner {
|
||||
private final GrReferenceExpression place;
|
||||
private final GroovyResolverProcessor processor;
|
||||
|
||||
public GrReferenceResolveRunner(GrReferenceExpression place,
|
||||
GroovyResolverProcessor processor) {
|
||||
this.place = place;
|
||||
this.processor = processor;
|
||||
}
|
||||
|
||||
public void resolveImpl() {
|
||||
GrExpression qualifier = place.getQualifier();
|
||||
if (qualifier == null) {
|
||||
if (!ResolveUtil.treeWalkUp(place, processor, true)) return;
|
||||
|
||||
if (place.getContext() instanceof GrMethodCall) {
|
||||
if (!ClosureMissingMethodContributor.processMethodsFromClosures(place, processor)) return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (place.getDotTokenType() == GroovyTokenTypes.mSPREAD_DOT) {
|
||||
final PsiType qtype = qualifier.getType();
|
||||
final PsiType componentType = ClosureParameterEnhancer.findTypeForIteration(qtype, place);
|
||||
if (componentType != null) {
|
||||
final ResolveState state = ResolveState.initial()
|
||||
.put(ClassHint.RESOLVE_CONTEXT, qualifier)
|
||||
.put(SpreadState.SPREAD_STATE, SpreadState.create(qtype, null));
|
||||
processQualifierType(componentType, state);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ResolveUtil.isClassReference(place)) return;
|
||||
if (!processJavaLangClass(qualifier)) return;
|
||||
processQualifier(qualifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean processJavaLangClass(@NotNull GrExpression qualifier) {
|
||||
if (!(qualifier instanceof GrReferenceExpression)) return true;
|
||||
|
||||
//optimization: only 'class' or 'this' in static context can be an alias of java.lang.Class
|
||||
if (!"class".equals(((GrReferenceExpression)qualifier).getReferenceName()) &&
|
||||
!PsiUtil.isThisReference(qualifier) &&
|
||||
!(((GrReferenceExpression)qualifier).resolve() instanceof PsiClass)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PsiType classType = ResolveUtil.unwrapClassType(qualifier.getType());
|
||||
return classType == null || processQualifierType(classType, ResolveState.initial().put(ClassHint.RESOLVE_CONTEXT, qualifier));
|
||||
}
|
||||
|
||||
private boolean processQualifier(@NotNull GrExpression qualifier) {
|
||||
PsiType qualifierType = qualifier.getType();
|
||||
ResolveState state = ResolveState.initial().put(ClassHint.RESOLVE_CONTEXT, qualifier);
|
||||
if (qualifierType == null || PsiType.VOID.equals(qualifierType)) {
|
||||
if (qualifier instanceof GrReferenceExpression) {
|
||||
PsiElement resolved = ((GrReferenceExpression)qualifier).resolve();
|
||||
if (resolved instanceof PsiClass) {
|
||||
if (!ResolveUtil.processClassDeclarations((PsiClass)resolved, processor, state, null, place)) return false;
|
||||
}
|
||||
else if (resolved != null && !resolved.processDeclarations(processor, state, null, place)) return false;
|
||||
if (!(resolved instanceof PsiPackage)) {
|
||||
PsiType objectQualifier = TypesUtil.getJavaLangObject(place);
|
||||
if (!processQualifierType(objectQualifier, state)) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!processQualifierType(qualifierType, state)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean processQualifierType(@NotNull PsiType originalQualifierType,
|
||||
@NotNull ResolveState state) {
|
||||
PsiType qualifierType = originalQualifierType instanceof PsiDisjunctionType
|
||||
? ((PsiDisjunctionType)originalQualifierType).getLeastUpperBound()
|
||||
: originalQualifierType;
|
||||
|
||||
if (qualifierType instanceof PsiIntersectionType) {
|
||||
for (PsiType conjunct : ((PsiIntersectionType)qualifierType).getConjuncts()) {
|
||||
if (!processQualifierType(conjunct, state)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (qualifierType instanceof PsiCapturedWildcardType) {
|
||||
PsiWildcardType wildcard = ((PsiCapturedWildcardType)qualifierType).getWildcard();
|
||||
if (wildcard.isExtends()) {
|
||||
PsiType bound = wildcard.getExtendsBound();
|
||||
return processQualifierType(bound, state);
|
||||
}
|
||||
}
|
||||
|
||||
if (qualifierType instanceof GrTraitType) {
|
||||
return processTraitType((GrTraitType)qualifierType, state);
|
||||
}
|
||||
|
||||
if (qualifierType instanceof PsiClassType) {
|
||||
PsiClassType.ClassResolveResult qualifierResult = ((PsiClassType)qualifierType).resolveGenerics();
|
||||
PsiClass qualifierClass = qualifierResult.getElement();
|
||||
if (qualifierClass != null) {
|
||||
if (!ResolveUtil.processClassDeclarations(qualifierClass, processor, state.put(PsiSubstitutor.KEY, qualifierResult.getSubstitutor()), null, place)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (qualifierType instanceof PsiArrayType) {
|
||||
final GroovyPsiManager gmanager = GroovyPsiManager.getInstance(place.getProject());
|
||||
final GrTypeDefinition arrayClass = gmanager.getArrayClass(((PsiArrayType)qualifierType).getComponentType());
|
||||
if (arrayClass != null && !ResolveUtil.processClassDeclarations(arrayClass, processor, state, null, place)) return false;
|
||||
}
|
||||
|
||||
if (!(place.getParent() instanceof GrMethodCall) && InheritanceUtil.isInheritor(qualifierType, CommonClassNames.JAVA_UTIL_COLLECTION)) {
|
||||
final PsiType componentType = ClosureParameterEnhancer.findTypeForIteration(qualifierType, place);
|
||||
if (componentType != null) {
|
||||
final SpreadState spreadState = state.get(SpreadState.SPREAD_STATE);
|
||||
processQualifierType(componentType, state.put(SpreadState.SPREAD_STATE, SpreadState.create(qualifierType, spreadState)));
|
||||
}
|
||||
}
|
||||
|
||||
if (!ResolveUtil.processCategoryMembers(place, processor, state)) return false;
|
||||
if (!ResolveUtil.processNonCodeMembers(qualifierType, processor, place, state)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process trait type conjuncts in reversed order because last applied trait matters.
|
||||
*/
|
||||
private boolean processTraitType(@NotNull GrTraitType traitType, @NotNull ResolveState state) {
|
||||
final PsiType[] conjuncts = traitType.getConjuncts();
|
||||
for (int i = conjuncts.length - 1; i >= 0; i--) {
|
||||
if (!processQualifierType(conjuncts[i], state)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions
|
||||
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.scope.PsiScopeProcessor
|
||||
import com.intellij.psi.util.InheritanceUtil
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.SpreadState
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GrTraitType
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiManager
|
||||
import org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.ClosureParameterEnhancer
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.ClosureMissingMethodContributor
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint
|
||||
|
||||
fun resolveReferenceExpression(place: GrReferenceExpression, processor: PsiScopeProcessor): Boolean {
|
||||
val qualifier = place.qualifier
|
||||
if (qualifier == null) {
|
||||
if (!ResolveUtil.treeWalkUp(place, processor, true)) return false
|
||||
return place.context !is GrMethodCall || ClosureMissingMethodContributor.processMethodsFromClosures(place, processor)
|
||||
}
|
||||
else {
|
||||
if (place.dotTokenType === GroovyTokenTypes.mSPREAD_DOT) {
|
||||
val qType = qualifier.type
|
||||
val componentType = ClosureParameterEnhancer.findTypeForIteration(qType, place)
|
||||
if (componentType != null) {
|
||||
val state = ResolveState.initial().put(ClassHint.RESOLVE_CONTEXT, qualifier).put(SpreadState.SPREAD_STATE, SpreadState.create(qType, null))
|
||||
return processQualifierType(place, componentType, processor, state)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ResolveUtil.isClassReference(place)) return false
|
||||
if (!processJavaLangClass(place, qualifier, processor)) return false
|
||||
return processQualifier(place, qualifier, processor)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun processJavaLangClass(place: PsiElement, qualifier: GrExpression, processor: PsiScopeProcessor): Boolean {
|
||||
if (qualifier !is GrReferenceExpression) return true
|
||||
|
||||
//optimization: only 'class' or 'this' in static context can be an alias of java.lang.Class
|
||||
if ("class" != qualifier.referenceName && !PsiUtil.isThisReference(qualifier) && qualifier.resolve() !is PsiClass) return true
|
||||
|
||||
val classType = ResolveUtil.unwrapClassType(qualifier.getType())
|
||||
return classType?.let {
|
||||
val state = ResolveState.initial().put(ClassHint.RESOLVE_CONTEXT, qualifier)
|
||||
processQualifierType(place, classType, processor, state)
|
||||
} ?: true
|
||||
}
|
||||
|
||||
fun processQualifier(place: PsiElement, qualifier: GrExpression, processor: PsiScopeProcessor): Boolean {
|
||||
val qualifierType = qualifier.type
|
||||
val state = ResolveState.initial().put(ClassHint.RESOLVE_CONTEXT, qualifier)
|
||||
if (qualifierType == null || PsiType.VOID == qualifierType) {
|
||||
if (qualifier is GrReferenceExpression) {
|
||||
val resolved = qualifier.resolve()
|
||||
if (resolved is PsiClass) {
|
||||
if (!ResolveUtil.processClassDeclarations((resolved as PsiClass?)!!, processor, state, null, place)) return false
|
||||
}
|
||||
else if (resolved != null && !resolved.processDeclarations(processor, state, null, place)) return false
|
||||
if (resolved !is PsiPackage) {
|
||||
val objectQualifier = TypesUtil.getJavaLangObject(place)
|
||||
if (!processQualifierType(place, objectQualifier, processor, state)) return false
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!processQualifierType(place, qualifierType, processor, state)) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun processQualifierType(place: PsiElement, qualifierType: PsiType, processor: PsiScopeProcessor, state: ResolveState): Boolean {
|
||||
val type = if (qualifierType is PsiDisjunctionType) qualifierType.leastUpperBound else qualifierType
|
||||
return doProcessQualifierType(place, type, processor, state)
|
||||
}
|
||||
|
||||
fun doProcessQualifierType(place: PsiElement, qualifierType: PsiType, processor: PsiScopeProcessor, state: ResolveState): Boolean {
|
||||
if (qualifierType is PsiIntersectionType) {
|
||||
return qualifierType.conjuncts.find { !processQualifierType(place, it, processor, state) } == null
|
||||
}
|
||||
|
||||
if (qualifierType is PsiCapturedWildcardType) {
|
||||
val wildcard = qualifierType.wildcard
|
||||
if (wildcard.isExtends) {
|
||||
return processQualifierType(place, wildcard.extendsBound, processor, state)
|
||||
}
|
||||
}
|
||||
|
||||
// Process trait type conjuncts in reversed order because last applied trait matters.
|
||||
if (qualifierType is GrTraitType) return qualifierType.conjuncts.findLast { !processQualifierType(place, it, processor, state) } == null
|
||||
|
||||
if (qualifierType is PsiClassType) {
|
||||
val qualifierResult = qualifierType.resolveGenerics()
|
||||
qualifierResult.element?.let {
|
||||
val resolveState = state.put(PsiSubstitutor.KEY, qualifierResult.substitutor)
|
||||
if (!ResolveUtil.processClassDeclarations(it, processor, resolveState, null, place)) return false
|
||||
}
|
||||
}
|
||||
else if (qualifierType is PsiArrayType) {
|
||||
GroovyPsiManager.getInstance(place.project).getArrayClass(qualifierType.componentType)?.let {
|
||||
if (!ResolveUtil.processClassDeclarations(it, processor, state, null, place)) return false
|
||||
}
|
||||
}
|
||||
|
||||
if (place.parent !is GrMethodCall && InheritanceUtil.isInheritor(qualifierType, CommonClassNames.JAVA_UTIL_COLLECTION)) {
|
||||
ClosureParameterEnhancer.findTypeForIteration(qualifierType, place)?.let {
|
||||
val spreadState = state.get(SpreadState.SPREAD_STATE)
|
||||
val resolveState = state.put(SpreadState.SPREAD_STATE, SpreadState.create(qualifierType, spreadState))
|
||||
if (!processQualifierType(place, it, processor, resolveState)) return false
|
||||
}
|
||||
}
|
||||
|
||||
if (!ResolveUtil.processCategoryMembers(place, processor, state)) return false
|
||||
if (!ResolveUtil.processNonCodeMembers(qualifierType, processor, place, state)) return false
|
||||
return true
|
||||
}
|
||||
+2
@@ -32,6 +32,7 @@ import com.intellij.util.containers.HashMap;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.TIntObjectHashMap;
|
||||
import gnu.trove.TObjectIntHashMap;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -634,6 +635,7 @@ public class TypesUtil {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Contract("null, _ -> false")
|
||||
public static boolean isClassType(@Nullable PsiType type, @NotNull String qName) {
|
||||
return qName.equals(getQualifiedName(type));
|
||||
}
|
||||
|
||||
+4
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,7 @@ import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.containers.hash.HashMap;
|
||||
import com.intellij.util.containers.hash.HashSet;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
@@ -286,6 +287,8 @@ public class ClosureParameterEnhancer extends AbstractClosureParameterEnhancer {
|
||||
return PsiImplUtil.normalizeWildcardTypeByPosition(type, qualifier);
|
||||
}
|
||||
|
||||
@Contract("null,_ -> null")
|
||||
@Nullable
|
||||
public static PsiType findTypeForIteration(@Nullable PsiType type, @NotNull PsiElement context) {
|
||||
final PsiManager manager = context.getManager();
|
||||
final GlobalSearchScope resolveScope = context.getResolveScope();
|
||||
|
||||
@@ -394,7 +394,9 @@ public class MavenIndex {
|
||||
myUpdateTimestamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
oldData.close(true);
|
||||
if(oldData != null) {
|
||||
oldData.close(true);
|
||||
}
|
||||
|
||||
for (File each : FileUtil.notNullize(myDir.listFiles())) {
|
||||
if (each.getName().startsWith(DATA_DIR_PREFIX) && !each.getName().equals(myDataDirName)) {
|
||||
|
||||
+23
-12
@@ -71,7 +71,7 @@
|
||||
</hspacer>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="b217f" binding="versionPanel" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="b217f" binding="versionPanel" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -82,7 +82,7 @@
|
||||
<grid id="19e9e" layout-manager="GridLayoutManager" row-count="1" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -117,21 +117,13 @@
|
||||
</grid>
|
||||
<vspacer id="b095d">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="d864d" class="com.intellij.ui.components.JBLabel" binding="mavenCoordinates">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Maven:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="1bd32" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -161,6 +153,25 @@
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="6c7af" class="com.intellij.ui.components.JBLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Maven:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="c5f78" class="com.intellij.ui.components.JBLabel" binding="mavenCoordinates">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<editable value="false"/>
|
||||
<opaque value="false"/>
|
||||
<requestFocusEnabled value="true"/>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
|
||||
+3
-2
@@ -74,6 +74,7 @@ public class RepositoryLibraryPropertiesEditor {
|
||||
this.model = model;
|
||||
this.project = project == null ? ProjectManager.getInstance().getDefaultProject() : project;
|
||||
repositoryLibraryDescription = description;
|
||||
mavenCoordinates.setCopyable(true);
|
||||
myReloadButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@@ -84,7 +85,7 @@ public class RepositoryLibraryPropertiesEditor {
|
||||
@Override
|
||||
public void onChange(RepositoryLibraryPropertiesEditor editor) {
|
||||
onChangeListener.onChange(editor);
|
||||
mavenCoordinates.setText("Maven: " + repositoryLibraryDescription.getMavenCoordinates(model.getVersion()));
|
||||
mavenCoordinates.setText(repositoryLibraryDescription.getMavenCoordinates(model.getVersion()));
|
||||
}
|
||||
};
|
||||
reloadVersionsAsync();
|
||||
@@ -253,7 +254,7 @@ public class RepositoryLibraryPropertiesEditor {
|
||||
return;
|
||||
}
|
||||
|
||||
ApplicationManager.getApplication().invokeLater(() -> initVersionsPanel(), ModalityState.any());
|
||||
ApplicationManager.getApplication().invokeLater(this::initVersionsPanel, ModalityState.any());
|
||||
}
|
||||
|
||||
private void versionsFailedToLoad() {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -470,7 +470,8 @@ class PyDBFrame: # No longer cdef because object was dying when only a reference
|
||||
if hasattr(frame, "f_back") and hasattr(frame.f_back, "f_locals"):
|
||||
frame.f_back.f_locals[RETURN_VALUES_PREFIX + name] = arg
|
||||
if main_debugger.remove_return_values_flag:
|
||||
# show return values was turned off, we should remove them from locals dict
|
||||
# Showing return values was turned off, we should remove them from locals dict.
|
||||
# The values can be in the current frame or in the back one
|
||||
for var_name in dict_keys(frame.f_locals):
|
||||
if var_name.startswith(RETURN_VALUES_PREFIX):
|
||||
dict_pop(frame.f_locals, var_name)
|
||||
@@ -565,7 +566,7 @@ class PyDBFrame: # No longer cdef because object was dying when only a reference
|
||||
|
||||
if can_skip and main_debugger.show_return_values:
|
||||
# trace function for showing return values after step over
|
||||
if info.pydev_step_cmd == CMD_STEP_OVER and frame.f_back == info.pydev_step_stop:
|
||||
if info.pydev_step_cmd == CMD_STEP_OVER and hasattr(frame, "f_back") and frame.f_back == info.pydev_step_stop:
|
||||
can_skip = False
|
||||
|
||||
# Let's check to see if we are in a function that has a breakpoint. If we don't have a breakpoint,
|
||||
|
||||
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user