mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+1
-1
@@ -26,7 +26,7 @@ public interface CompilationStatusListener extends EventListener {
|
||||
/**
|
||||
* Invoked in a Swing dispatch thread after the compilation is finished.
|
||||
*
|
||||
* @param aborted true if compilatioin has been cancelled
|
||||
* @param aborted true if compilation has been cancelled
|
||||
* @param errors error count
|
||||
* @param warnings warning count
|
||||
* @param compileContext context for the finished compilation
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ public class ModuleConfigurable extends ProjectStructureElementConfigurable<Modu
|
||||
|
||||
@Override
|
||||
public Icon getIcon(final boolean open) {
|
||||
return ModuleType.get(myModule).getIcon();
|
||||
return myModule.isDisposed() ? null : ModuleType.get(myModule).getIcon();
|
||||
}
|
||||
|
||||
public Module getModule() {
|
||||
|
||||
+7
-6
@@ -18,15 +18,13 @@ package com.intellij.codeInsight.completion;
|
||||
import com.intellij.codeInsight.TailType;
|
||||
import com.intellij.codeInsight.completion.scope.CompletionElement;
|
||||
import com.intellij.codeInsight.completion.scope.JavaCompletionProcessor;
|
||||
import com.intellij.codeInsight.editorActions.wordSelection.DocTagSelectioner;
|
||||
import com.intellij.codeInsight.lookup.*;
|
||||
import com.intellij.codeInspection.InspectionProfile;
|
||||
import com.intellij.codeInspection.SuppressionUtil;
|
||||
import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.CaretModel;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorModificationUtil;
|
||||
import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
@@ -171,13 +169,16 @@ public class JavaDocCompletionContributor extends CompletionContributor {
|
||||
result.addElement(LookupElementBuilder.create(description).withInsertHandler(new InsertHandler<LookupElement>() {
|
||||
@Override
|
||||
public void handleInsert(InsertionContext context, LookupElement item) {
|
||||
if (context.getCompletionChar() != Lookup.REPLACE_SELECT_CHAR) return;
|
||||
|
||||
context.commitDocument();
|
||||
PsiDocTag docTag = PsiTreeUtil.findElementOfClassAtOffset(context.getFile(), context.getStartOffset(), PsiDocTag.class, false);
|
||||
if (docTag != null) {
|
||||
int tagEnd = docTag.getTextRange().getEndOffset();
|
||||
Document document = context.getDocument();
|
||||
int tagEnd = DocTagSelectioner.getDocTagRange(docTag, document.getCharsSequence(), 0).getEndOffset();
|
||||
int tail = context.getTailOffset();
|
||||
if (tail < tagEnd) {
|
||||
context.getDocument().deleteString(tail, tagEnd);
|
||||
document.deleteString(tail, tagEnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-5
@@ -36,7 +36,11 @@ public class DocTagSelectioner extends WordSelectioner {
|
||||
@Override
|
||||
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
|
||||
List<TextRange> result = super.select(e, editorText, cursorOffset, editor);
|
||||
result.add(getDocTagRange((PsiDocTag)e, editorText, cursorOffset));
|
||||
return result;
|
||||
}
|
||||
|
||||
public static TextRange getDocTagRange(PsiDocTag e, CharSequence documentText, int minOffset) {
|
||||
TextRange range = e.getTextRange();
|
||||
|
||||
int endOffset = range.getEndOffset();
|
||||
@@ -49,7 +53,7 @@ public class DocTagSelectioner extends WordSelectioner {
|
||||
|
||||
int childStartOffset = child.getTextRange().getStartOffset();
|
||||
|
||||
if (childStartOffset <= cursorOffset) {
|
||||
if (childStartOffset <= minOffset) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -71,10 +75,8 @@ public class DocTagSelectioner extends WordSelectioner {
|
||||
endOffset = Math.min(childStartOffset, endOffset);
|
||||
}
|
||||
|
||||
startOffset = CharArrayUtil.shiftBackward(editorText, startOffset - 1, "* \t") + 1;
|
||||
startOffset = CharArrayUtil.shiftBackward(documentText, startOffset - 1, "* \t") + 1;
|
||||
|
||||
result.add(new TextRange(startOffset, endOffset));
|
||||
|
||||
return result;
|
||||
return new TextRange(startOffset, endOffset);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-13
@@ -169,7 +169,10 @@ public class UncheckedWarningLocalInspection extends BaseJavaLocalInspectionTool
|
||||
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder,
|
||||
boolean isOnTheFly,
|
||||
@NotNull LocalInspectionToolSession session) {
|
||||
return new UncheckedWarningsVisitor(isOnTheFly, PsiUtil.getLanguageLevel(session.getFile())){
|
||||
LanguageLevel languageLevel = PsiUtil.getLanguageLevel(session.getFile());
|
||||
if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_5)) return super.buildVisitor(holder, isOnTheFly, session);
|
||||
|
||||
return new UncheckedWarningsVisitor(isOnTheFly, languageLevel){
|
||||
@Override
|
||||
protected void registerProblem(@NotNull String message, @NotNull PsiElement psiElement, @NotNull LocalQuickFix[] quickFixes) {
|
||||
holder.registerProblem(psiElement, message, quickFixes);
|
||||
@@ -194,9 +197,8 @@ public class UncheckedWarningLocalInspection extends BaseJavaLocalInspectionTool
|
||||
@Override
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
if (IGNORE_UNCHECKED_GENERICS_ARRAY_CREATION) return;
|
||||
if (!myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_5)) return;
|
||||
final JavaResolveResult result = expression.advancedResolve(false);
|
||||
if (JavaGenericsUtil.isUncheckedWarning(expression, result, PsiUtil.getLanguageLevel(expression))) {
|
||||
if (JavaGenericsUtil.isUncheckedWarning(expression, result, myLanguageLevel)) {
|
||||
registerProblem("Unchecked generics array creation for varargs parameter", expression, LocalQuickFix.EMPTY_ARRAY);
|
||||
}
|
||||
}
|
||||
@@ -205,7 +207,6 @@ public class UncheckedWarningLocalInspection extends BaseJavaLocalInspectionTool
|
||||
public void visitNewExpression(PsiNewExpression expression) {
|
||||
super.visitNewExpression(expression);
|
||||
if (IGNORE_UNCHECKED_GENERICS_ARRAY_CREATION) return;
|
||||
if (!myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_5)) return;
|
||||
final PsiJavaCodeReferenceElement classReference = expression.getClassOrAnonymousClassReference();
|
||||
if (classReference != null && JavaGenericsUtil.isUncheckedWarning(classReference, expression.resolveMethodGenerics(), myLanguageLevel)) {
|
||||
registerProblem("Unchecked generics array creation for varargs parameter", classReference, LocalQuickFix.EMPTY_ARRAY);
|
||||
@@ -216,7 +217,6 @@ public class UncheckedWarningLocalInspection extends BaseJavaLocalInspectionTool
|
||||
public void visitTypeCastExpression(PsiTypeCastExpression expression) {
|
||||
super.visitTypeCastExpression(expression);
|
||||
if (IGNORE_UNCHECKED_CAST) return;
|
||||
if (!PsiUtil.isLanguageLevel5OrHigher(expression)) return;
|
||||
final PsiTypeElement typeElement = expression.getCastType();
|
||||
if (typeElement == null) return;
|
||||
final PsiType castType = typeElement.getType();
|
||||
@@ -236,7 +236,6 @@ public class UncheckedWarningLocalInspection extends BaseJavaLocalInspectionTool
|
||||
@Override
|
||||
public void visitCallExpression(PsiCallExpression callExpression) {
|
||||
super.visitCallExpression(callExpression);
|
||||
if (!PsiUtil.isLanguageLevel5OrHigher(callExpression)) return;
|
||||
final JavaResolveResult result = callExpression.resolveMethodGenerics();
|
||||
final String description = getUncheckedCallDescription(result);
|
||||
if (description != null) {
|
||||
@@ -275,7 +274,6 @@ public class UncheckedWarningLocalInspection extends BaseJavaLocalInspectionTool
|
||||
public void visitVariable(PsiVariable variable) {
|
||||
super.visitVariable(variable);
|
||||
if (IGNORE_UNCHECKED_ASSIGNMENT) return;
|
||||
if (!PsiUtil.isLanguageLevel5OrHigher(variable)) return;
|
||||
PsiExpression initializer = variable.getInitializer();
|
||||
if (initializer == null || initializer instanceof PsiArrayInitializerExpression) return;
|
||||
final PsiType initializerType = initializer.getType();
|
||||
@@ -287,13 +285,11 @@ public class UncheckedWarningLocalInspection extends BaseJavaLocalInspectionTool
|
||||
public void visitForeachStatement(PsiForeachStatement statement) {
|
||||
super.visitForeachStatement(statement);
|
||||
if (IGNORE_UNCHECKED_ASSIGNMENT) return;
|
||||
if (!PsiUtil.isLanguageLevel5OrHigher(statement)) return;
|
||||
final PsiParameter parameter = statement.getIterationParameter();
|
||||
final PsiType parameterType = parameter.getType();
|
||||
final PsiExpression iteratedValue = statement.getIteratedValue();
|
||||
if (iteratedValue == null) return;
|
||||
final PsiType itemType = JavaGenericsUtil.getCollectionItemType(iteratedValue);
|
||||
if (!PsiUtil.isLanguageLevel5OrHigher(statement)) return;
|
||||
checkRawToGenericsAssignment(parameter, parameterType, itemType, true, myOnTheFly ? getChangeVariableTypeFixes(parameter, itemType) : LocalQuickFix.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
@@ -301,7 +297,6 @@ public class UncheckedWarningLocalInspection extends BaseJavaLocalInspectionTool
|
||||
public void visitAssignmentExpression(PsiAssignmentExpression expression) {
|
||||
super.visitAssignmentExpression(expression);
|
||||
if (IGNORE_UNCHECKED_ASSIGNMENT) return;
|
||||
if (!PsiUtil.isLanguageLevel5OrHigher(expression)) return;
|
||||
if (!"=".equals(expression.getOperationSign().getText())) return;
|
||||
PsiExpression lExpr = expression.getLExpression();
|
||||
PsiExpression rExpr = expression.getRExpression();
|
||||
@@ -323,7 +318,6 @@ public class UncheckedWarningLocalInspection extends BaseJavaLocalInspectionTool
|
||||
public void visitArrayInitializerExpression(PsiArrayInitializerExpression arrayInitializer) {
|
||||
super.visitArrayInitializerExpression(arrayInitializer);
|
||||
if (IGNORE_UNCHECKED_ASSIGNMENT) return;
|
||||
if (!PsiUtil.isLanguageLevel5OrHigher(arrayInitializer)) return;
|
||||
final PsiType type = arrayInitializer.getType();
|
||||
if (!(type instanceof PsiArrayType)) return;
|
||||
final PsiType componentType = ((PsiArrayType)type).getComponentType();
|
||||
@@ -374,7 +368,6 @@ public class UncheckedWarningLocalInspection extends BaseJavaLocalInspectionTool
|
||||
public void visitMethod(PsiMethod method) {
|
||||
super.visitMethod(method);
|
||||
if (IGNORE_UNCHECKED_OVERRIDING) return;
|
||||
if (!PsiUtil.isLanguageLevel5OrHigher(method)) return;
|
||||
if (!method.isConstructor()) {
|
||||
List<HierarchicalMethodSignature> superMethodSignatures = method.getHierarchicalMethodSignature().getSuperSignatures();
|
||||
if (!superMethodSignatures.isEmpty() && !method.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
@@ -405,7 +398,6 @@ public class UncheckedWarningLocalInspection extends BaseJavaLocalInspectionTool
|
||||
public void visitReturnStatement(PsiReturnStatement statement) {
|
||||
super.visitReturnStatement(statement);
|
||||
if (IGNORE_UNCHECKED_ASSIGNMENT) return;
|
||||
if (!PsiUtil.isLanguageLevel5OrHigher(statement)) return;
|
||||
final PsiMethod method = PsiTreeUtil.getParentOfType(statement, PsiMethod.class);
|
||||
if (method != null) {
|
||||
final PsiType returnType = method.getReturnType();
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.lang.java;
|
||||
|
||||
import com.intellij.lang.LiteralEscaper;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiJavaToken;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class JavaLiteralEscaper implements LiteralEscaper {
|
||||
@Override
|
||||
public String getEscapedText(final PsiElement context, final String originalText) {
|
||||
if (context instanceof PsiJavaToken && ((PsiJavaToken)context).getTokenType() == JavaTokenType.STRING_LITERAL) {
|
||||
return StringUtil.escapeStringCharacters(originalText);
|
||||
}
|
||||
return originalText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeText(String originalText) {
|
||||
return StringUtil.escapeStringCharacters(originalText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String unescapeText(String originalText) {
|
||||
return StringUtil.unescapeStringCharacters(originalText);
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public class GenericsUtil {
|
||||
PsiType mapping2 = subst2.substitute(parameter);
|
||||
|
||||
if (mapping1 != null && mapping2 != null) {
|
||||
substitutor = substitutor.put(parameter, getLeastContainingTypeArgument(mapping1, mapping2, compared, manager));
|
||||
substitutor = substitutor.put(parameter, getLeastContainingTypeArgument(mapping1, mapping2, compared, manager, type1.equals(mapping1) && type2.equals(mapping2) ? aSuper : null, parameter));
|
||||
}
|
||||
else {
|
||||
substitutor = substitutor.put(parameter, null);
|
||||
@@ -150,9 +150,23 @@ public class GenericsUtil {
|
||||
private static PsiType getLeastContainingTypeArgument(PsiType type1,
|
||||
PsiType type2,
|
||||
Set<Pair<PsiType, PsiType>> compared,
|
||||
PsiManager manager) {
|
||||
PsiManager manager,
|
||||
PsiClass nestedLayer,
|
||||
PsiTypeParameter parameter) {
|
||||
Pair<PsiType, PsiType> types = new Pair<PsiType, PsiType>(type1, type2);
|
||||
if (compared.contains(types)) return PsiWildcardType.createUnbounded(manager);
|
||||
if (compared.contains(types)) {
|
||||
if (nestedLayer != null) {
|
||||
PsiSubstitutor subst = PsiSubstitutor.EMPTY;
|
||||
for (PsiTypeParameter param : PsiUtil.typeParametersIterable(nestedLayer)) {
|
||||
subst = subst.put(param, PsiWildcardType.createUnbounded(manager));
|
||||
}
|
||||
subst = subst.put(parameter, getLeastContainingTypeArgument(type1, type2, compared, manager, null, null));
|
||||
|
||||
final PsiClassType boundType = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createType(nestedLayer, subst);
|
||||
return PsiWildcardType.createExtends(manager, boundType);
|
||||
}
|
||||
return PsiWildcardType.createUnbounded(manager);
|
||||
}
|
||||
compared.add(types);
|
||||
|
||||
try {
|
||||
@@ -180,7 +194,7 @@ public class GenericsUtil {
|
||||
}
|
||||
}
|
||||
else if (type2 instanceof PsiWildcardType) {
|
||||
return getLeastContainingTypeArgument(type2, type1, compared, manager);
|
||||
return getLeastContainingTypeArgument(type2, type1, compared, manager, null, null);
|
||||
}
|
||||
//Done with wildcards
|
||||
|
||||
|
||||
@@ -87,7 +87,12 @@ public class LambdaHighlightingUtil {
|
||||
|
||||
@Nullable
|
||||
public static String checkInterfaceFunctional(PsiType functionalInterfaceType) {
|
||||
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(functionalInterfaceType);
|
||||
if (functionalInterfaceType instanceof PsiIntersectionType) {
|
||||
for (PsiType type : ((PsiIntersectionType)functionalInterfaceType).getConjuncts()) {
|
||||
if (checkInterfaceFunctional(type) == null) return null;
|
||||
}
|
||||
}
|
||||
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(GenericsUtil.eliminateWildcards(functionalInterfaceType));
|
||||
final PsiClass aClass = resolveResult.getElement();
|
||||
if (aClass != null) {
|
||||
if (checkReturnTypeApplicable(resolveResult, aClass)) {
|
||||
@@ -95,7 +100,7 @@ public class LambdaHighlightingUtil {
|
||||
}
|
||||
return checkInterfaceFunctional(aClass);
|
||||
}
|
||||
return null;
|
||||
return functionalInterfaceType.getPresentableText() + " is not a functional interface";
|
||||
}
|
||||
|
||||
private static boolean checkReturnTypeApplicable(PsiClassType.ClassResolveResult resolveResult, final PsiClass aClass) {
|
||||
|
||||
@@ -484,23 +484,30 @@ public class LambdaUtil {
|
||||
}
|
||||
}
|
||||
else if (parent instanceof PsiReturnStatement) {
|
||||
final PsiMethod method = PsiTreeUtil.getParentOfType(parent, PsiMethod.class);
|
||||
if (method != null) {
|
||||
return method.getReturnType();
|
||||
final PsiLambdaExpression gParent = PsiTreeUtil.getParentOfType(parent, PsiLambdaExpression.class);
|
||||
if (gParent != null) {
|
||||
return getFunctionalInterfaceTypeByContainingLambda(gParent);
|
||||
} else {
|
||||
final PsiMethod method = PsiTreeUtil.getParentOfType(parent, PsiMethod.class);
|
||||
if (method != null) {
|
||||
return method.getReturnType();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (parent instanceof PsiLambdaExpression) {
|
||||
final PsiType parentInterfaceType = ((PsiLambdaExpression)parent).getFunctionalInterfaceType();
|
||||
if (parentInterfaceType != null) {
|
||||
return getFunctionalInterfaceReturnType(parentInterfaceType);
|
||||
}
|
||||
return getFunctionalInterfaceTypeByContainingLambda((PsiLambdaExpression)parent);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static PsiType getFunctionalInterfaceTypeByContainingLambda(@NotNull PsiLambdaExpression parentLambda) {
|
||||
final PsiType parentInterfaceType = parentLambda.getFunctionalInterfaceType();
|
||||
return parentInterfaceType != null ? getFunctionalInterfaceReturnType(parentInterfaceType) : null;
|
||||
}
|
||||
|
||||
private static int adjustLambdaIdx(int lambdaIdx, PsiMethod resolve, PsiParameter[] parameters) {
|
||||
final int finalLambdaIdx;
|
||||
if (((PsiMethod)resolve).isVarArgs() && lambdaIdx >= parameters.length) {
|
||||
if (resolve.isVarArgs() && lambdaIdx >= parameters.length) {
|
||||
finalLambdaIdx = parameters.length - 1;
|
||||
} else {
|
||||
finalLambdaIdx = lambdaIdx;
|
||||
@@ -524,7 +531,6 @@ public class LambdaUtil {
|
||||
final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(param, PsiLambdaExpression.class);
|
||||
if (lambdaExpression != null) {
|
||||
|
||||
final PsiParameterList parameterList = lambdaExpression.getParameterList();
|
||||
PsiType type = getFunctionalInterfaceType(lambdaExpression, true, parameterIndex);
|
||||
if (type == null) {
|
||||
type = getFunctionalInterfaceType(lambdaExpression, false);
|
||||
|
||||
@@ -541,7 +541,7 @@ public class ExceptionUtil {
|
||||
List<PsiClassType> result = ContainerUtil.newArrayList();
|
||||
|
||||
for (PsiClassType referencedType : referencedTypes) {
|
||||
final PsiType type = substitutor.substitute(referencedType);
|
||||
final PsiType type = GenericsUtil.eliminateWildcards(substitutor.substitute(referencedType), false);
|
||||
if (!(type instanceof PsiClassType)) continue;
|
||||
PsiClassType classType = (PsiClassType)type;
|
||||
PsiClass exceptionClass = ((PsiClassType)type).resolve();
|
||||
|
||||
+1
-1
@@ -863,7 +863,7 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
|
||||
PsiType patternType,
|
||||
final ConstraintType constraintType,
|
||||
final int depth) {
|
||||
if (arg instanceof PsiCapturedWildcardType) arg = ((PsiCapturedWildcardType)arg).getWildcard(); //reopen
|
||||
if (arg instanceof PsiCapturedWildcardType && (depth < 2 || constraintType != ConstraintType.EQUALS)) arg = ((PsiCapturedWildcardType)arg).getWildcard(); //reopen
|
||||
|
||||
if (patternType.equals(param)) {
|
||||
return processArgType(arg, constraintType, depth < 2);
|
||||
|
||||
+2
-1
@@ -382,7 +382,8 @@ public class PsiLiteralExpressionImpl
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiReference[] getReferences() {
|
||||
return PsiReferenceService.getService().getContributedReferences(this);
|
||||
PsiReference[] references = PsiReferenceService.getService().getContributedReferences(this);
|
||||
return references;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
interface I<T extends Exception> {
|
||||
void m() throws T;
|
||||
}
|
||||
|
||||
class C {
|
||||
void x(I<?> i) {
|
||||
<error descr="Unhandled exception: java.lang.Exception">i.m();</error>
|
||||
}
|
||||
|
||||
void y(I<? extends Exception> i) {
|
||||
<error descr="Unhandled exception: java.lang.Exception">i.m();</error>
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ class A<T> {
|
||||
}
|
||||
|
||||
void bar(A<?> x){
|
||||
baz<error descr="'baz(A<A<?>>)' in 'A' cannot be applied to '(A<A<capture<?>>>)'">(x.foo())</error>;
|
||||
baz<error descr="'baz(A<A<? extends S>>)' in 'A' cannot be applied to '(A<A<capture<?>>>)'">(x.foo())</error>;
|
||||
}
|
||||
|
||||
<S> void baz(A<A<? extends S>> x){}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class A<T> {
|
||||
A<A<? super A<T>>> foo(){
|
||||
return null;
|
||||
}
|
||||
|
||||
void bar(A<?> x){
|
||||
baz(x.foo());
|
||||
}
|
||||
|
||||
<S> void baz(A<A<? super A<S>>> x){}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
class A<T> {}
|
||||
|
||||
class B<T> extends A<A<T>> {
|
||||
void bar(B<?> b, B<? extends String> eb, B<? super String> sb, B<String> s) {
|
||||
foo(b);
|
||||
foo(eb);
|
||||
foo(sb);
|
||||
foo(s);
|
||||
|
||||
<error descr="Inferred type 'capture<?>' for type parameter 'T' is not within its bound; should extend 'java.lang.String'">foo1(b)</error>;
|
||||
foo1(eb);
|
||||
<error descr="Inferred type 'capture<? super java.lang.String>' for type parameter 'T' is not within its bound; should extend 'java.lang.String'">foo1(sb)</error>;
|
||||
foo1(s);
|
||||
|
||||
foo2(b);
|
||||
foo2(eb);
|
||||
foo2(sb);
|
||||
foo2(s);
|
||||
|
||||
foo3<error descr="'foo3(A<A<? extends T>>)' in 'B' cannot be applied to '(B<capture<?>>)'">(b)</error>;
|
||||
foo3<error descr="'foo3(A<A<? extends T>>)' in 'B' cannot be applied to '(B<capture<? extends java.lang.String>>)'">(eb)</error>;
|
||||
foo3<error descr="'foo3(A<A<? extends T>>)' in 'B' cannot be applied to '(B<capture<? super java.lang.String>>)'">(sb)</error>;
|
||||
foo3<error descr="'foo3(A<A<? extends java.lang.String>>)' in 'B' cannot be applied to '(B<java.lang.String>)'">(s)</error>;
|
||||
|
||||
foo4<error descr="'foo4(A<A<? super T>>)' in 'B' cannot be applied to '(B<capture<?>>)'">(b)</error>;
|
||||
foo4<error descr="'foo4(A<A<? super T>>)' in 'B' cannot be applied to '(B<capture<? extends java.lang.String>>)'">(eb)</error>;
|
||||
foo4<error descr="'foo4(A<A<? super T>>)' in 'B' cannot be applied to '(B<capture<? super java.lang.String>>)'">(sb)</error>;
|
||||
foo4<error descr="'foo4(A<A<? super java.lang.String>>)' in 'B' cannot be applied to '(B<java.lang.String>)'">(s)</error>;
|
||||
|
||||
foo5(b);
|
||||
foo5(eb);
|
||||
foo5(sb);
|
||||
foo5(s);
|
||||
}
|
||||
|
||||
|
||||
<T> void foo(A<A<T>> x) {}
|
||||
<T extends String> void foo1(A<A<T>> x) {}
|
||||
<T> void foo2(A<? extends A<T>> x) {}
|
||||
<T> void foo3(A<A<? extends T>> x) {}
|
||||
<T> void foo4(A<A<? super T>> x) {}
|
||||
<T> void foo5(A<? super A<T>> x) {}
|
||||
}
|
||||
+42
-2
@@ -8,7 +8,7 @@ class Test {
|
||||
}
|
||||
|
||||
void foo() {
|
||||
<error descr="Incompatible types. Found: 'java.util.List<java.lang.Class<? extends java.io.Serializable & java.lang.Comparable<?>>>', required: 'java.util.List<java.lang.Class<? extends java.io.Serializable>>'">List<Class<? extends Serializable>> l = <warning descr="Unchecked generics array creation for varargs parameter">this.asList</warning>(String.class, Integer.class);</error>
|
||||
<error descr="Incompatible types. Found: 'java.util.List<java.lang.Class<? extends java.io.Serializable & java.lang.Comparable<? extends java.lang.Comparable<?>>>>', required: 'java.util.List<java.lang.Class<? extends java.io.Serializable>>'">List<Class<? extends Serializable>> l = <warning descr="Unchecked generics array creation for varargs parameter">this.asList</warning>(String.class, Integer.class);</error>
|
||||
l.size();
|
||||
List<? extends Object> objects = this.asList(new String(), new Integer(0));
|
||||
objects.size();
|
||||
@@ -146,7 +146,7 @@ class IDEADEV25515 {
|
||||
}
|
||||
|
||||
public static final
|
||||
<error descr="Incompatible types. Found: 'java.util.List<java.lang.Class<? extends java.io.Serializable & java.lang.Comparable<?>>>', required: 'java.util.List<java.lang.Class<? extends java.io.Serializable>>'">List<Class<? extends Serializable>> SIMPLE_TYPES =
|
||||
<error descr="Incompatible types. Found: 'java.util.List<java.lang.Class<? extends java.io.Serializable & java.lang.Comparable<? extends java.lang.Comparable<?>>>>', required: 'java.util.List<java.lang.Class<? extends java.io.Serializable>>'">List<Class<? extends Serializable>> SIMPLE_TYPES =
|
||||
<warning descr="Unchecked generics array creation for varargs parameter">asList</warning>(String.class, Integer.class ,Long.class, Double.class, /*Date.class,*/
|
||||
Boolean.class, Boolean.TYPE /*,String[].class */ /*,BigDecimal.class*/);</error>
|
||||
|
||||
@@ -179,3 +179,43 @@ public class MaximalType {
|
||||
class M extends MaximalType implements L{}
|
||||
class M2 extends MaximalType implements L{}
|
||||
/////////////
|
||||
|
||||
|
||||
class IDEA67676 {
|
||||
interface I<<warning descr="Type parameter 'T' is never used">T</warning>> {}
|
||||
interface A<T> extends I<A<T>>{}
|
||||
interface Com2<T, U> {
|
||||
void foo(T t, U u);
|
||||
}
|
||||
interface Com1<T> {
|
||||
void foo(T t);
|
||||
}
|
||||
|
||||
abstract class X {
|
||||
abstract <T> T foo(T x, T y);
|
||||
|
||||
void bar(A<A2> x, A<B2> y) {
|
||||
A<? extends Com2<? extends Com2<?, ?>, ? extends Com2<?, ?>>> f = foo(x, y);
|
||||
f.hashCode();
|
||||
}
|
||||
|
||||
void boo(A<A3> x, A<B3> y) {
|
||||
A<? extends Com2<? extends Com2<?, ?>, ? extends Com2<?, ?>>> f = foo(x, y);
|
||||
f.hashCode();
|
||||
}
|
||||
|
||||
void baz(A<A1> x, A<B1> y) {
|
||||
A<? extends Com1<? extends Com1<?>>> f = foo(x, y);
|
||||
f.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class A1 implements Com1<A1> {}
|
||||
abstract class B1 implements Com1<B1> {}
|
||||
|
||||
abstract class A2 implements Com2<A2, A2> {}
|
||||
abstract class B2 implements Com2<B2, B2> {}
|
||||
|
||||
abstract class A3 implements Com2<A3, B3> {}
|
||||
abstract class B3 implements Com2<B3, A3> {}
|
||||
}
|
||||
+1
-1
@@ -22,6 +22,6 @@ class CastInContexts {
|
||||
}
|
||||
|
||||
{
|
||||
int i = <error descr="Inconvertible types; cannot cast '<lambda expression>' to 'int'">(int) ()-> 1</error>;
|
||||
int i = (int) <error descr="int is not a functional interface">()-> 1</error>;
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class Demo {
|
||||
public static void main(String[] args) {
|
||||
Runnable r = () -> <error descr="void is not a functional interface">() -> () -> {}</error>;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -16,7 +16,7 @@ class NoInferenceResult {
|
||||
|
||||
void test() {
|
||||
m((String s1) -> <error descr="Target type of a lambda conversion must be an interface">(String s2) -> s1 + s2</error>);
|
||||
m(<error descr="Incompatible return type <lambda expression> in lambda expression">(String s1) -> {return (String s2) -> s1 + s2;}</error>);
|
||||
m((String s1) -> {return <error descr="Target type of a lambda conversion must be an interface">(String s2) -> s1 + s2</error>;});
|
||||
|
||||
m((String s1) -> s1.length());
|
||||
m((String s1) -> s1);
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ class Test2 {
|
||||
}
|
||||
|
||||
{
|
||||
X<?> x = <error descr="No instance of type X<?> exists so that lambda expression can be type-checked">() -> 123</error>;
|
||||
X<?> x = () -> 123;
|
||||
X<? extends Number> x1 = () -> 123;
|
||||
|
||||
}
|
||||
|
||||
+15
-1
@@ -221,6 +221,7 @@ class Foo {
|
||||
class Foo {
|
||||
/**
|
||||
* @param intParam so<caret> xxx
|
||||
* @throws Foo
|
||||
*/
|
||||
void foo2(int intParam, Object param2) { }
|
||||
|
||||
@@ -234,7 +235,20 @@ class Foo {
|
||||
myFixture.assertPreferredCompletionItems 0, 'some', 'some integer param'
|
||||
myFixture.lookup.currentItem = myFixture.lookupElements[1]
|
||||
myFixture.type('\t')
|
||||
assert !myFixture.editor.document.text.contains('xxx')
|
||||
myFixture.checkResult '''
|
||||
class Foo {
|
||||
/**
|
||||
* @param intParam some integer param<caret>
|
||||
* @throws Foo
|
||||
*/
|
||||
void foo2(int intParam, Object param2) { }
|
||||
|
||||
/**
|
||||
* @param intParam some integer param
|
||||
*/
|
||||
void foo(int intParam, Object param2) { }
|
||||
}
|
||||
'''
|
||||
}
|
||||
|
||||
public void "test see super class"() {
|
||||
|
||||
@@ -307,6 +307,8 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA109556() { doTest5(false); }
|
||||
public void testIDEA107440() { doTest5(false); }
|
||||
public void testIDEA57289() { doTest5(false); }
|
||||
public void testIDEA57439() { doTest5(false); }
|
||||
public void testIDEA57312() { doTest5(false); }
|
||||
|
||||
public void testJavaUtilCollections_NoVerify() throws Exception {
|
||||
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
|
||||
|
||||
+1
@@ -58,4 +58,5 @@ public class LightAdvHighlightingJdk6Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testClassObjectAccessibility() throws Exception { setLanguageLevel(LanguageLevel.JDK_1_6); doTest(false, false); }
|
||||
public void testRedundantCastInConditionalExpression() throws Exception { setLanguageLevel(LanguageLevel.JDK_1_6); doTest(true, false); }
|
||||
public void testJava5CastConventions() { setLanguageLevel(LanguageLevel.JDK_1_5); doTest(true, false); }
|
||||
public void testUnhandledExceptions() { doTest(true, false); }
|
||||
}
|
||||
|
||||
+1
@@ -89,6 +89,7 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testConflictResolution() throws Exception {doTest();}
|
||||
public void testIDEA108195() throws Exception {doTest();}
|
||||
public void testDiamondInference() throws Exception { doTest();}
|
||||
public void testFunctionalInterfaceCheck() throws Exception { doTest();}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
|
||||
@@ -188,7 +188,7 @@ public abstract class DaemonAnalyzerTestCase extends CodeInsightTestCase {
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
((StartupManagerImpl)StartupManager.getInstance(getProject())).checkCleared();
|
||||
((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).cleanupAfterTest(!LightPlatformTestCase.isLight(getProject()));
|
||||
((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).cleanupAfterTest();
|
||||
super.tearDown();
|
||||
//((VirtualFilePointerManagerImpl)VirtualFilePointerManager.getInstance()).assertPointersDisposed();
|
||||
}
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ public abstract class LightDaemonAnalyzerTestCase extends LightCodeInsightTestCa
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).cleanupAfterTest(!isLight(getProject()));
|
||||
((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).cleanupAfterTest();
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Bootstrap {
|
||||
}
|
||||
|
||||
public static void main(String[] args, String mainClass, String methodName, List<URL> classpathElements) throws Exception {
|
||||
UrlClassLoader newClassLoader = ClassloaderUtil.initClassloader(classpathElements);
|
||||
UrlClassLoader newClassLoader = ClassloaderUtil.initClassloader(classpathElements, args.length == 0);
|
||||
WindowsCommandLineProcessor.ourMirrorClass = Class.forName(WindowsCommandLineProcessor.class.getName(), true, newClassLoader);
|
||||
|
||||
Class<?> klass = Class.forName(PLUGIN_MANAGER, true, newClassLoader);
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ClassloaderUtil extends ClassUtilCore {
|
||||
return Logger.getInstance("ClassloaderUtil");
|
||||
}
|
||||
|
||||
public static UrlClassLoader initClassloader(final List<URL> classpathElements) throws Exception {
|
||||
public static UrlClassLoader initClassloader(final List<URL> classpathElements, boolean updatePlugins) throws Exception {
|
||||
PathManager.loadProperties();
|
||||
|
||||
addParentClasspath(classpathElements);
|
||||
@@ -60,7 +60,7 @@ public class ClassloaderUtil extends ClassUtilCore {
|
||||
UrlClassLoader newClassLoader = new UrlClassLoader(classpathElements, null, true, true);
|
||||
|
||||
// prepare plugins
|
||||
if (!isLoadingOfExternalPluginsDisabled()) {
|
||||
if (updatePlugins && !isLoadingOfExternalPluginsDisabled()) {
|
||||
try {
|
||||
StartupActionScriptManager.executeActionScript();
|
||||
}
|
||||
|
||||
@@ -59,12 +59,14 @@ public class Main {
|
||||
throw new HeadlessException("Unable to detect graphics environment");
|
||||
}
|
||||
|
||||
try {
|
||||
installPatch();
|
||||
}
|
||||
catch (Throwable t) {
|
||||
showMessage("Update Failed", t);
|
||||
System.exit(UPDATE_FAILED);
|
||||
if (args.length == 0) {
|
||||
try {
|
||||
installPatch();
|
||||
}
|
||||
catch (Throwable t) {
|
||||
showMessage("Update Failed", t);
|
||||
System.exit(UPDATE_FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
*/
|
||||
package com.intellij.concurrency;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@@ -28,11 +30,11 @@ public interface Job<T> {
|
||||
|
||||
String getTitle();
|
||||
|
||||
void addTask(Callable<T> task);
|
||||
void addTask(@NotNull Callable<T> task);
|
||||
|
||||
void addTask(Runnable task, T result);
|
||||
void addTask(@NotNull Runnable task, T result);
|
||||
|
||||
void addTask(Runnable task);
|
||||
void addTask(@NotNull Runnable task);
|
||||
|
||||
List<T> scheduleAndWaitForResults() throws Throwable;
|
||||
|
||||
@@ -43,4 +45,53 @@ public interface Job<T> {
|
||||
void schedule();
|
||||
|
||||
boolean isDone();
|
||||
|
||||
|
||||
@NotNull
|
||||
Job NULL_JOB = new Job() {
|
||||
@Override
|
||||
public boolean isDone() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTask(@NotNull Callable task) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTask(@NotNull Runnable task, Object result) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTask(@NotNull Runnable task) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List scheduleAndWaitForResults() throws Throwable {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCanceled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void schedule() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -50,14 +50,23 @@ public abstract class JobLauncher {
|
||||
boolean failFastOnAcquireReadAction,
|
||||
@NotNull Processor<T> thingProcessor) throws ProcessCanceledException;
|
||||
|
||||
public abstract <T> boolean invokeConcurrentlyUnderProgress(@NotNull List<? extends T> things,
|
||||
ProgressIndicator progress,
|
||||
boolean runInReadAction,
|
||||
boolean failFastOnAcquireReadAction,
|
||||
@NotNull Processor<T> thingProcessor);
|
||||
|
||||
@NotNull
|
||||
public abstract <T> AsyncFuture<Boolean> invokeConcurrentlyUnderProgressAsync(@NotNull List<? extends T> things,
|
||||
ProgressIndicator progress,
|
||||
boolean failFastOnAcquireReadAction,
|
||||
@NotNull Processor<T> thingProcessor);
|
||||
|
||||
|
||||
@NotNull
|
||||
public abstract Job<Void> submitToJobThread(int priority, @NotNull final Runnable action, @Nullable Consumer<Future> onDoneCallback);
|
||||
|
||||
@NotNull
|
||||
public Job<Void> submitToJobThread(int priority, @NotNull final Runnable action) {
|
||||
return submitToJobThread(priority, action, null);
|
||||
}
|
||||
|
||||
@@ -221,4 +221,11 @@ public abstract class Language extends UserDataHolderBase {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Fake language identifier without registering */
|
||||
protected Language(String id, @SuppressWarnings("UnusedParameters") boolean register) {
|
||||
myID = id;
|
||||
myBaseLanguage = null;
|
||||
myMimeTypes = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,16 @@
|
||||
*/
|
||||
package com.intellij.openapi.progress;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface NonCancelableSection {
|
||||
void done();
|
||||
|
||||
@NotNull
|
||||
NonCancelableSection EMPTY = new NonCancelableSection() {
|
||||
@Override
|
||||
public void done() {
|
||||
// do nothing
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@ import org.jetbrains.annotations.Nullable;
|
||||
public abstract class ProgressIndicatorProvider {
|
||||
@Nullable
|
||||
public static ProgressIndicatorProvider ourInstance;
|
||||
|
||||
|
||||
@Nullable
|
||||
public static ProgressIndicatorProvider getInstance() {
|
||||
return ourInstance;
|
||||
}
|
||||
|
||||
|
||||
public abstract ProgressIndicator getProgressIndicator();
|
||||
|
||||
protected abstract void doCheckCanceled() throws ProcessCanceledException;
|
||||
@@ -43,12 +43,7 @@ public abstract class ProgressIndicatorProvider {
|
||||
|
||||
@NotNull
|
||||
public static NonCancelableSection startNonCancelableSectionIfSupported() {
|
||||
return ourInstance != null ? ourInstance.startNonCancelableSection() : new NonCancelableSection() {
|
||||
@Override
|
||||
public void done() {
|
||||
// do nothing
|
||||
}
|
||||
};
|
||||
return ourInstance != null ? ourInstance.startNonCancelableSection() : NonCancelableSection.EMPTY;
|
||||
}
|
||||
|
||||
public static volatile boolean ourNeedToCheckCancel = false;
|
||||
|
||||
@@ -40,6 +40,7 @@ public abstract class ProgressManager {
|
||||
ProgressManager.ourInstance.doCheckCanceled();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public NonCancelableSection startNonCancelableSection() {
|
||||
return ProgressManager.ourInstance.startNonCancelableSection();
|
||||
@@ -209,13 +210,6 @@ public abstract class ProgressManager {
|
||||
if (set) {
|
||||
myThreadIndicator.set(oldIndicator);
|
||||
}
|
||||
|
||||
if (progress != null) {
|
||||
synchronized (progress) {
|
||||
progress.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -152,6 +152,16 @@ public class CoreApplicationEnvironment {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> boolean invokeConcurrentlyUnderProgress(@NotNull List<? extends T> things,
|
||||
ProgressIndicator progress,
|
||||
boolean runInReadAction,
|
||||
boolean failFastOnAcquireReadAction,
|
||||
@NotNull Processor<T> thingProcessor) {
|
||||
return invokeConcurrentlyUnderProgress(things, progress, failFastOnAcquireReadAction, thingProcessor);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T> AsyncFuture<Boolean> invokeConcurrentlyUnderProgressAsync(@NotNull List<? extends T> things,
|
||||
ProgressIndicator progress,
|
||||
@@ -161,12 +171,14 @@ public class CoreApplicationEnvironment {
|
||||
try {
|
||||
final boolean result = invokeConcurrentlyUnderProgress(things, progress, failFastOnAcquireReadAction, thingProcessor);
|
||||
asyncFutureResult.set(result);
|
||||
} catch (Throwable t) {
|
||||
}
|
||||
catch (Throwable t) {
|
||||
asyncFutureResult.setException(t);
|
||||
}
|
||||
return asyncFutureResult;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Job<Void> submitToJobThread(int priority, @NotNull Runnable action, Consumer<Future> onDoneCallback) {
|
||||
action.run();
|
||||
@@ -197,7 +209,7 @@ public class CoreApplicationEnvironment {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
return null;
|
||||
return Job.NULL_JOB;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -215,11 +227,7 @@ public class CoreApplicationEnvironment {
|
||||
|
||||
@Override
|
||||
public NonCancelableSection startNonCancelableSection() {
|
||||
return new NonCancelableSection() {
|
||||
@Override
|
||||
public void done() {
|
||||
}
|
||||
};
|
||||
return NonCancelableSection.EMPTY;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+25
-8
@@ -28,7 +28,7 @@ import com.intellij.util.containers.Stack;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AbstractProgressIndicatorBase extends UserDataHolderBase implements ProgressIndicator {
|
||||
public class AbstractProgressIndicatorBase extends UserDataHolderBase implements ProgressIndicatorStacked {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.progress.util.ProgressIndicatorBase");
|
||||
|
||||
private volatile String myText;
|
||||
@@ -41,10 +41,10 @@ public class AbstractProgressIndicatorBase extends UserDataHolderBase implements
|
||||
|
||||
private volatile boolean myIndeterminate;
|
||||
|
||||
protected Stack<String> myTextStack;
|
||||
protected DoubleArrayList myFractionStack;
|
||||
protected Stack<String> myText2Stack;
|
||||
protected volatile int myNonCancelableCount;
|
||||
private Stack<String> myTextStack;
|
||||
private DoubleArrayList myFractionStack;
|
||||
private Stack<String> myText2Stack;
|
||||
private volatile int myNonCancelableCount;
|
||||
|
||||
protected ProgressIndicator myModalityProgress;
|
||||
private volatile ModalityState myModalityState = ModalityState.NON_MODAL;
|
||||
@@ -214,6 +214,7 @@ public class AbstractProgressIndicatorBase extends UserDataHolderBase implements
|
||||
return isModal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void initStateFrom(@NotNull final ProgressIndicator indicator) {
|
||||
myRunning = indicator.isRunning();
|
||||
myCanceled = indicator.isCanceled();
|
||||
@@ -224,26 +225,42 @@ public class AbstractProgressIndicatorBase extends UserDataHolderBase implements
|
||||
myText2 = indicator.getText2();
|
||||
|
||||
myFraction = indicator.getFraction();
|
||||
|
||||
if (indicator instanceof ProgressIndicatorStacked) {
|
||||
ProgressIndicatorStacked stacked = (ProgressIndicatorStacked)indicator;
|
||||
|
||||
myNonCancelableCount = stacked.getNonCancelableCount();
|
||||
|
||||
myTextStack = new Stack<String>(stacked.getTextStack());
|
||||
|
||||
myText2Stack = new Stack<String>(stacked.getText2Stack());
|
||||
|
||||
myFractionStack = new DoubleArrayList(stacked.getFractionStack());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Stack<String> getTextStack() {
|
||||
public synchronized Stack<String> getTextStack() {
|
||||
if (myTextStack == null) myTextStack = new Stack<String>(2);
|
||||
return myTextStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public DoubleArrayList getFractionStack() {
|
||||
public synchronized DoubleArrayList getFractionStack() {
|
||||
if (myFractionStack == null) myFractionStack = new DoubleArrayList(2);
|
||||
return myFractionStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Stack<String> getText2Stack() {
|
||||
public synchronized Stack<String> getText2Stack() {
|
||||
if (myText2Stack == null) myText2Stack = new Stack<String>(2);
|
||||
return myText2Stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNonCancelableCount() {
|
||||
return myNonCancelableCount;
|
||||
}
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.progress.util;
|
||||
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.util.containers.DoubleArrayList;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface ProgressIndicatorStacked extends ProgressIndicator {
|
||||
void initStateFrom(@NotNull ProgressIndicator indicator);
|
||||
|
||||
@NotNull
|
||||
Stack<String> getTextStack();
|
||||
|
||||
@NotNull
|
||||
DoubleArrayList getFractionStack();
|
||||
|
||||
@NotNull
|
||||
Stack<String> getText2Stack();
|
||||
|
||||
int getNonCancelableCount();
|
||||
}
|
||||
@@ -33,6 +33,7 @@ public class ProgressWrapper extends AbstractProgressIndicatorBase {
|
||||
myOriginal = original;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCanceled() {
|
||||
return myOriginal.isCanceled();
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -61,7 +62,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
protected final Project myProject;
|
||||
protected final PsiManager myPsiManager;
|
||||
protected final DocumentCommitProcessor myDocumentCommitProcessor;
|
||||
protected final Set<Document> myUncommittedDocuments = Collections.synchronizedSet(new HashSet<Document>());
|
||||
protected final Set<Document> myUncommittedDocuments = Collections.synchronizedSet(new THashSet<Document>());
|
||||
|
||||
protected volatile boolean myIsCommitInProgress;
|
||||
protected final PsiToDocumentSynchronizer mySynchronizer;
|
||||
@@ -361,7 +362,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
finally {
|
||||
myIsCommitInProgress = false;
|
||||
}
|
||||
assert !myUncommittedDocuments.contains(document) : "Document :" + document;
|
||||
assert !isInUncommittedSet(document) : "Document :" + document;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -540,8 +541,9 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
return myUncommittedDocuments.toArray(new Document[myUncommittedDocuments.size()]);
|
||||
}
|
||||
|
||||
public Collection<Document> getUncommittedDocumentsUnsafe() {
|
||||
return myUncommittedDocuments;
|
||||
boolean isInUncommittedSet(@NotNull Document document) {
|
||||
if (document instanceof DocumentWindow) return isInUncommittedSet(((DocumentWindow)document).getDelegate());
|
||||
return myUncommittedDocuments.contains(document);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -551,8 +553,9 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
|
||||
@Override
|
||||
public boolean isCommitted(@NotNull Document document) {
|
||||
if (document instanceof DocumentWindow) return isCommitted(((DocumentWindow)document).getDelegate());
|
||||
if (getSynchronizer().isInSynchronization(document)) return true;
|
||||
return !((DocumentEx)document).isInEventsHandling() && !myUncommittedDocuments.contains(document);
|
||||
return !((DocumentEx)document).isInEventsHandling() && !isInUncommittedSet(document);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -603,7 +606,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
boolean commitNecessary = true;
|
||||
for (PsiFile file : files) {
|
||||
mySmartPointerManager.unfastenBelts(file, event.getOffset());
|
||||
|
||||
|
||||
final TextBlock textBlock = TextBlock.get(file);
|
||||
if (textBlock.isLocked()) {
|
||||
commitNecessary = false;
|
||||
@@ -634,10 +637,12 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
}
|
||||
|
||||
if (commitNecessary) {
|
||||
assert !(document instanceof DocumentWindow);
|
||||
myUncommittedDocuments.add(document);
|
||||
if (forceCommit) {
|
||||
commitDocument(document);
|
||||
} else if (!((DocumentEx)document).isInBulkUpdate()) {
|
||||
}
|
||||
else if (!((DocumentEx)document).isInBulkUpdate()) {
|
||||
myDocumentCommitProcessor.commitAsynchronously(myProject, document, event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class PsiToDocumentSynchronizer extends PsiTreeChangeAdapter {
|
||||
return pair != null ? pair.getFirst() : null;
|
||||
}
|
||||
|
||||
public boolean isInSynchronization(final Document document) {
|
||||
public boolean isInSynchronization(@NotNull Document document) {
|
||||
return mySyncDocument == document;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class PsiToDocumentSynchronizer extends PsiTreeChangeAdapter {
|
||||
}
|
||||
|
||||
private interface DocSyncAction {
|
||||
void syncDocument(Document document, PsiTreeChangeEventImpl event);
|
||||
void syncDocument(@NotNull Document document, @NotNull PsiTreeChangeEventImpl event);
|
||||
}
|
||||
|
||||
private void doSync(@NotNull final PsiTreeChangeEvent event, boolean force, @NotNull final DocSyncAction syncAction) {
|
||||
@@ -107,7 +107,7 @@ public class PsiToDocumentSynchronizer extends PsiTreeChangeAdapter {
|
||||
if (!(event.getChild() instanceof ForeignLeafPsiElement)) {
|
||||
doSync(event, false, new DocSyncAction() {
|
||||
@Override
|
||||
public void syncDocument(Document document, PsiTreeChangeEventImpl event) {
|
||||
public void syncDocument(@NotNull Document document, @NotNull PsiTreeChangeEventImpl event) {
|
||||
insertString(document, event.getOffset(), event.getChild().getText());
|
||||
}
|
||||
});
|
||||
@@ -119,7 +119,7 @@ public class PsiToDocumentSynchronizer extends PsiTreeChangeAdapter {
|
||||
if (!(event.getChild() instanceof ForeignLeafPsiElement)) {
|
||||
doSync(event, false, new DocSyncAction() {
|
||||
@Override
|
||||
public void syncDocument(Document document, PsiTreeChangeEventImpl event) {
|
||||
public void syncDocument(@NotNull Document document, @NotNull PsiTreeChangeEventImpl event) {
|
||||
deleteString(document, event.getOffset(), event.getOffset() + event.getOldLength());
|
||||
}
|
||||
});
|
||||
@@ -130,7 +130,7 @@ public class PsiToDocumentSynchronizer extends PsiTreeChangeAdapter {
|
||||
public void childReplaced(@NotNull final PsiTreeChangeEvent event) {
|
||||
doSync(event, false, new DocSyncAction() {
|
||||
@Override
|
||||
public void syncDocument(Document document, PsiTreeChangeEventImpl event) {
|
||||
public void syncDocument(@NotNull Document document, @NotNull PsiTreeChangeEventImpl event) {
|
||||
int oldLength = event.getOldChild() instanceof ForeignLeafPsiElement ? 0 : event.getOldLength();
|
||||
String newText = event.getNewChild() instanceof ForeignLeafPsiElement ? "" : event.getNewChild().getText();
|
||||
replaceString(document, event.getOffset(), event.getOffset() + oldLength, newText);
|
||||
@@ -142,7 +142,7 @@ public class PsiToDocumentSynchronizer extends PsiTreeChangeAdapter {
|
||||
public void childrenChanged(@NotNull final PsiTreeChangeEvent event) {
|
||||
doSync(event, false, new DocSyncAction() {
|
||||
@Override
|
||||
public void syncDocument(Document document, PsiTreeChangeEventImpl event) {
|
||||
public void syncDocument(@NotNull Document document, @NotNull PsiTreeChangeEventImpl event) {
|
||||
replaceString(document, event.getOffset(), event.getOffset() + event.getOldLength(), event.getParent().getText());
|
||||
}
|
||||
});
|
||||
@@ -209,7 +209,7 @@ public class PsiToDocumentSynchronizer extends PsiTreeChangeAdapter {
|
||||
fakeEvent.setFile(changeScope.getContainingFile());
|
||||
doSync(fakeEvent, true, new DocSyncAction() {
|
||||
@Override
|
||||
public void syncDocument(Document document, PsiTreeChangeEventImpl event) {
|
||||
public void syncDocument(@NotNull Document document, @NotNull PsiTreeChangeEventImpl event) {
|
||||
doCommitTransaction(document, documentChangeTransaction);
|
||||
}
|
||||
});
|
||||
@@ -220,7 +220,7 @@ public class PsiToDocumentSynchronizer extends PsiTreeChangeAdapter {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@TestOnly
|
||||
public void doCommitTransaction(@NotNull Document document){
|
||||
doCommitTransaction(document, getTransaction(document));
|
||||
|
||||
+14
-3
@@ -405,11 +405,22 @@ public class ExternalSystemApiUtil {
|
||||
@NotNull
|
||||
public static String getProjectRepresentationName(@NotNull String targetProjectPath, @Nullable String rootProjectPath) {
|
||||
if (rootProjectPath == null) {
|
||||
return new File(targetProjectPath).getParentFile().getName();
|
||||
File rootProjectDir = new File(targetProjectPath);
|
||||
if (rootProjectDir.isFile()) {
|
||||
rootProjectDir = rootProjectDir.getParentFile();
|
||||
}
|
||||
return rootProjectDir.getName();
|
||||
}
|
||||
File rootProjectDir = new File(rootProjectPath);
|
||||
if (rootProjectDir.isFile()) {
|
||||
rootProjectDir = rootProjectDir.getParentFile();
|
||||
}
|
||||
File targetProjectDir = new File(targetProjectPath);
|
||||
if (targetProjectDir.isFile()) {
|
||||
targetProjectDir = targetProjectDir.getParentFile();
|
||||
}
|
||||
File rootProjectDir = new File(rootProjectPath).getParentFile();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
for (File f = new File(targetProjectPath).getParentFile(); f != null && !FileUtil.filesEqual(f, rootProjectDir); f = f.getParentFile()) {
|
||||
for (File f = targetProjectDir; f != null && !FileUtil.filesEqual(f, rootProjectDir); f = f.getParentFile()) {
|
||||
buffer.insert(0, f.getName()).insert(0, ":");
|
||||
}
|
||||
buffer.insert(0, rootProjectDir.getName());
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ public class ExternalSystemTaskSettingsControl implements ExternalSystemSettings
|
||||
|
||||
String path = myOriginalSettings.getExternalProjectPath();
|
||||
if (StringUtil.isEmpty(path)) {
|
||||
path = ExternalSystemApiUtil.getLastUsedExternalProjectPath(myExternalSystemId);
|
||||
path = "";
|
||||
}
|
||||
myProjectPathField.setText(path);
|
||||
myTasksTextField.setText(StringUtil.join(myOriginalSettings.getTaskNames(), " "));
|
||||
|
||||
+3
@@ -241,6 +241,9 @@ public class ExternalProjectPathField extends ComponentWithBrowseButton<External
|
||||
foldingModel.runBatchFoldingOperation(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (FoldRegion region : foldingModel.getAllFoldRegions()) {
|
||||
foldingModel.removeFoldRegion(region);
|
||||
}
|
||||
FoldRegion region = foldingModel.addFoldRegion(0, editor.getDocument().getTextLength(), placeholder);
|
||||
if (region != null) {
|
||||
region.setExpanded(false);
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 250 B |
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.lang;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class LanguageLiteralEscapers extends LanguageExtension<LiteralEscaper> {
|
||||
public static final LanguageLiteralEscapers INSTANCE = new LanguageLiteralEscapers();
|
||||
|
||||
private LanguageLiteralEscapers() {
|
||||
super("com.intellij.lang.literalEscaper", new LiteralEscaper() {
|
||||
@Override
|
||||
public String getEscapedText(final PsiElement context, final String originalText) {
|
||||
return originalText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeText(String originalText) {
|
||||
return originalText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String unescapeText(String originalText) {
|
||||
return originalText;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.lang;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public interface LiteralEscaper {
|
||||
String getEscapedText(PsiElement context, String originalText);
|
||||
String escapeText(String originalText);
|
||||
String unescapeText(String originalText);
|
||||
}
|
||||
+20
-16
@@ -13,20 +13,15 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.intellij.plugins.intelliLang.references;
|
||||
package com.intellij.psi.injection;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import org.intellij.plugins.intelliLang.inject.InjectedLanguage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
@@ -41,6 +36,11 @@ public abstract class Injectable implements Comparable<Injectable> {
|
||||
@NotNull
|
||||
public abstract String getDisplayName();
|
||||
|
||||
@Nullable
|
||||
public String getAdditionalDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Icon getIcon() {
|
||||
return EmptyIcon.ICON_16;
|
||||
@@ -57,15 +57,13 @@ public abstract class Injectable implements Comparable<Injectable> {
|
||||
@Nullable
|
||||
public abstract Language getLanguage();
|
||||
|
||||
public static List<Injectable> getAllInjectables() {
|
||||
Language[] languages = InjectedLanguage.getAvailableLanguages();
|
||||
List<Injectable> list = new ArrayList<Injectable>();
|
||||
for (Language language : languages) {
|
||||
list.add(fromLanguage(language));
|
||||
}
|
||||
list.addAll(Arrays.asList(ReferenceInjector.EXTENSION_POINT_NAME.getExtensions()));
|
||||
Collections.sort(list);
|
||||
return list;
|
||||
public Language toLanguage() {
|
||||
return getLanguage() == null ? new Language(getId(), false) {
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return Injectable.this.getDisplayName();
|
||||
}
|
||||
} : getLanguage();
|
||||
}
|
||||
|
||||
public static Injectable fromLanguage(final Language language) {
|
||||
@@ -79,8 +77,14 @@ public abstract class Injectable implements Comparable<Injectable> {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return language.getDisplayName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getAdditionalDescription() {
|
||||
final FileType ft = language.getAssociatedFileType();
|
||||
return language.getDisplayName() + (ft != null ? " (" + ft.getDescription() + ")" : "");
|
||||
return ft != null ? " (" + ft.getDescription() + ")" : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
+7
-2
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.intellij.plugins.intelliLang.references;
|
||||
package com.intellij.psi.injection;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
@@ -26,18 +26,23 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This will work only in presence of IntelliLang plugin.
|
||||
*
|
||||
* @author Dmitry Avdeev
|
||||
* Date: 01.08.13
|
||||
*/
|
||||
public abstract class ReferenceInjector extends Injectable {
|
||||
|
||||
final static ExtensionPointName<ReferenceInjector> EXTENSION_POINT_NAME = ExtensionPointName.create("org.intellij.intelliLang.referenceInjector");
|
||||
public final static ExtensionPointName<ReferenceInjector> EXTENSION_POINT_NAME = ExtensionPointName.create("com.intellij.referenceInjector");
|
||||
|
||||
@Override
|
||||
public final Language getLanguage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated references should be soft ({@link com.intellij.psi.PsiReference#isSoft()})
|
||||
*/
|
||||
@NotNull
|
||||
public abstract PsiReference[] getReferences(@NotNull PsiElement element, @NotNull final ProcessingContext context, @NotNull TextRange range);
|
||||
|
||||
@@ -15,11 +15,7 @@
|
||||
*/
|
||||
package com.intellij.codeEditor.printing;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.ide.highlighter.HighlighterFactory;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.Notifications;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
@@ -160,8 +156,7 @@ class PrintManager {
|
||||
printerJob.cancel();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Notifications.Bus.notify(new Notification("Print", CommonBundle.getErrorTitle(), e.getMessage(), NotificationType.ERROR));
|
||||
LOG.warn(e);
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+1
-12
@@ -261,7 +261,6 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
if (callbackWhileWaiting != null) {
|
||||
callbackWhileWaiting.run();
|
||||
}
|
||||
progress.waitFor(50);
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
Throwable savedException = PassExecutorService.getSavedException(progress);
|
||||
if (savedException != null) throw savedException;
|
||||
@@ -270,11 +269,9 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
throw e;
|
||||
}
|
||||
catch (Error e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
@@ -299,16 +296,8 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public void cleanupAfterTest(boolean dispose) {
|
||||
public void cleanupAfterTest() {
|
||||
if (!myProject.isOpen()) return;
|
||||
//stopProcess(false);
|
||||
//if (dispose) {
|
||||
// projectClosed();
|
||||
// Disposer.dispose(myStatusBarUpdater);
|
||||
// myStatusBarUpdater = null;
|
||||
// Disposer.dispose(myDaemonListeners);
|
||||
// myDaemonListeners = null;
|
||||
//}
|
||||
setUpdateByTimerEnabled(false);
|
||||
waitForTermination();
|
||||
}
|
||||
|
||||
-12
@@ -61,18 +61,6 @@ public class DaemonProgressIndicator extends AbstractProgressIndicatorBase {
|
||||
super.start();
|
||||
}
|
||||
|
||||
public boolean waitFor(int millisTimeout) {
|
||||
synchronized (this) {
|
||||
try {
|
||||
// we count on ProgressManagerImpl doing progress.notifyAll() on finish
|
||||
wait(millisTimeout);
|
||||
}
|
||||
catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
return isCanceled();
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public static void setDebug(boolean debug) {
|
||||
DaemonProgressIndicator.debug = debug;
|
||||
|
||||
+16
-15
@@ -34,7 +34,6 @@ import com.intellij.openapi.fileEditor.TextEditor;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.impl.ProgressManagerImpl;
|
||||
import com.intellij.openapi.project.DumbAwareRunnable;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -95,7 +94,7 @@ public abstract class PassExecutorService implements Disposable {
|
||||
mySubmittedPasses.clear();
|
||||
}
|
||||
|
||||
public void submitPasses(Map<FileEditor, HighlightingPass[]> passesMap, DaemonProgressIndicator updateProgress, final int jobPriority) {
|
||||
public void submitPasses(@NotNull Map<FileEditor, HighlightingPass[]> passesMap, @NotNull DaemonProgressIndicator updateProgress, final int jobPriority) {
|
||||
if (isDisposed()) return;
|
||||
int id = 1;
|
||||
|
||||
@@ -190,13 +189,14 @@ public abstract class PassExecutorService implements Disposable {
|
||||
log(updateProgress, null, "---------------------starting------------------------ " + threadsToStartCountdown.get(), freePasses);
|
||||
|
||||
for (ScheduledPass dependentPass : dependentPasses) {
|
||||
mySubmittedPasses.put(dependentPass, JobImpl.NULL_JOB);
|
||||
mySubmittedPasses.put(dependentPass, Job.NULL_JOB);
|
||||
}
|
||||
for (ScheduledPass freePass : freePasses) {
|
||||
submit(freePass);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private ScheduledPass createScheduledPass(@NotNull List<FileEditor> fileEditors,
|
||||
@NotNull TextEditorHighlightingPass pass,
|
||||
@NotNull Map<Pair<Document, Integer>, ScheduledPass> toBeSubmitted,
|
||||
@@ -238,14 +238,14 @@ public abstract class PassExecutorService implements Disposable {
|
||||
return scheduledPass;
|
||||
}
|
||||
|
||||
private ScheduledPass findOrCreatePredecessorPass(final List<FileEditor> fileEditors,
|
||||
final Document document,
|
||||
final Map<Pair<Document, Integer>, ScheduledPass> toBeSubmitted,
|
||||
final List<TextEditorHighlightingPass> textEditorHighlightingPasses,
|
||||
final List<ScheduledPass> freePasses,
|
||||
List<ScheduledPass> dependentPasses,
|
||||
final DaemonProgressIndicator updateProgress,
|
||||
final AtomicInteger myThreadsToStartCountdown,
|
||||
private ScheduledPass findOrCreatePredecessorPass(@NotNull List<FileEditor> fileEditors,
|
||||
Document document,
|
||||
@NotNull Map<Pair<Document, Integer>, ScheduledPass> toBeSubmitted,
|
||||
@NotNull List<TextEditorHighlightingPass> textEditorHighlightingPasses,
|
||||
@NotNull List<ScheduledPass> freePasses,
|
||||
@NotNull List<ScheduledPass> dependentPasses,
|
||||
@NotNull DaemonProgressIndicator updateProgress,
|
||||
@NotNull AtomicInteger myThreadsToStartCountdown,
|
||||
final int jobPriority,
|
||||
final int predecessorId) {
|
||||
Pair<Document, Integer> predKey = Pair.create(document, predecessorId);
|
||||
@@ -258,7 +258,7 @@ public abstract class PassExecutorService implements Disposable {
|
||||
return predecessor;
|
||||
}
|
||||
|
||||
private static TextEditorHighlightingPass findPassById(final int id, final List<TextEditorHighlightingPass> textEditorHighlightingPasses) {
|
||||
private static TextEditorHighlightingPass findPassById(final int id, @NotNull List<TextEditorHighlightingPass> textEditorHighlightingPasses) {
|
||||
TextEditorHighlightingPass textEditorPass = null;
|
||||
for (TextEditorHighlightingPass found : textEditorHighlightingPasses) {
|
||||
if (found.getId() == id) {
|
||||
@@ -269,7 +269,7 @@ public abstract class PassExecutorService implements Disposable {
|
||||
return textEditorPass;
|
||||
}
|
||||
|
||||
private void submit(final ScheduledPass pass) {
|
||||
private void submit(@NotNull ScheduledPass pass) {
|
||||
if (!pass.myUpdateProgress.isCanceled()) {
|
||||
Job<Void> job = JobLauncher.getInstance().submitToJobThread(pass.myJobPriority, pass, new Consumer<Future>() {
|
||||
@Override
|
||||
@@ -342,7 +342,7 @@ public abstract class PassExecutorService implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
((ProgressManagerImpl)ProgressManager.getInstance()).executeProcessUnderProgress(new Runnable(){
|
||||
ProgressManager.getInstance().executeProcessUnderProgress(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
boolean success = ApplicationManagerEx.getApplicationEx().tryRunReadAction(new Runnable() {
|
||||
@@ -379,7 +379,7 @@ public abstract class PassExecutorService implements Disposable {
|
||||
myUpdateProgress.cancel();
|
||||
}
|
||||
}
|
||||
},myUpdateProgress);
|
||||
}, myUpdateProgress);
|
||||
|
||||
log(myUpdateProgress, myPass, "Finished. ");
|
||||
|
||||
@@ -468,6 +468,7 @@ public abstract class PassExecutorService implements Disposable {
|
||||
|
||||
protected abstract void afterApplyInformationToEditor(TextEditorHighlightingPass pass, FileEditor fileEditor, ProgressIndicator updateProgress);
|
||||
|
||||
@NotNull
|
||||
public List<TextEditorHighlightingPass> getAllSubmittedPasses() {
|
||||
List<TextEditorHighlightingPass> result = new ArrayList<TextEditorHighlightingPass>(mySubmittedPasses.size());
|
||||
for (ScheduledPass scheduledPass : mySubmittedPasses.keySet()) {
|
||||
|
||||
@@ -341,7 +341,7 @@ class ParameterInfoComponent extends JPanel {
|
||||
myLabel.setForeground(FOREGROUND_COLOR);
|
||||
|
||||
if (flagsMap.isEmpty()) {
|
||||
myLabel.setText(XmlStringUtil.wrapInHtml(text));
|
||||
myLabel.setText(XmlStringUtil.wrapInHtml(XmlStringUtil.escapeString(text)));
|
||||
}
|
||||
else {
|
||||
String labelText = buildLabelText(text, flagsMap);
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.ide.IdeEventQueue;
|
||||
import com.intellij.ide.SearchTopHitProvider;
|
||||
import com.intellij.ide.ui.LafManager;
|
||||
import com.intellij.ide.ui.LafManagerListener;
|
||||
import com.intellij.ide.ui.search.BooleanOptionDescription;
|
||||
import com.intellij.ide.ui.search.OptionDescription;
|
||||
import com.intellij.ide.ui.search.SearchableOptionsRegistrarImpl;
|
||||
import com.intellij.ide.util.gotoByName.*;
|
||||
@@ -58,6 +59,7 @@ import com.intellij.psi.codeStyle.NameUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.ui.components.OnOffButton;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
@@ -330,11 +332,19 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
Component cmp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
if (myLocationString != null) {
|
||||
if (myLocationString != null || value instanceof BooleanOptionDescription) {
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setBackground(UIUtil.getListBackground());
|
||||
panel.setBackground(UIUtil.getListBackground(isSelected));
|
||||
panel.add(cmp, BorderLayout.CENTER);
|
||||
panel.add(myLocation.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus), BorderLayout.EAST);
|
||||
final Component rightComponent;
|
||||
if (value instanceof BooleanOptionDescription) {
|
||||
final OnOffButton button = new OnOffButton();
|
||||
button.setSelected(((BooleanOptionDescription)value).isOptionEnabled());
|
||||
rightComponent = button;
|
||||
} else {
|
||||
rightComponent = myLocation.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
panel.add(rightComponent, BorderLayout.EAST);
|
||||
cmp = panel;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,9 @@ public class MarkRootAction extends DumbAwareAction {
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
Module module = e.getData(LangDataKeys.MODULE);
|
||||
VirtualFile[] vFiles = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY);
|
||||
assert vFiles != null;
|
||||
if (module == null || vFiles == null) {
|
||||
return;
|
||||
}
|
||||
final ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
|
||||
for (VirtualFile vFile : vFiles) {
|
||||
ContentEntry entry = findContentEntry(model, vFile);
|
||||
|
||||
@@ -138,10 +138,7 @@ public class ScopeViewPane extends AbstractProjectViewPane {
|
||||
@Override
|
||||
@NotNull
|
||||
public String[] getSubIds() {
|
||||
NamedScope[] scopes = myDependencyValidationManager.getScopes();
|
||||
scopes = ArrayUtil.mergeArrays(scopes, myNamedScopeManager.getScopes());
|
||||
scopes = NonProjectFilesScope.removeFromList(scopes);
|
||||
scopes = ArrayUtil.remove(scopes, CustomScopesProviderEx.getAllScope());
|
||||
NamedScope[] scopes = getShownScopes();
|
||||
String[] ids = new String[scopes.length];
|
||||
for (int i = 0; i < scopes.length; i++) {
|
||||
final NamedScope scope = scopes[i];
|
||||
@@ -150,6 +147,14 @@ public class ScopeViewPane extends AbstractProjectViewPane {
|
||||
return ids;
|
||||
}
|
||||
|
||||
private NamedScope[] getShownScopes() {
|
||||
NamedScope[] scopes = myDependencyValidationManager.getScopes();
|
||||
scopes = ArrayUtil.mergeArrays(scopes, myNamedScopeManager.getScopes());
|
||||
scopes = NonProjectFilesScope.removeFromList(scopes);
|
||||
scopes = ArrayUtil.remove(scopes, CustomScopesProviderEx.getAllScope());
|
||||
return scopes;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getPresentableSubIdName(@NotNull final String subId) {
|
||||
@@ -183,15 +188,13 @@ public class ScopeViewPane extends AbstractProjectViewPane {
|
||||
if (psiFile == null) return;
|
||||
if (!(element instanceof PsiElement)) return;
|
||||
|
||||
List<NamedScope> allScopes = new ArrayList<NamedScope>();
|
||||
ContainerUtil.addAll(allScopes, myDependencyValidationManager.getScopes());
|
||||
ContainerUtil.addAll(allScopes, myNamedScopeManager.getScopes());
|
||||
for (int i = 0; i < allScopes.size(); i++) {
|
||||
final NamedScope scope = allScopes.get(i);
|
||||
NamedScope[] allScopes = getShownScopes();
|
||||
for (int i = 0; i < allScopes.length; i++) {
|
||||
final NamedScope scope = allScopes[i];
|
||||
String name = scope.getName();
|
||||
if (name.equals(getSubId())) {
|
||||
allScopes.set(i, allScopes.get(0));
|
||||
allScopes.set(0, scope);
|
||||
allScopes[i] = allScopes[0];
|
||||
allScopes[0] = scope;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,10 +159,10 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
|
||||
}
|
||||
}
|
||||
if (task != null) {
|
||||
Collection<Document> unc = task.project.isDisposed() ? Collections.<Document>emptyList() :
|
||||
((PsiDocumentManagerImpl)PsiDocumentManager.getInstance(task.project)).getUncommittedDocumentsUnsafe();
|
||||
if (!unc.isEmpty()) {
|
||||
s += "; Uncommitted: " + unc;
|
||||
boolean stillUncommitted = !task.project.isDisposed() &&
|
||||
((PsiDocumentManagerImpl)PsiDocumentManager.getInstance(task.project)).isInUncommittedSet(task.document);
|
||||
if (stillUncommitted) {
|
||||
s += "; Uncommitted: " + task.document;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
|
||||
|
||||
log("Pulled", task, false, indicator);
|
||||
|
||||
if (project.isDisposed() || !((PsiDocumentManagerImpl)PsiDocumentManager.getInstance(project)).getUncommittedDocumentsUnsafe().contains(document)) {
|
||||
if (project.isDisposed() || !((PsiDocumentManagerImpl)PsiDocumentManager.getInstance(project)).isInUncommittedSet(document)) {
|
||||
log("Abandon and proceed to next",task, false);
|
||||
return;
|
||||
}
|
||||
@@ -469,10 +469,9 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
|
||||
if (synchronously) {
|
||||
assert success;
|
||||
}
|
||||
Collection<Document> unc = documentManager.getUncommittedDocumentsUnsafe();
|
||||
log("after call finishCommit",task, synchronously, success);
|
||||
if (synchronously || success) {
|
||||
assert !unc.contains(document) : unc;
|
||||
assert !documentManager.isInUncommittedSet(document);
|
||||
}
|
||||
if (!success) {
|
||||
// add document back to the queue
|
||||
|
||||
@@ -45,6 +45,7 @@ import com.intellij.util.Query;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.TreeSelectionEvent;
|
||||
@@ -300,4 +301,9 @@ public abstract class CallerChooserBase<M extends PsiElement> extends DialogWrap
|
||||
return myTree;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected String getDimensionServiceKey() {
|
||||
return "caller.chooser.dialog";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,7 @@ package com.intellij.ide;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.AsyncResult;
|
||||
import com.intellij.openapi.util.Key;
|
||||
@@ -29,7 +30,8 @@ import java.awt.*;
|
||||
|
||||
public abstract class DataManager {
|
||||
public static DataManager getInstance() {
|
||||
return ApplicationManager.getApplication().getComponent(DataManager.class);
|
||||
Application application = ApplicationManager.getApplication();
|
||||
return application != null ? application.getComponent(DataManager.class) : null;
|
||||
}
|
||||
|
||||
@NonNls public static final String CLIENT_PROPERTY_DATA_PROVIDER = "DataProvider";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,10 +24,7 @@ import java.awt.*;
|
||||
public abstract class DnDManager {
|
||||
public static DnDManager getInstance() {
|
||||
Application application = ApplicationManager.getApplication();
|
||||
if (application == null) {
|
||||
return null;
|
||||
}
|
||||
return (DnDManager)application.getPicoContainer().getComponentInstance(DnDManager.class.getName());
|
||||
return application != null ? (DnDManager)application.getPicoContainer().getComponentInstance(DnDManager.class.getName()) : null;
|
||||
}
|
||||
|
||||
public abstract void registerSource(DnDSource source, JComponent component);
|
||||
@@ -41,6 +38,6 @@ public abstract class DnDManager {
|
||||
public abstract void registerTarget(DnDTarget target, JComponent component);
|
||||
|
||||
public abstract void unregisterTarget(DnDTarget target, JComponent component);
|
||||
|
||||
|
||||
public abstract Component getLastDropHandler();
|
||||
}
|
||||
|
||||
@@ -23,10 +23,25 @@ import com.intellij.util.Consumer;
|
||||
*/
|
||||
public class UISimpleSettingsProvider implements SearchTopHitProvider {
|
||||
private static UISettingsOptionDescription CYCLING_SCROLLING = new UISettingsOptionDescription("CYCLING_SCROLLING", "Cyclic scrolling", "appearance");
|
||||
private static UISettingsOptionDescription MEMORY_INDICATOR = new UISettingsOptionDescription("SHOW_MEMORY_INDICATOR", "Show Memory Indicator", "appearance");
|
||||
|
||||
|
||||
@Override
|
||||
public void consumeTopHits(String pattern, Consumer<Object> collector) {
|
||||
pattern = pattern.trim().toLowerCase();
|
||||
if (pattern.startsWith("cyc") || pattern.startsWith("scr") || patternContains(pattern, "scroll")) {
|
||||
collector.consume(CYCLING_SCROLLING);
|
||||
} else if (patternContains(pattern, "memo")) {
|
||||
collector.consume(MEMORY_INDICATOR);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean patternContains(String pattern, String search) {
|
||||
for (String s : pattern.split(" ")) {
|
||||
if (s.contains(search)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,12 +38,14 @@ import java.awt.event.MouseEvent;
|
||||
*/
|
||||
public interface Editor extends UserDataHolder {
|
||||
Editor[] EMPTY_ARRAY = new Editor[0];
|
||||
|
||||
/**
|
||||
* Returns the document edited or viewed in the editor.
|
||||
*
|
||||
* @return the document instance.
|
||||
*/
|
||||
@NotNull Document getDocument();
|
||||
@NotNull
|
||||
Document getDocument();
|
||||
|
||||
/**
|
||||
* Returns the value indicating whether the editor operates in viewer mode, with
|
||||
@@ -60,7 +62,8 @@ public interface Editor extends UserDataHolder {
|
||||
*
|
||||
* @return the component instance.
|
||||
*/
|
||||
@NotNull JComponent getComponent();
|
||||
@NotNull
|
||||
JComponent getComponent();
|
||||
|
||||
/**
|
||||
* Returns the component for the content area of the editor (the area displaying the document text).
|
||||
@@ -69,7 +72,8 @@ public interface Editor extends UserDataHolder {
|
||||
*
|
||||
* @return the component instance.
|
||||
*/
|
||||
@NotNull JComponent getContentComponent();
|
||||
@NotNull
|
||||
JComponent getContentComponent();
|
||||
|
||||
void setBorder(@Nullable Border border);
|
||||
|
||||
@@ -81,7 +85,8 @@ public interface Editor extends UserDataHolder {
|
||||
*
|
||||
* @return the selection model instance.
|
||||
*/
|
||||
@NotNull SelectionModel getSelectionModel();
|
||||
@NotNull
|
||||
SelectionModel getSelectionModel();
|
||||
|
||||
/**
|
||||
* Returns the markup model for the editor. This model contains editor-specific highlighters
|
||||
@@ -91,7 +96,8 @@ public interface Editor extends UserDataHolder {
|
||||
* @return the markup model instance.
|
||||
* @see com.intellij.openapi.editor.impl.DocumentMarkupModel#forDocument(com.intellij.openapi.editor.Document, com.intellij.openapi.project.Project, boolean)
|
||||
*/
|
||||
@NotNull MarkupModel getMarkupModel();
|
||||
@NotNull
|
||||
MarkupModel getMarkupModel();
|
||||
|
||||
/**
|
||||
* Returns the folding model for the document, which can be used to add, remove, expand
|
||||
@@ -99,7 +105,8 @@ public interface Editor extends UserDataHolder {
|
||||
*
|
||||
* @return the folding model instance.
|
||||
*/
|
||||
@NotNull FoldingModel getFoldingModel();
|
||||
@NotNull
|
||||
FoldingModel getFoldingModel();
|
||||
|
||||
/**
|
||||
* Returns the scrolling model for the document, which can be used to scroll the document
|
||||
@@ -107,7 +114,8 @@ public interface Editor extends UserDataHolder {
|
||||
*
|
||||
* @return the scrolling model instance.
|
||||
*/
|
||||
@NotNull ScrollingModel getScrollingModel();
|
||||
@NotNull
|
||||
ScrollingModel getScrollingModel();
|
||||
|
||||
/**
|
||||
* Returns the caret model for the document, which can be used to move the caret and
|
||||
@@ -115,7 +123,8 @@ public interface Editor extends UserDataHolder {
|
||||
*
|
||||
* @return the caret model instance.
|
||||
*/
|
||||
@NotNull CaretModel getCaretModel();
|
||||
@NotNull
|
||||
CaretModel getCaretModel();
|
||||
|
||||
/**
|
||||
* Returns the soft wrap model for the document, which can be used to get information about soft wraps registered
|
||||
@@ -123,7 +132,8 @@ public interface Editor extends UserDataHolder {
|
||||
*
|
||||
* @return the soft wrap model instance
|
||||
*/
|
||||
@NotNull SoftWrapModel getSoftWrapModel();
|
||||
@NotNull
|
||||
SoftWrapModel getSoftWrapModel();
|
||||
|
||||
/**
|
||||
* Returns the editor settings for this editor instance. Changes to these settings affect
|
||||
@@ -131,7 +141,8 @@ public interface Editor extends UserDataHolder {
|
||||
*
|
||||
* @return the settings instance.
|
||||
*/
|
||||
@NotNull EditorSettings getSettings();
|
||||
@NotNull
|
||||
EditorSettings getSettings();
|
||||
|
||||
/**
|
||||
* Returns the editor color scheme for this editor instance. Changes to the scheme affect
|
||||
@@ -139,7 +150,8 @@ public interface Editor extends UserDataHolder {
|
||||
*
|
||||
* @return the color scheme instance.
|
||||
*/
|
||||
@NotNull EditorColorsScheme getColorsScheme();
|
||||
@NotNull
|
||||
EditorColorsScheme getColorsScheme();
|
||||
|
||||
/**
|
||||
* Returns the height of a single line of text in the current editor font.
|
||||
@@ -154,7 +166,8 @@ public interface Editor extends UserDataHolder {
|
||||
* @param pos the logical position.
|
||||
* @return the coordinates relative to the top left corner of the {@link #getContentComponent() content component}.
|
||||
*/
|
||||
@NotNull Point logicalPositionToXY(@NotNull LogicalPosition pos);
|
||||
@NotNull
|
||||
Point logicalPositionToXY(@NotNull LogicalPosition pos);
|
||||
|
||||
/**
|
||||
* Maps a logical position in the editor to the offset in the document.
|
||||
@@ -171,7 +184,8 @@ public interface Editor extends UserDataHolder {
|
||||
* @param logicalPos the logical position.
|
||||
* @return the corresponding visual position.
|
||||
*/
|
||||
@NotNull VisualPosition logicalToVisualPosition(@NotNull LogicalPosition logicalPos);
|
||||
@NotNull
|
||||
VisualPosition logicalToVisualPosition(@NotNull LogicalPosition logicalPos);
|
||||
|
||||
/**
|
||||
* Maps a visual position in the editor to pixel coordinates.
|
||||
@@ -179,7 +193,8 @@ public interface Editor extends UserDataHolder {
|
||||
* @param visible the visual position.
|
||||
* @return the coordinates relative to the top left corner of the {@link #getContentComponent() content component}.
|
||||
*/
|
||||
@NotNull Point visualPositionToXY(@NotNull VisualPosition visible);
|
||||
@NotNull
|
||||
Point visualPositionToXY(@NotNull VisualPosition visible);
|
||||
|
||||
/**
|
||||
* Maps a visual position in the editor (with folded lines and columns not included in the line and column count) to
|
||||
@@ -188,7 +203,8 @@ public interface Editor extends UserDataHolder {
|
||||
* @param visiblePos the visual position.
|
||||
* @return the corresponding logical position.
|
||||
*/
|
||||
@NotNull LogicalPosition visualToLogicalPosition(@NotNull VisualPosition visiblePos);
|
||||
@NotNull
|
||||
LogicalPosition visualToLogicalPosition(@NotNull VisualPosition visiblePos);
|
||||
|
||||
/**
|
||||
* Maps an offset in the document to a logical position.
|
||||
@@ -196,7 +212,8 @@ public interface Editor extends UserDataHolder {
|
||||
* @param offset the offset in the document.
|
||||
* @return the corresponding logical position.
|
||||
*/
|
||||
@NotNull LogicalPosition offsetToLogicalPosition(int offset);
|
||||
@NotNull
|
||||
LogicalPosition offsetToLogicalPosition(int offset);
|
||||
|
||||
/**
|
||||
* Maps an offset in the document to a visual position.
|
||||
@@ -204,7 +221,8 @@ public interface Editor extends UserDataHolder {
|
||||
* @param offset the offset in the document.
|
||||
* @return the corresponding visual position.
|
||||
*/
|
||||
@NotNull VisualPosition offsetToVisualPosition(int offset);
|
||||
@NotNull
|
||||
VisualPosition offsetToVisualPosition(int offset);
|
||||
|
||||
/**
|
||||
* Maps the pixel coordinates in the editor to a logical position.
|
||||
@@ -212,7 +230,8 @@ public interface Editor extends UserDataHolder {
|
||||
* @param p the coordinates relative to the top left corner of the {@link #getContentComponent() content component}.
|
||||
* @return the corresponding logical position.
|
||||
*/
|
||||
@NotNull LogicalPosition xyToLogicalPosition(@NotNull Point p);
|
||||
@NotNull
|
||||
LogicalPosition xyToLogicalPosition(@NotNull Point p);
|
||||
|
||||
/**
|
||||
* Maps the pixel coordinates in the editor to a visual position.
|
||||
@@ -220,7 +239,8 @@ public interface Editor extends UserDataHolder {
|
||||
* @param p the coordinates relative to the top left corner of the {@link #getContentComponent() content component}.
|
||||
* @return the corresponding visual position.
|
||||
*/
|
||||
@NotNull VisualPosition xyToVisualPosition(@NotNull Point p);
|
||||
@NotNull
|
||||
VisualPosition xyToVisualPosition(@NotNull Point p);
|
||||
|
||||
/**
|
||||
* Adds a listener for receiving notifications about mouse clicks in the editor and
|
||||
@@ -264,7 +284,8 @@ public interface Editor extends UserDataHolder {
|
||||
*
|
||||
* @return the project instance, or null if the editor is not related to any project.
|
||||
*/
|
||||
@Nullable Project getProject();
|
||||
@Nullable
|
||||
Project getProject();
|
||||
|
||||
/**
|
||||
* Returns the insert/overwrite mode for the editor.
|
||||
@@ -293,7 +314,8 @@ public interface Editor extends UserDataHolder {
|
||||
*
|
||||
* @return the gutter instance.
|
||||
*/
|
||||
@NotNull EditorGutter getGutter();
|
||||
@NotNull
|
||||
EditorGutter getGutter();
|
||||
|
||||
/**
|
||||
* Returns the editor area (text, gutter, folding outline and so on) in which the specified
|
||||
@@ -302,17 +324,18 @@ public interface Editor extends UserDataHolder {
|
||||
* @param e the mouse event for which the area is requested.
|
||||
* @return the editor area, or null if the event occurred over an unknown area.
|
||||
*/
|
||||
@Nullable EditorMouseEventArea getMouseEventArea(@NotNull MouseEvent e);
|
||||
@Nullable
|
||||
EditorMouseEventArea getMouseEventArea(@NotNull MouseEvent e);
|
||||
|
||||
/**
|
||||
* Set up a header component for this text editor. Please note this is used for textual find feature so your component will most
|
||||
* probably will be reset once the user presses Ctrl+F.
|
||||
*
|
||||
* @param header a component to setup as header for this text editor or <code>null</code> to remove one.
|
||||
*/
|
||||
void setHeaderComponent(@Nullable JComponent header);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return <code>true</code> if this editor has active header component set up by {@link #setHeaderComponent(javax.swing.JComponent)}
|
||||
*/
|
||||
boolean hasHeaderComponent();
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.ui.components;
|
||||
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.util.ui.GraphicsUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicToggleButtonUI;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class OnOffButton extends JToggleButton {
|
||||
private String myOnText;
|
||||
private String myOffText;
|
||||
public OnOffButton() {
|
||||
setUI(OnOffButtonUI.createUI(this));
|
||||
setOpaque(false);
|
||||
setBorder(null);
|
||||
}
|
||||
|
||||
public String getOnText() {
|
||||
return myOnText == null ? "ON" : myOnText;
|
||||
}
|
||||
|
||||
public void setOnText(String onText) {
|
||||
myOnText = onText;
|
||||
}
|
||||
|
||||
public String getOffText() {
|
||||
return myOffText == null ? "OFF" : myOffText;
|
||||
}
|
||||
|
||||
public void setOffText(String offText) {
|
||||
myOffText = offText;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
}
|
||||
|
||||
public static class OnOffButtonUI extends BasicToggleButtonUI {
|
||||
private final OnOffButton myButton;
|
||||
|
||||
public OnOffButtonUI(OnOffButton checkBox) {
|
||||
myButton = checkBox;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"})
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new OnOffButtonUI((OnOffButton)c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize(JComponent c) {
|
||||
final OnOffButton button = (OnOffButton)c;
|
||||
String text = button.getOffText().length() > button.getOnText().length() ? button.getOffText() : button.getOnText();
|
||||
text = text.toUpperCase();
|
||||
final FontMetrics fm = c.getFontMetrics(c.getFont());
|
||||
int w = fm.stringWidth(text);
|
||||
int h = fm.getHeight();
|
||||
h += 2*4;
|
||||
w += 3 * h / 2 + 4;
|
||||
return new Dimension(w, h);
|
||||
}
|
||||
@Override
|
||||
public void paint(Graphics gr, JComponent c) {
|
||||
final OnOffButton button = (OnOffButton)c;
|
||||
final Dimension size = button.getSize();
|
||||
int w = size.width-4;
|
||||
int h = size.height-4;
|
||||
if (h % 2 == 1) {
|
||||
h--;
|
||||
}
|
||||
Graphics2D g = ((Graphics2D)gr);
|
||||
GraphicsUtil.setupAAPainting(g);
|
||||
g.translate(1,1);
|
||||
if (button.isSelected()) {
|
||||
g.setColor(new Color(13, 41, 62));
|
||||
g.fillRoundRect(0, 0, w, h, h, h);
|
||||
g.setColor(UIUtil.getBorderColor());
|
||||
g.drawRoundRect(0, 0, w, h, h, h);
|
||||
g.setColor(Gray._128);
|
||||
g.fillOval(w - h + 1, 1, h - 1, h - 1);
|
||||
g.setColor(UIUtil.getListForeground(true));
|
||||
g.drawString(button.getOnText(), h/2, h - 4);
|
||||
} else {
|
||||
g.setColor(UIUtil.getPanelBackground());
|
||||
g.fillRoundRect(0, 0, w, h, h, h);
|
||||
g.setColor(UIUtil.getBorderColor());
|
||||
g.drawRoundRect(0, 0, w, h, h, h);
|
||||
g.setColor(UIUtil.getLabelDisabledForeground());
|
||||
g.drawString(button.getOffText(), h + 4 , h - 4);
|
||||
g.setColor(Gray._128);
|
||||
g.fillOval(0, 0, h - 1, h - 1);
|
||||
}
|
||||
g.translate(-1, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize(JComponent c) {
|
||||
return getPreferredSize(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMaximumSize(JComponent c) {
|
||||
return getPreferredSize(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -284,21 +284,16 @@ public class Alarm implements Disposable {
|
||||
myFuture = null;
|
||||
}
|
||||
|
||||
if (myThreadToUse == ThreadToUse.SWING_THREAD && !isEdt()) {
|
||||
try {
|
||||
try {
|
||||
if (myThreadToUse == ThreadToUse.SWING_THREAD && !isEdt()) {
|
||||
SwingUtilities.invokeAndWait(task);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
else {
|
||||
task.run();
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error("Exception in task " + task, e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -684,6 +684,9 @@ public class HintManagerImpl extends HintManager implements Disposable {
|
||||
}
|
||||
|
||||
public void showInformationHint(@NotNull Editor editor, @NotNull JComponent component, boolean showByBalloon) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
return;
|
||||
}
|
||||
LightweightHint hint = new LightweightHint(component);
|
||||
Point p = getHintPosition(hint, editor, ABOVE);
|
||||
showEditorHint(hint, editor, p, HIDE_BY_ANY_KEY | HIDE_BY_TEXT_CHANGE | HIDE_BY_SCROLLING, 0, false);
|
||||
|
||||
@@ -39,21 +39,6 @@ public class JobImpl<T> implements Job<T> {
|
||||
private volatile boolean scheduled;
|
||||
private final boolean myFailFastOnAcquireReadAction;
|
||||
|
||||
public static final Job NULL_JOB = new JobImpl(0,false) {
|
||||
@Override
|
||||
public boolean isDone() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void waitForTermination() throws Throwable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
}
|
||||
};
|
||||
|
||||
JobImpl(int priority, boolean failFastOnAcquireReadAction) {
|
||||
myPriority = priority;
|
||||
myFailFastOnAcquireReadAction = failFastOnAcquireReadAction;
|
||||
@@ -65,17 +50,17 @@ public class JobImpl<T> implements Job<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTask(Callable<T> task) {
|
||||
public void addTask(@NotNull Callable<T> task) {
|
||||
addTask(task, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTask(Runnable task, T result) {
|
||||
public void addTask(@NotNull Runnable task, T result) {
|
||||
addTask(Executors.callable(task, result));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTask(Runnable task) {
|
||||
public void addTask(@NotNull Runnable task) {
|
||||
addTask(Executors.callable(task, (T)null));
|
||||
}
|
||||
|
||||
@@ -105,7 +90,11 @@ public class JobImpl<T> implements Job<T> {
|
||||
checkCanSchedule();
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
boolean callerHasReadAccess = application != null && application.isReadAccessAllowed();
|
||||
scheduleAndWaitForResults(callerHasReadAccess);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void scheduleAndWaitForResults(boolean runInReadAction) throws Throwable {
|
||||
// Don't bother scheduling if we only have one processor or only one task
|
||||
boolean reallySchedule;
|
||||
PrioritizedFutureTask[] tasks = getTasks();
|
||||
@@ -118,10 +107,10 @@ public class JobImpl<T> implements Job<T> {
|
||||
for (PrioritizedFutureTask future : tasks) {
|
||||
future.run();
|
||||
}
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
submitTasks(tasks, callerHasReadAccess, false);
|
||||
submitTasks(tasks, runInReadAction, false);
|
||||
|
||||
// in case of imbalanced tasks one huge task can stuck running and we would fall to waitForTermination instead of doing useful work
|
||||
//// http://gafter.blogspot.com/2006/11/thread-pool-puzzler.html
|
||||
@@ -137,7 +126,6 @@ public class JobImpl<T> implements Job<T> {
|
||||
}
|
||||
|
||||
waitForTermination();
|
||||
return null;
|
||||
}
|
||||
|
||||
public void waitForTermination() throws Throwable {
|
||||
@@ -208,6 +196,7 @@ public class JobImpl<T> implements Job<T> {
|
||||
submitTasks(tasks, false, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PrioritizedFutureTask[] getTasks() {
|
||||
PrioritizedFutureTask[] tasks;
|
||||
synchronized (myFutures) {
|
||||
@@ -244,9 +233,9 @@ public class JobImpl<T> implements Job<T> {
|
||||
}
|
||||
}
|
||||
|
||||
private static void submitTasks(PrioritizedFutureTask[] tasks, boolean callerHasReadAccess, boolean reportExceptions) {
|
||||
private static void submitTasks(@NotNull PrioritizedFutureTask[] tasks, boolean runInReadAction, boolean reportExceptions) {
|
||||
for (final PrioritizedFutureTask future : tasks) {
|
||||
JobSchedulerImpl.submitTask(future, callerHasReadAccess, reportExceptions);
|
||||
JobSchedulerImpl.submitTask(future, runInReadAction, reportExceptions);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.concurrency;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
@@ -32,37 +32,44 @@ import java.util.concurrent.Future;
|
||||
* @author cdr
|
||||
*/
|
||||
public class JobLauncherImpl extends JobLauncher {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.concurrency.JobLauncher");
|
||||
|
||||
private static <T> boolean invokeConcurrentlyForAll(@NotNull final List<? extends T> things,
|
||||
boolean runInReadAction,
|
||||
boolean failFastOnAcquireReadAction,
|
||||
@NotNull final Processor<T> thingProcessor) throws ProcessCanceledException {
|
||||
final Job<String> job = new JobImpl<String>(Job.DEFAULT_PRIORITY, failFastOnAcquireReadAction);
|
||||
@NotNull final Processor<T> thingProcessor,
|
||||
final ProgressWrapper wrapper) throws ProcessCanceledException {
|
||||
final JobImpl<String> job = new JobImpl<String>(Job.DEFAULT_PRIORITY, failFastOnAcquireReadAction);
|
||||
|
||||
final int chunkSize = Math.max(1, things.size() / JobSchedulerImpl.CORES_COUNT / 20);
|
||||
final int chunkSize = Math.max(1, things.size() / Math.max(1, JobSchedulerImpl.CORES_COUNT / 2));
|
||||
for (int i = 0; i < things.size(); i += chunkSize) {
|
||||
// this job chunk is i..i+chunkSize-1
|
||||
final int finalI = i;
|
||||
job.addTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
for (int k = finalI; k < finalI + chunkSize && k < things.size(); k++) {
|
||||
T thing = things.get(k);
|
||||
if (!thingProcessor.process(thing)) {
|
||||
job.cancel();
|
||||
break;
|
||||
ProgressManager.getInstance().executeProcessUnderProgress(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
for (int k = finalI; k < finalI + chunkSize && k < things.size(); k++) {
|
||||
T thing = things.get(k);
|
||||
if (!thingProcessor.process(thing)) {
|
||||
job.cancel();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
job.cancel();
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
job.cancel();
|
||||
throw e;
|
||||
}
|
||||
}, wrapper);
|
||||
}
|
||||
});
|
||||
}
|
||||
try {
|
||||
job.scheduleAndWaitForResults();
|
||||
job.scheduleAndWaitForResults(runInReadAction);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
job.cancel();
|
||||
@@ -80,6 +87,16 @@ public class JobLauncherImpl extends JobLauncher {
|
||||
ProgressIndicator progress,
|
||||
boolean failFastOnAcquireReadAction,
|
||||
@NotNull final Processor<T> thingProcessor) throws ProcessCanceledException {
|
||||
return invokeConcurrentlyUnderProgress(things, progress, ApplicationManager.getApplication().isReadAccessAllowed(),
|
||||
failFastOnAcquireReadAction, thingProcessor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> boolean invokeConcurrentlyUnderProgress(@NotNull List<? extends T> things,
|
||||
ProgressIndicator progress,
|
||||
boolean runInReadAction,
|
||||
boolean failFastOnAcquireReadAction,
|
||||
@NotNull Processor<T> thingProcessor) {
|
||||
if (things.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
@@ -90,20 +107,11 @@ public class JobLauncherImpl extends JobLauncher {
|
||||
|
||||
// can be already wrapped
|
||||
final ProgressWrapper wrapper = progress instanceof ProgressWrapper ? (ProgressWrapper)progress : ProgressWrapper.wrap(progress);
|
||||
return invokeConcurrentlyForAll(things, failFastOnAcquireReadAction, new Processor<T>() {
|
||||
public boolean process(final T t) {
|
||||
final boolean[] result = new boolean[1];
|
||||
ProgressManager.getInstance().executeProcessUnderProgress(new Runnable() {
|
||||
public void run() {
|
||||
result[0] = thingProcessor.process(t);
|
||||
}
|
||||
}, wrapper);
|
||||
return result[0];
|
||||
}
|
||||
});
|
||||
return invokeConcurrentlyForAll(things, runInReadAction, failFastOnAcquireReadAction, thingProcessor, wrapper);
|
||||
}
|
||||
|
||||
// This implementation is not really async
|
||||
@NotNull
|
||||
@Override
|
||||
public <T> AsyncFutureResult<Boolean> invokeConcurrentlyUnderProgressAsync(@NotNull List<? extends T> things,
|
||||
ProgressIndicator progress,
|
||||
@@ -120,10 +128,12 @@ public class JobLauncherImpl extends JobLauncher {
|
||||
return asyncFutureResult;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Job<Void> submitToJobThread(int priority, @NotNull final Runnable action, Consumer<Future> onDoneCallback) {
|
||||
final JobImpl<Void> job = new JobImpl<Void>(priority, false);
|
||||
Callable<Void> callable = new Callable<Void>() {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
try {
|
||||
action.run();
|
||||
|
||||
@@ -21,6 +21,7 @@ package com.intellij.concurrency;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.PriorityBlockingQueue;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
@@ -34,7 +35,9 @@ public class JobSchedulerImpl extends JobScheduler implements Disposable {
|
||||
private static final ThreadFactory WORKERS_FACTORY = new ThreadFactory() {
|
||||
private int threadSeq;
|
||||
|
||||
public synchronized Thread newThread(final Runnable r) {
|
||||
@NotNull
|
||||
@Override
|
||||
public synchronized Thread newThread(@NotNull final Runnable r) {
|
||||
@NonNls String name = "JobScheduler pool " + threadSeq + "/" + CORES_COUNT;
|
||||
final Thread thread = new Thread(r, name);
|
||||
thread.setPriority(Thread.NORM_PRIORITY);
|
||||
@@ -50,6 +53,7 @@ public class JobSchedulerImpl extends JobScheduler implements Disposable {
|
||||
return ourQueue.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
((ThreadPoolExecutor)getScheduler()).getQueue().clear();
|
||||
}
|
||||
@@ -58,8 +62,8 @@ public class JobSchedulerImpl extends JobScheduler implements Disposable {
|
||||
return ourQueue.poll();
|
||||
}
|
||||
|
||||
static void submitTask(PrioritizedFutureTask future, boolean callerHasReadAccess, boolean reportExceptions) {
|
||||
future.beforeRun(callerHasReadAccess, reportExceptions);
|
||||
static void submitTask(@NotNull PrioritizedFutureTask future, boolean runInReadAction, boolean reportExceptions) {
|
||||
future.beforeRun(runInReadAction, reportExceptions);
|
||||
ourExecutor.executeTask(future);
|
||||
}
|
||||
|
||||
@@ -68,12 +72,12 @@ public class JobSchedulerImpl extends JobScheduler implements Disposable {
|
||||
super(CORES_COUNT, Integer.MAX_VALUE, 60 * 10, TimeUnit.SECONDS, ourQueue, WORKERS_FACTORY);
|
||||
}
|
||||
|
||||
private void executeTask(final PrioritizedFutureTask task) {
|
||||
private void executeTask(@NotNull PrioritizedFutureTask task) {
|
||||
super.execute(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Runnable command) {
|
||||
public void execute(@NotNull Runnable command) {
|
||||
throw new IllegalStateException("Use executeTask() to submit PrioritizedFutureTasks only");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ package com.intellij.concurrency;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.application.impl.ApplicationImpl;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CancellationException;
|
||||
@@ -35,7 +36,7 @@ class PrioritizedFutureTask<T> extends FutureTask<T> implements Comparable<Prior
|
||||
private final int myTaskIndex;
|
||||
private final int myPriority;
|
||||
private final boolean myFailFastOnAcquireReadAction;
|
||||
private volatile boolean myParentThreadHasReadAccess;
|
||||
private volatile boolean myRunInReadAction;
|
||||
private volatile boolean myReportExceptions;
|
||||
|
||||
PrioritizedFutureTask(final Callable<T> callable,
|
||||
@@ -52,14 +53,15 @@ class PrioritizedFutureTask<T> extends FutureTask<T> implements Comparable<Prior
|
||||
myFailFastOnAcquireReadAction = failFastOnAcquireReadAction;
|
||||
}
|
||||
|
||||
public void beforeRun(boolean parentThreadHasReadAccess, boolean reportExceptions) {
|
||||
myParentThreadHasReadAccess = parentThreadHasReadAccess;
|
||||
public void beforeRun(boolean runInReadAction, boolean reportExceptions) {
|
||||
myRunInReadAction = runInReadAction;
|
||||
myReportExceptions = reportExceptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (myJob.isCanceled()) {
|
||||
@@ -91,7 +93,7 @@ class PrioritizedFutureTask<T> extends FutureTask<T> implements Comparable<Prior
|
||||
}
|
||||
}
|
||||
};
|
||||
if (myParentThreadHasReadAccess) {
|
||||
if (myRunInReadAction) {
|
||||
// have to start "real" read action so that we cannot start write action until we are finished here
|
||||
if (myFailFastOnAcquireReadAction) {
|
||||
if (!ApplicationManagerEx.getApplicationEx().tryRunReadAction(runnable)) {
|
||||
@@ -114,7 +116,8 @@ class PrioritizedFutureTask<T> extends FutureTask<T> implements Comparable<Prior
|
||||
}
|
||||
}
|
||||
|
||||
public int compareTo(final PrioritizedFutureTask o) {
|
||||
@Override
|
||||
public int compareTo(@NotNull final PrioritizedFutureTask o) {
|
||||
int priorityDelta = myPriority - o.myPriority;
|
||||
if (priorityDelta != 0) return priorityDelta;
|
||||
if (myJobIndex != o.myJobIndex) return myJobIndex < o.myJobIndex ? -1 : 1;
|
||||
|
||||
+5
-1
@@ -532,12 +532,16 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
}
|
||||
myLoaded = true;
|
||||
|
||||
createLocatorFile();
|
||||
}
|
||||
|
||||
private static void createLocatorFile() {
|
||||
File locatorFile = new File(PathManager.getSystemPath() + "/" + ApplicationEx.LOCATOR_FILE_NAME);
|
||||
try {
|
||||
byte[] data = PathManager.getHomePath().getBytes("UTF-8");
|
||||
FileUtil.writeToFile(locatorFile, data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (IOException e) {
|
||||
LOG.warn("can't store a location in '" + locatorFile + "'", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5596,7 +5596,9 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
mySelectionModel.setSelection(caretOffset, caretOffset);
|
||||
}
|
||||
else {
|
||||
if (!e.isPopupTrigger() && eventArea == EditorMouseEventArea.EDITING_AREA) {
|
||||
if (!e.isPopupTrigger()
|
||||
&& (eventArea == EditorMouseEventArea.EDITING_AREA || eventArea == EditorMouseEventArea.LINE_NUMBERS_AREA))
|
||||
{
|
||||
switch (e.getClickCount()) {
|
||||
case 2:
|
||||
selectWordAtCaret(mySettings.isMouseClickSelectionHonorsCamelWords() && mySettings.isCamelWords());
|
||||
|
||||
+20
-42
@@ -40,18 +40,17 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class ProgressManagerImpl extends ProgressManager implements Disposable{
|
||||
@NonNls private static final String PROCESS_CANCELED_EXCEPTION = "idea.ProcessCanceledException";
|
||||
|
||||
private final AtomicInteger myCurrentUnsafeProgressCount = new AtomicInteger(0);
|
||||
private final AtomicInteger myCurrentModalProgressCount = new AtomicInteger(0);
|
||||
|
||||
private static volatile int ourLockedCheckCounter = 0;
|
||||
private static final boolean DISABLED = "disabled".equals(System.getProperty(PROCESS_CANCELED_EXCEPTION));
|
||||
private static final boolean DISABLED = "disabled".equals(System.getProperty("idea.ProcessCanceledException"));
|
||||
private final ScheduledFuture<?> myCheckCancelledFuture;
|
||||
|
||||
public ProgressManagerImpl(Application application) {
|
||||
@@ -63,7 +62,8 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
|
||||
ProgressIndicatorProvider.ourNeedToCheckCancel = true;
|
||||
}
|
||||
}, 0, 10, TimeUnit.MILLISECONDS);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
myCheckCancelledFuture = null;
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonCancelableSection startNonCancelableSection() {
|
||||
public final NonCancelableSection startNonCancelableSection() {
|
||||
NonCancelableIndicator nonCancelor = new NonCancelableIndicator(myThreadIndicator.get());
|
||||
myThreadIndicator.set(nonCancelor);
|
||||
return nonCancelor;
|
||||
@@ -131,13 +131,7 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
|
||||
|
||||
@Override
|
||||
public void executeNonCancelableSection(@NotNull Runnable runnable) {
|
||||
NonCancelableSection nonCancelor = startNonCancelableSection();
|
||||
try {
|
||||
runnable.run();
|
||||
}
|
||||
finally {
|
||||
nonCancelor.done();
|
||||
}
|
||||
executeProcessUnderProgress(runnable, new NonCancelableIndicator(getProgressIndicator()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -174,9 +168,6 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
|
||||
executeProcessUnderProgress(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (process) {
|
||||
process.notifyAll();
|
||||
}
|
||||
try {
|
||||
if (progress != null && !progress.isRunning()) {
|
||||
progress.start();
|
||||
@@ -190,9 +181,6 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
|
||||
if (progress instanceof ProgressIndicatorEx) {
|
||||
((ProgressIndicatorEx)progress).processFinish();
|
||||
}
|
||||
synchronized (process) {
|
||||
process.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -281,7 +269,6 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
|
||||
|
||||
private static boolean runProcessWithProgressSynchronously(final Task task, @Nullable final JComponent parentComponent) {
|
||||
final long start = System.currentTimeMillis();
|
||||
long time = 0;
|
||||
final boolean result = ((ApplicationEx)ApplicationManager.getApplication())
|
||||
.runProcessWithProgressSynchronously(new TaskContainer(task) {
|
||||
@Override
|
||||
@@ -292,7 +279,7 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
|
||||
if (result) {
|
||||
final long end = System.currentTimeMillis();
|
||||
final Task.NotificationInfo notificationInfo = task.notifyFinished();
|
||||
time = end - start;
|
||||
long time = end - start;
|
||||
if (notificationInfo != null && time > 5000) { // show notification only if process took more than 5 secs
|
||||
final JFrame frame = WindowManager.getInstance().getFrame(task.getProject());
|
||||
if (!frame.hasFocus()) {
|
||||
@@ -353,7 +340,7 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
|
||||
});
|
||||
}
|
||||
|
||||
public static void runProcessWithProgressAsynchronously(@NotNull Task.Backgroundable task) {
|
||||
private static void runProcessWithProgressAsynchronously(@NotNull Task.Backgroundable task) {
|
||||
final ProgressIndicator progressIndicator;
|
||||
if (ApplicationManager.getApplication().isHeadlessEnvironment()) {
|
||||
progressIndicator = new EmptyProgressIndicator();
|
||||
@@ -364,13 +351,15 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
|
||||
runProcessWithProgressAsynchronously(task, progressIndicator, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runProcessWithProgressAsynchronously(@NotNull Task.Backgroundable task, @NotNull ProgressIndicator progressIndicator) {
|
||||
runProcessWithProgressAsynchronously(task, progressIndicator, null);
|
||||
}
|
||||
|
||||
public static void runProcessWithProgressAsynchronously(@NotNull final Task.Backgroundable task,
|
||||
@NotNull final ProgressIndicator progressIndicator,
|
||||
@Nullable final Runnable continuation) {
|
||||
@NotNull
|
||||
public static Future<?> runProcessWithProgressAsynchronously(@NotNull final Task.Backgroundable task,
|
||||
@NotNull final ProgressIndicator progressIndicator,
|
||||
@Nullable final Runnable continuation) {
|
||||
if (progressIndicator instanceof Disposable) {
|
||||
Disposer.register(ApplicationManager.getApplication(), (Disposable)progressIndicator);
|
||||
}
|
||||
@@ -417,15 +406,7 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
|
||||
}
|
||||
};
|
||||
|
||||
synchronized (process) {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(action);
|
||||
try {
|
||||
process.wait();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return ApplicationManager.getApplication().executeOnPooledThread(action);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -500,19 +481,16 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
stopCheckCanceled();
|
||||
}
|
||||
|
||||
private void stopCheckCanceled() {
|
||||
if (myCheckCancelledFuture != null) myCheckCancelledFuture.cancel(false);
|
||||
}
|
||||
|
||||
//for debugging
|
||||
@TestOnly
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
private static void stopCheckCanceled() {
|
||||
((ProgressManagerImpl)getInstance()).dispose();
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public static String isCanceledThread(Thread thread) {
|
||||
public static String isCanceledThread(@NotNull Thread thread) {
|
||||
try {
|
||||
Field th = Thread.class.getDeclaredField("threadLocals");
|
||||
th.setAccessible(true);
|
||||
@@ -537,7 +515,7 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
|
||||
final int debugProgressTime = Registry.intValue("ide.debug.minProgressTime");
|
||||
if (debugProgressTime > 0) {
|
||||
try {
|
||||
Thread.currentThread().sleep(debugProgressTime);
|
||||
Thread.sleep(debugProgressTime);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
//ignore
|
||||
|
||||
+5
-11
@@ -17,12 +17,11 @@ package com.intellij.openapi.progress.util;
|
||||
|
||||
import com.intellij.openapi.application.impl.LaterInvocator;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.TaskInfo;
|
||||
import com.intellij.openapi.progress.impl.ProgressManagerImpl;
|
||||
import com.intellij.openapi.wm.ex.ProgressIndicatorEx;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.DoubleArrayList;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import com.intellij.util.containers.WeakList;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -330,16 +329,11 @@ public class ProgressIndicatorBase extends AbstractProgressIndicatorBase impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void initStateFrom(@NotNull final ProgressIndicatorEx indicator) {
|
||||
public synchronized void initStateFrom(@NotNull final ProgressIndicator indicator) {
|
||||
super.initStateFrom(indicator);
|
||||
myModalityEntered = indicator.isModalityEntered();
|
||||
myNonCancelableCount = indicator.getNonCancelableCount();
|
||||
|
||||
myTextStack = new Stack<String>(indicator.getTextStack());
|
||||
|
||||
myText2Stack = new Stack<String>(indicator.getText2Stack());
|
||||
|
||||
myFractionStack = new DoubleArrayList(indicator.getFractionStack());
|
||||
if (indicator instanceof ProgressIndicatorEx) {
|
||||
myModalityEntered = ((ProgressIndicatorEx)indicator).isModalityEntered();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,30 +15,17 @@
|
||||
*/
|
||||
package com.intellij.openapi.wm.ex;
|
||||
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.TaskInfo;
|
||||
import com.intellij.util.containers.DoubleArrayList;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import com.intellij.openapi.progress.util.ProgressIndicatorStacked;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface ProgressIndicatorEx extends ProgressIndicator {
|
||||
|
||||
public interface ProgressIndicatorEx extends ProgressIndicatorStacked {
|
||||
void addStateDelegate(@NotNull ProgressIndicatorEx delegate);
|
||||
|
||||
void initStateFrom(@NotNull ProgressIndicatorEx indicator);
|
||||
|
||||
@NotNull Stack<String> getTextStack();
|
||||
|
||||
@NotNull DoubleArrayList getFractionStack();
|
||||
|
||||
@NotNull Stack<String> getText2Stack();
|
||||
|
||||
int getNonCancelableCount();
|
||||
|
||||
boolean isModalityEntered();
|
||||
|
||||
void finish(@NotNull TaskInfo task);
|
||||
|
||||
|
||||
boolean isFinished(@NotNull TaskInfo task);
|
||||
|
||||
boolean wasStarted();
|
||||
|
||||
@@ -103,6 +103,7 @@
|
||||
<extensionPoint name="multiHostInjector"
|
||||
interface="com.intellij.lang.injection.MultiHostInjector"
|
||||
area="IDEA_PROJECT"/>
|
||||
<extensionPoint name="referenceInjector" interface="com.intellij.psi.injection.ReferenceInjector"/>
|
||||
|
||||
<extensionPoint name="annotator"
|
||||
beanClass="com.intellij.lang.LanguageExtensionPoint">
|
||||
@@ -144,11 +145,6 @@
|
||||
<with attribute="implementationClass" implements="com.intellij.lang.Commenter"/>
|
||||
</extensionPoint>
|
||||
|
||||
<extensionPoint name="lang.literalEscaper"
|
||||
beanClass="com.intellij.lang.LanguageExtensionPoint">
|
||||
<with attribute="implementationClass" implements="com.intellij.lang.LiteralEscaper"/>
|
||||
</extensionPoint>
|
||||
|
||||
<extensionPoint name="lang.braceMatcher"
|
||||
beanClass="com.intellij.lang.LanguageExtensionPoint">
|
||||
<with attribute="implementationClass" implements="com.intellij.lang.PairedBraceMatcher"/>
|
||||
|
||||
@@ -305,5 +305,6 @@
|
||||
groupKey="group.names.portability.issues" enabledByDefault="false" level="WARNING"
|
||||
implementationClass="com.intellij.codeStyle.InconsistentLineSeparatorsInspection"/>
|
||||
<search.topHitProvider implementation="com.intellij.platform.DefaultPlatformTopHitProvider"/>
|
||||
<search.topHitProvider implementation="com.intellij.ide.ui.UISimpleSettingsProvider"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
serviceImplementation="com.intellij.remoteServer.impl.configuration.RemoteServersManagerImpl"/>
|
||||
<applicationService serviceInterface="com.intellij.remoteServer.configuration.deployment.DeploymentSourceUtil"
|
||||
serviceImplementation="com.intellij.remoteServer.impl.configuration.deployment.DeploymentSourceUtilImpl"/>
|
||||
<projectService serviceInterface="com.intellij.remoteServer.runtime.ServerConnectionManager"
|
||||
serviceImplementation="com.intellij.remoteServer.impl.runtime.ServerConnectionManagerImpl"/>
|
||||
<applicationService serviceInterface="com.intellij.remoteServer.runtime.ServerConnectionManager"
|
||||
serviceImplementation="com.intellij.remoteServer.impl.runtime.ServerConnectionManagerImpl"/>
|
||||
<applicationConfigurable instance="com.intellij.remoteServer.impl.configuration.RemoteServerListConfigurable"/>
|
||||
<programRunner implementation="com.intellij.remoteServer.impl.runtime.DeployToServerRunner"/>
|
||||
</extensions>
|
||||
|
||||
@@ -111,8 +111,6 @@
|
||||
<renameHandler implementation="com.intellij.xml.refactoring.SchemaPrefixRenameHandler" order="before xmlTagRenameHandler"/>
|
||||
<refactoring.inlineHandler language="XML" implementationClass="com.intellij.xml.refactoring.XmlInlineHandler"/>
|
||||
|
||||
<lang.literalEscaper language="XML" implementationClass="com.intellij.lang.xml.XmlLiteralEscaper"/>
|
||||
|
||||
<completion.contributor language="any" implementationClass="com.intellij.codeInsight.completion.XmlCompletionContributor" id="xml"
|
||||
order="first"/>
|
||||
<completion.contributor language="any" implementationClass="com.intellij.codeInsight.completion.XmlNonFirstCompletionContributor" id="xmlNonFirst" order="after xml"/>
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.ide;
|
||||
|
||||
import com.intellij.idea.IdeaTestApplication;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationEx;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -26,7 +25,6 @@ import java.io.File;
|
||||
|
||||
public class LocatorTest extends PlatformLangTestCase {
|
||||
public void test() throws Exception {
|
||||
IdeaTestApplication.getInstance(null);
|
||||
File locatorFile = new File(PathManager.getSystemPath() + "/" + ApplicationEx.LOCATOR_FILE_NAME);
|
||||
assertTrue("doesn't exist: " + locatorFile.getPath(), locatorFile.exists());
|
||||
assertTrue("can't read: " + locatorFile.getPath(), locatorFile.canRead());
|
||||
|
||||
@@ -6,10 +6,10 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.remoteServer.configuration.ServerConfiguration;
|
||||
import com.intellij.remoteServer.configuration.deployment.DeploymentConfigurator;
|
||||
import com.intellij.remoteServer.runtime.ServerConnector;
|
||||
import com.intellij.remoteServer.runtime.ServerTaskExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -42,5 +42,5 @@ public abstract class ServerType<C extends ServerConfiguration> {
|
||||
public abstract DeploymentConfigurator<?> createDeployer(Project project);
|
||||
|
||||
@NotNull
|
||||
public abstract ServerConnector<?> createConnector(@NotNull C configuration, @NotNull Project project, @NotNull Executor asyncTasksExecutor);
|
||||
public abstract ServerConnector<?> createConnector(@NotNull C configuration, @NotNull ServerTaskExecutor asyncTasksExecutor);
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.intellij.remoteServer.runtime;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface RemoteOperationCallback {
|
||||
void errorOccurred(@NotNull String errorMessage);
|
||||
}
|
||||
+6
-2
@@ -4,6 +4,7 @@ import com.intellij.remoteServer.configuration.RemoteServer;
|
||||
import com.intellij.remoteServer.configuration.deployment.DeploymentConfiguration;
|
||||
import com.intellij.remoteServer.configuration.deployment.DeploymentSource;
|
||||
import com.intellij.remoteServer.runtime.deployment.DeploymentStatus;
|
||||
import com.intellij.remoteServer.runtime.deployment.DeploymentTask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -20,9 +21,12 @@ public interface ServerConnection<D extends DeploymentConfiguration> {
|
||||
String getStatusText();
|
||||
|
||||
|
||||
void deploy(@NotNull DeploymentSource source, @NotNull D configuration);
|
||||
void connect(@NotNull Runnable onFinished);
|
||||
|
||||
void undeploy(@NotNull DeploymentSource source, @NotNull D configuration);
|
||||
|
||||
void deploy(@NotNull DeploymentTask<D> task);
|
||||
|
||||
void undeploy(@NotNull DeploymentTask<D> task);
|
||||
|
||||
@NotNull
|
||||
DeploymentStatus getDeploymentStatus(@NotNull DeploymentSource source);
|
||||
|
||||
+2
-3
@@ -1,7 +1,6 @@
|
||||
package com.intellij.remoteServer.runtime;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.remoteServer.configuration.RemoteServer;
|
||||
import com.intellij.remoteServer.configuration.ServerConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -13,8 +12,8 @@ import java.util.Collection;
|
||||
*/
|
||||
public abstract class ServerConnectionManager {
|
||||
@NotNull
|
||||
public static ServerConnectionManager getInstance(@NotNull Project project) {
|
||||
return ServiceManager.getService(project, ServerConnectionManager.class);
|
||||
public static ServerConnectionManager getInstance() {
|
||||
return ServiceManager.getService(ServerConnectionManager.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+1
-2
@@ -12,8 +12,7 @@ public abstract class ServerConnector<D extends DeploymentConfiguration> {
|
||||
|
||||
public abstract void disconnect();
|
||||
|
||||
public interface ConnectionCallback<D extends DeploymentConfiguration> {
|
||||
public interface ConnectionCallback<D extends DeploymentConfiguration> extends RemoteOperationCallback {
|
||||
void connected(@NotNull ServerRuntimeInstance<D> serverRuntimeInstance);
|
||||
void connectionFailed(@NotNull String errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
package com.intellij.remoteServer.runtime;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface ServerRuntimeData {
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.intellij.remoteServer.runtime;
|
||||
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface ServerTaskExecutor extends Executor {
|
||||
void submit(@NotNull Runnable command);
|
||||
void submit(@NotNull ThrowableRunnable<?> command, @NotNull RemoteOperationCallback callback);
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.intellij.remoteServer.runtime.deployment;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.remoteServer.configuration.deployment.DeploymentConfiguration;
|
||||
import com.intellij.remoteServer.configuration.deployment.DeploymentSource;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface DeploymentTask<D extends DeploymentConfiguration> {
|
||||
@NotNull
|
||||
DeploymentSource getSource();
|
||||
|
||||
@NotNull
|
||||
D getConfiguration();
|
||||
|
||||
@NotNull
|
||||
Project getProject();
|
||||
}
|
||||
+4
-8
@@ -1,7 +1,7 @@
|
||||
package com.intellij.remoteServer.runtime.deployment;
|
||||
|
||||
import com.intellij.remoteServer.configuration.deployment.DeploymentConfiguration;
|
||||
import com.intellij.remoteServer.configuration.deployment.DeploymentSource;
|
||||
import com.intellij.remoteServer.runtime.RemoteOperationCallback;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -9,15 +9,11 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public abstract class ServerRuntimeInstance<D extends DeploymentConfiguration> {
|
||||
|
||||
public abstract void deploy(@NotNull DeploymentSource source, @NotNull D configuration,
|
||||
@NotNull DeploymentOperationCallback callback);
|
||||
public abstract void deploy(@NotNull DeploymentTask<D> task, @NotNull DeploymentOperationCallback callback);
|
||||
|
||||
public abstract void undeploy(@NotNull DeploymentSource source, @NotNull D configuration,
|
||||
@NotNull DeploymentOperationCallback callback);
|
||||
public abstract void undeploy(@NotNull DeploymentTask<D> task, @NotNull DeploymentOperationCallback callback);
|
||||
|
||||
public interface DeploymentOperationCallback {
|
||||
public interface DeploymentOperationCallback extends RemoteOperationCallback {
|
||||
void succeeded();
|
||||
|
||||
void failed(@NotNull String errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.remoteServer.impl.configuration.RemoteServerConfigurable">
|
||||
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="3" 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>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="ab159" binding="mySettingsPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" 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"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<vspacer id="7a5f8">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="9d650" class="javax.swing.JButton" binding="myTestConnectionButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Test connection"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="79e5">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
+67
-4
@@ -1,15 +1,27 @@
|
||||
package com.intellij.remoteServer.impl.configuration;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.UnnamedConfigurable;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.NamedConfigurable;
|
||||
import com.intellij.remoteServer.configuration.RemoteServer;
|
||||
import com.intellij.remoteServer.configuration.ServerConfiguration;
|
||||
import com.intellij.remoteServer.runtime.ConnectionStatus;
|
||||
import com.intellij.remoteServer.runtime.ServerConnection;
|
||||
import com.intellij.remoteServer.runtime.ServerConnectionManager;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -19,6 +31,9 @@ public class RemoteServerConfigurable extends NamedConfigurable<RemoteServer<?>>
|
||||
private final RemoteServer<?> myServer;
|
||||
private String myServerName;
|
||||
private boolean myNew;
|
||||
private JPanel myMainPanel;
|
||||
private JPanel mySettingsPanel;
|
||||
private JButton myTestConnectionButton;
|
||||
|
||||
public <C extends ServerConfiguration> RemoteServerConfigurable(RemoteServer<C> server, Runnable treeUpdater, boolean isNew) {
|
||||
super(true, treeUpdater);
|
||||
@@ -41,10 +56,58 @@ public class RemoteServerConfigurable extends NamedConfigurable<RemoteServer<?>>
|
||||
|
||||
@Override
|
||||
public JComponent createOptionsPanel() {
|
||||
JComponent component = myConfigurable.createComponent();
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(component, BorderLayout.NORTH);
|
||||
return panel;
|
||||
mySettingsPanel.add(BorderLayout.CENTER, myConfigurable.createComponent());
|
||||
myTestConnectionButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
apply();
|
||||
}
|
||||
catch (ConfigurationException exc) {
|
||||
Messages.showErrorDialog(myMainPanel, "Cannot test connection: " + exc.getMessage(), exc.getTitle());
|
||||
return;
|
||||
}
|
||||
testConnection();
|
||||
}
|
||||
});
|
||||
return myMainPanel;
|
||||
}
|
||||
|
||||
private void testConnection() {
|
||||
final ServerConnection connection = ServerConnectionManager.getInstance().getOrCreateConnection(myServer);
|
||||
final AtomicReference<Runnable> showResultRef = new AtomicReference<Runnable>(null);
|
||||
new Task.Modal(null, "Connecting...", true) {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
indicator.setIndeterminate(true);
|
||||
final Semaphore semaphore = new Semaphore();
|
||||
semaphore.down();
|
||||
connection.connect(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showResultRef.set(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (connection.getStatus() == ConnectionStatus.CONNECTED) {
|
||||
Messages.showInfoMessage(myMainPanel, "Connection successful", "Test Connection");
|
||||
}
|
||||
else if (connection.getStatus() == ConnectionStatus.DISCONNECTED) {
|
||||
Messages.showErrorDialog(myMainPanel, "Cannot connect: " + connection.getStatusText(), "Test Connection");
|
||||
}
|
||||
}
|
||||
});
|
||||
semaphore.up();
|
||||
}
|
||||
});
|
||||
while (!indicator.isCanceled()) {
|
||||
semaphore.waitFor(500);
|
||||
}
|
||||
Runnable showResult = showResultRef.get();
|
||||
if (showResult != null) {
|
||||
ApplicationManager.getApplication().invokeLater(showResult);
|
||||
}
|
||||
}
|
||||
}.queue();
|
||||
}
|
||||
|
||||
@Nls
|
||||
|
||||
+3
-2
@@ -25,6 +25,7 @@ import com.intellij.remoteServer.configuration.RemoteServer;
|
||||
import com.intellij.remoteServer.configuration.ServerConfiguration;
|
||||
import com.intellij.remoteServer.configuration.deployment.DeploymentConfiguration;
|
||||
import com.intellij.remoteServer.configuration.deployment.DeploymentSource;
|
||||
import com.intellij.remoteServer.impl.runtime.deployment.DeploymentTaskImpl;
|
||||
import com.intellij.remoteServer.runtime.ServerConnection;
|
||||
import com.intellij.remoteServer.runtime.ServerConnectionManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -51,8 +52,8 @@ public class DeployToServerState<S extends ServerConfiguration, D extends Deploy
|
||||
@Nullable
|
||||
@Override
|
||||
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
|
||||
ServerConnection connection = ServerConnectionManager.getInstance(myEnvironment.getProject()).getOrCreateConnection(myServer);
|
||||
connection.deploy(mySource, myConfiguration);
|
||||
ServerConnection connection = ServerConnectionManager.getInstance().getOrCreateConnection(myServer);
|
||||
connection.deploy(new DeploymentTaskImpl(mySource, myConfiguration, myEnvironment.getProject()));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+50
-16
@@ -3,12 +3,13 @@ package com.intellij.remoteServer.impl.runtime;
|
||||
import com.intellij.remoteServer.configuration.RemoteServer;
|
||||
import com.intellij.remoteServer.configuration.deployment.DeploymentConfiguration;
|
||||
import com.intellij.remoteServer.configuration.deployment.DeploymentSource;
|
||||
import com.intellij.remoteServer.impl.runtime.deployment.DeploymentInformation;
|
||||
import com.intellij.remoteServer.runtime.ConnectionStatus;
|
||||
import com.intellij.remoteServer.runtime.ServerConnection;
|
||||
import com.intellij.remoteServer.runtime.ServerConnector;
|
||||
import com.intellij.remoteServer.runtime.deployment.DeploymentStatus;
|
||||
import com.intellij.remoteServer.runtime.deployment.DeploymentTask;
|
||||
import com.intellij.remoteServer.runtime.deployment.ServerRuntimeInstance;
|
||||
import com.intellij.util.ParameterizedRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -48,23 +49,49 @@ public class ServerConnectionImpl<D extends DeploymentConfiguration> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deploy(@NotNull final DeploymentSource source, @NotNull final D configuration) {
|
||||
runOnInstance(new ParameterizedRunnable<ServerRuntimeInstance<D>>() {
|
||||
public void connect(@NotNull final Runnable onFinished) {
|
||||
disconnect();
|
||||
connectIfNeeded(new ServerConnector.ConnectionCallback<D>() {
|
||||
@Override
|
||||
public void run(ServerRuntimeInstance<D> instance) {
|
||||
myDeploymentInfos.put(source, new DeploymentInformation(DeploymentStatus.DEPLOYING));
|
||||
instance.deploy(source, configuration, new UpdateDeploymentStatusCallback(source, DeploymentStatus.DEPLOYED,
|
||||
DeploymentStatus.NOT_DEPLOYED));
|
||||
public void connected(@NotNull ServerRuntimeInstance<D> serverRuntimeInstance) {
|
||||
onFinished.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void errorOccurred(@NotNull String errorMessage) {
|
||||
onFinished.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void disconnect() {
|
||||
if (myStatus == ConnectionStatus.CONNECTED) {
|
||||
myRuntimeInstance = null;
|
||||
myConnector.disconnect();
|
||||
myStatus = ConnectionStatus.DISCONNECTED;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deploy(@NotNull final DeploymentTask<D> task) {
|
||||
connectIfNeeded(new ConnectionCallbackBase<D>() {
|
||||
@Override
|
||||
public void connected(@NotNull ServerRuntimeInstance<D> instance) {
|
||||
myDeploymentInfos.put(task.getSource(), new DeploymentInformation(DeploymentStatus.DEPLOYING));
|
||||
instance.deploy(task, new UpdateDeploymentStatusCallback(task.getSource(), DeploymentStatus.DEPLOYED,
|
||||
DeploymentStatus.NOT_DEPLOYED));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undeploy(@NotNull final DeploymentSource source, @NotNull final D configuration) {
|
||||
runOnInstance(new ParameterizedRunnable<ServerRuntimeInstance<D>>() {
|
||||
public void undeploy(@NotNull final DeploymentTask<D> task) {
|
||||
connectIfNeeded(new ConnectionCallbackBase<D>() {
|
||||
@Override
|
||||
public void run(ServerRuntimeInstance<D> instance) {
|
||||
instance.undeploy(source, configuration, new UpdateDeploymentStatusCallback(source, DeploymentStatus.NOT_DEPLOYED, DeploymentStatus.DEPLOYED));
|
||||
public void connected(@NotNull ServerRuntimeInstance<D> instance) {
|
||||
myDeploymentInfos.put(task.getSource(), new DeploymentInformation(DeploymentStatus.UNDEPLOYING));
|
||||
instance.undeploy(task, new UpdateDeploymentStatusCallback(task.getSource(), DeploymentStatus.NOT_DEPLOYED,
|
||||
DeploymentStatus.DEPLOYED));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -76,10 +103,10 @@ public class ServerConnectionImpl<D extends DeploymentConfiguration> implements
|
||||
return information != null ? information.getStatus() : DeploymentStatus.NOT_DEPLOYED;
|
||||
}
|
||||
|
||||
private void runOnInstance(final ParameterizedRunnable<ServerRuntimeInstance<D>> action) {
|
||||
private void connectIfNeeded(final ServerConnector.ConnectionCallback<D> callback) {
|
||||
final ServerRuntimeInstance<D> instance = myRuntimeInstance;
|
||||
if (instance != null) {
|
||||
action.run(instance);
|
||||
callback.connected(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -89,18 +116,25 @@ public class ServerConnectionImpl<D extends DeploymentConfiguration> implements
|
||||
public void connected(@NotNull ServerRuntimeInstance<D> instance) {
|
||||
myStatus = ConnectionStatus.CONNECTED;
|
||||
myRuntimeInstance = instance;
|
||||
action.run(instance);
|
||||
callback.connected(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionFailed(@NotNull String errorMessage) {
|
||||
public void errorOccurred(@NotNull String errorMessage) {
|
||||
myStatus = ConnectionStatus.DISCONNECTED;
|
||||
myRuntimeInstance = null;
|
||||
myStatusText = errorMessage;
|
||||
callback.errorOccurred(errorMessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static abstract class ConnectionCallbackBase<D extends DeploymentConfiguration> implements ServerConnector.ConnectionCallback<D> {
|
||||
@Override
|
||||
public void errorOccurred(@NotNull String errorMessage) {
|
||||
}
|
||||
}
|
||||
|
||||
private class UpdateDeploymentStatusCallback implements ServerRuntimeInstance.DeploymentOperationCallback {
|
||||
private final DeploymentSource mySource;
|
||||
private DeploymentStatus mySuccessStatus;
|
||||
@@ -118,7 +152,7 @@ public class ServerConnectionImpl<D extends DeploymentConfiguration> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(@NotNull String errorMessage) {
|
||||
public void errorOccurred(@NotNull String errorMessage) {
|
||||
myDeploymentInfos.put(mySource, new DeploymentInformation(myFailedStatus, errorMessage));
|
||||
}
|
||||
}
|
||||
|
||||
+5
-11
@@ -1,13 +1,11 @@
|
||||
package com.intellij.remoteServer.impl.runtime;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.remoteServer.configuration.RemoteServer;
|
||||
import com.intellij.remoteServer.configuration.ServerConfiguration;
|
||||
import com.intellij.remoteServer.runtime.ServerConnection;
|
||||
import com.intellij.remoteServer.runtime.ServerConnectionManager;
|
||||
import com.intellij.util.concurrency.SequentialTaskExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.ide.PooledThreadExecutor;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -19,20 +17,15 @@ import java.util.Map;
|
||||
*/
|
||||
public class ServerConnectionManagerImpl extends ServerConnectionManager {
|
||||
private Map<RemoteServer<?>, ServerConnection> myConnections = new HashMap<RemoteServer<?>, ServerConnection>();
|
||||
private final PooledThreadExecutor myPooledThreadExecutor = new PooledThreadExecutor();
|
||||
private final Project myProject;
|
||||
|
||||
public ServerConnectionManagerImpl(Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <C extends ServerConfiguration> ServerConnection getOrCreateConnection(@NotNull RemoteServer<C> server) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
ServerConnection connection = myConnections.get(server);
|
||||
if (connection == null) {
|
||||
SequentialTaskExecutor executor = new SequentialTaskExecutor(myPooledThreadExecutor);
|
||||
connection = new ServerConnectionImpl(server, server.getType().createConnector(server.getConfiguration(), myProject, executor));
|
||||
ServerTaskExecutorImpl executor = new ServerTaskExecutorImpl();
|
||||
connection = new ServerConnectionImpl(server, server.getType().createConnector(server.getConfiguration(), executor));
|
||||
myConnections.put(server, connection);
|
||||
}
|
||||
return connection;
|
||||
@@ -41,6 +34,7 @@ public class ServerConnectionManagerImpl extends ServerConnectionManager {
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<ServerConnection> getConnections() {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
return Collections.unmodifiableCollection(myConnections.values());
|
||||
}
|
||||
}
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.intellij.remoteServer.impl.runtime;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.remoteServer.runtime.RemoteOperationCallback;
|
||||
import com.intellij.remoteServer.runtime.ServerTaskExecutor;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import com.intellij.util.concurrency.SequentialTaskExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.ide.PooledThreadExecutor;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ServerTaskExecutorImpl implements ServerTaskExecutor {
|
||||
private static final Logger LOG = Logger.getInstance(ServerTaskExecutorImpl.class);
|
||||
private static final PooledThreadExecutor POOLED_THREAD_EXECUTOR = new PooledThreadExecutor();
|
||||
private final SequentialTaskExecutor myTaskExecutor;
|
||||
|
||||
public ServerTaskExecutorImpl() {
|
||||
myTaskExecutor = new SequentialTaskExecutor(POOLED_THREAD_EXECUTOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(@NotNull Runnable command) {
|
||||
myTaskExecutor.execute(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submit(@NotNull Runnable command) {
|
||||
execute(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submit(@NotNull final ThrowableRunnable<?> command, @NotNull final RemoteOperationCallback callback) {
|
||||
execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
command.run();
|
||||
}
|
||||
catch (Throwable e) {
|
||||
LOG.info(e);
|
||||
callback.errorOccurred(e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.intellij.remoteServer.impl.runtime;
|
||||
package com.intellij.remoteServer.impl.runtime.deployment;
|
||||
|
||||
import com.intellij.remoteServer.runtime.deployment.DeploymentStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.intellij.remoteServer.impl.runtime.deployment;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.remoteServer.configuration.deployment.DeploymentConfiguration;
|
||||
import com.intellij.remoteServer.configuration.deployment.DeploymentSource;
|
||||
import com.intellij.remoteServer.runtime.deployment.DeploymentTask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class DeploymentTaskImpl<D extends DeploymentConfiguration> implements DeploymentTask<D> {
|
||||
private final DeploymentSource mySource;
|
||||
private final D myConfiguration;
|
||||
private final Project myProject;
|
||||
|
||||
public DeploymentTaskImpl(DeploymentSource source, D configuration, Project project) {
|
||||
mySource = source;
|
||||
myConfiguration = configuration;
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DeploymentSource getSource() {
|
||||
return mySource;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public D getConfiguration() {
|
||||
return myConfiguration;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Project getProject() {
|
||||
return myProject;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -667,7 +667,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
myFile.getName() +
|
||||
" at caret position, offset " +
|
||||
myEditor.getCaretModel().getOffset() + "\"" +
|
||||
" psi structure: " + DebugUtil.psiToString(myFile, true);
|
||||
" psi structure: " + DebugUtil.psiToString(myFile, true, true);
|
||||
return element;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,11 +16,10 @@
|
||||
package com.intellij.testFramework.vcs;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -51,14 +50,18 @@ public class DirectoryData {
|
||||
}
|
||||
|
||||
public VirtualFile getBase() {
|
||||
return myBase;
|
||||
return myBase.findChild("dirData");
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
final File ioFile = new File(myBase.getPath());
|
||||
final File[] files = ioFile.listFiles();
|
||||
for (File file : files) {
|
||||
FileUtil.delete(file);
|
||||
final VirtualFile base = getBase();
|
||||
if (base != null) {
|
||||
new WriteCommandAction.Simple(null) {
|
||||
@Override
|
||||
protected void run() throws Throwable {
|
||||
base.delete(this);
|
||||
}
|
||||
}.execute().throwException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +73,14 @@ public class DirectoryData {
|
||||
final List<VirtualFile> currentLevel = new ArrayList<VirtualFile>();
|
||||
final List<VirtualFile> nextLevel = new ArrayList<VirtualFile>();
|
||||
|
||||
currentLevel.add(myBase);
|
||||
try {
|
||||
myBase.createChildDirectory(this, "dirData");
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
}
|
||||
VirtualFile newBase = getBase();
|
||||
assert newBase != null;
|
||||
currentLevel.add(newBase);
|
||||
for (int i = 0; i < myLevels; i++) {
|
||||
for (VirtualFile file : currentLevel) {
|
||||
String numberInRow;
|
||||
@@ -101,7 +111,8 @@ public class DirectoryData {
|
||||
currentLevel.addAll(nextLevel);
|
||||
nextLevel.clear();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
catch (IOException e) {
|
||||
myException = e;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user