mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
@@ -30,6 +30,30 @@ if [ -z "$IDEA_JDK" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
VERSION_LOG='/tmp/java.version.log'
|
||||
$IDEA_JDK/bin/java -version 2> $VERSION_LOG
|
||||
grep 'OpenJDK' $VERSION_LOG
|
||||
OPEN_JDK=$?
|
||||
grep '64-Bit' $VERSION_LOG
|
||||
BITS=$?
|
||||
rm /tmp/java.version.log
|
||||
if [ $OPEN_JDK -eq 0 ]; then
|
||||
echo WARNING: You are launching IDE using OpenJDK Java runtime
|
||||
echo
|
||||
echo THIS IS STRICTLY UNSUPPORTED DUE TO KNOWN PERFORMANCE AND GRAPHICS PROBLEMS
|
||||
echo
|
||||
echo NOTE: If you have both Sun JDK and OpenJDK installed
|
||||
echo please validate either IDEA_JDK or JDK_HOME points to valid Sun JDK installation
|
||||
echo
|
||||
echo Press Enter to continue.
|
||||
read IGNORE
|
||||
fi
|
||||
if [ $BITS -eq 0 ]; then
|
||||
BITS="64"
|
||||
else
|
||||
BITS=""
|
||||
fi
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# Ensure the IDEA_HOME var for this script points to the
|
||||
# home directory where IntelliJ IDEA is installed on your system.
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+12
-3
@@ -317,6 +317,14 @@ public class JavacCompiler extends ExternalCompiler {
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (versionIndex > 5) {
|
||||
// Unless explicitly specified by user, disable annotation processing by default for 'java compilation' mode
|
||||
// This is needed to suppress unwanted side-effects from auto-discovered processors from compilation classpath
|
||||
additionalOptions.add("-proc:none");
|
||||
}
|
||||
}
|
||||
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
@NonNls String token = tokenizer.nextToken();
|
||||
if (versionIndex == 0) {
|
||||
@@ -329,10 +337,10 @@ public class JavacCompiler extends ExternalCompiler {
|
||||
continue; // not supported in these versions
|
||||
}
|
||||
}
|
||||
if (token.startsWith("-proc:")) {
|
||||
continue;
|
||||
}
|
||||
if (isAnnotationProcessing) {
|
||||
if (token.startsWith("-proc:")) {
|
||||
continue;
|
||||
}
|
||||
if (token.startsWith("-implicit:")) {
|
||||
continue;
|
||||
}
|
||||
@@ -344,6 +352,7 @@ public class JavacCompiler extends ExternalCompiler {
|
||||
additionalOptions.add(token);
|
||||
}
|
||||
}
|
||||
|
||||
return additionalOptions;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl;
|
||||
import com.intellij.debugger.ui.tree.render.NodeRenderer;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -34,7 +35,7 @@ import java.util.List;
|
||||
* Date: Sep 26, 2003
|
||||
* Time: 11:05:57 PM
|
||||
*/
|
||||
public class ViewAsGroup extends ActionGroup{
|
||||
public class ViewAsGroup extends ActionGroup implements DumbAware {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.actions.ViewAsGroup");
|
||||
|
||||
private AnAction[] myChildren = AnAction.EMPTY_ARRAY;
|
||||
|
||||
@@ -338,6 +338,11 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
|
||||
e.getPresentation().setText(ActionsBundle.message("group.XDebugger.settings.text"));
|
||||
e.getPresentation().setIcon(layoutGroup.getTemplatePresentation().getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDumbAware() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
for (AnAction each : layout) {
|
||||
settings.add(each);
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.facet.FacetTypeRegistry;
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -30,7 +31,7 @@ import java.util.Comparator;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class AddFacetActionGroup extends ActionGroup {
|
||||
public class AddFacetActionGroup extends ActionGroup implements DumbAware {
|
||||
private final boolean myFromPopup;
|
||||
private final FacetEditorFacade myEditor;
|
||||
private AnAction[] myCachedChildren;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class FrameworkSupportNode extends CheckedTreeNode {
|
||||
private final Computable<String> myBaseDirForLibrariesGetter;
|
||||
private LibraryCompositionOptionsPanel myLibraryCompositionOptionsPanel;
|
||||
|
||||
FrameworkSupportNode(final FrameworkSupportProvider provider, final FrameworkSupportNode parentNode, final FrameworkSupportModelImpl model,
|
||||
public FrameworkSupportNode(final FrameworkSupportProvider provider, final FrameworkSupportNode parentNode, final FrameworkSupportModelImpl model,
|
||||
Computable<String> baseDirForLibrariesGetter, Disposable parentDisposable) {
|
||||
super(provider);
|
||||
myBaseDirForLibrariesGetter = baseDirForLibrariesGetter;
|
||||
|
||||
@@ -462,8 +462,8 @@ public class HighlightUtil {
|
||||
if (rType != null && expression != null && isCastIntentionApplicable(expression, lType)) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, new AddTypeCastFix(lType, expression));
|
||||
}
|
||||
if (lType instanceof PsiClassType && expression != null) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, new WrapExpressionFix((PsiClassType)lType, expression));
|
||||
if (expression != null && lType != null) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, new WrapExpressionFix(lType, expression));
|
||||
}
|
||||
ChangeNewOperatorTypeFix.register(highlightInfo, expression, lType);
|
||||
return highlightInfo;
|
||||
|
||||
+49
-25
@@ -22,6 +22,7 @@ import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -34,29 +35,47 @@ public class WrapExpressionFix implements IntentionAction {
|
||||
|
||||
private final PsiExpression myExpression;
|
||||
private final PsiClassType myExpectedType;
|
||||
private final boolean myPrimitiveExpected;
|
||||
|
||||
public WrapExpressionFix(PsiClassType expectedType, PsiExpression expression) {
|
||||
public WrapExpressionFix(PsiType expectedType, PsiExpression expression) {
|
||||
myExpression = expression;
|
||||
myExpectedType = expectedType;
|
||||
myExpectedType = getClassType(expectedType, expression);
|
||||
myPrimitiveExpected = expectedType instanceof PsiPrimitiveType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiClassType getClassType(PsiType type, PsiElement place) {
|
||||
if (type instanceof PsiClassType) {
|
||||
return (PsiClassType)type;
|
||||
}
|
||||
else if (type instanceof PsiPrimitiveType){
|
||||
return ((PsiPrimitiveType)type).getBoxedType(place.getManager(), GlobalSearchScope.allScope(place.getProject()));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getText() {
|
||||
final PsiMethod wrapper = myExpression.isValid() ? findWrapper(myExpression.getType(), myExpectedType) : null;
|
||||
final PsiMethod wrapper = myExpression.isValid() ? findWrapper(myExpression.getType(), myExpectedType, myPrimitiveExpected) : null;
|
||||
final String methodPresentation = wrapper != null ? (wrapper.getContainingClass().getName() + "." + wrapper.getName()) : "";
|
||||
return QuickFixBundle.message("wrap.expression.using.static.accessor.text", methodPresentation);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiMethod findWrapper(PsiType type, PsiClassType expectedType) {
|
||||
private static PsiMethod findWrapper(PsiType type, PsiClassType expectedType, boolean primitiveExpected) {
|
||||
PsiClass aClass = expectedType.resolve();
|
||||
if (aClass != null) {
|
||||
PsiType expectedReturnType = expectedType;
|
||||
if (primitiveExpected) {
|
||||
expectedReturnType = PsiPrimitiveType.getUnboxedType(expectedType);
|
||||
}
|
||||
if (expectedReturnType == null) return null;
|
||||
PsiMethod[] methods = aClass.getMethods();
|
||||
for (PsiMethod method : methods) {
|
||||
if (method.hasModifierProperty(PsiModifier.STATIC) && method.getParameterList().getParametersCount() == 1 &&
|
||||
method.getParameterList().getParameters()[0].getType().equals(type) &&
|
||||
method.getReturnType() != null &&
|
||||
expectedType.equals(method.getReturnType())) {
|
||||
expectedReturnType.equals(method.getReturnType())) {
|
||||
return method;
|
||||
}
|
||||
}
|
||||
@@ -73,14 +92,15 @@ public class WrapExpressionFix implements IntentionAction {
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
return myExpression.isValid()
|
||||
&& myExpression.getManager().isInProject(myExpression)
|
||||
&& myExpectedType != null
|
||||
&& myExpectedType.isValid()
|
||||
&& myExpression.getType() != null
|
||||
&& findWrapper(myExpression.getType(), myExpectedType) != null;
|
||||
&& findWrapper(myExpression.getType(), myExpectedType, myPrimitiveExpected) != null;
|
||||
}
|
||||
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
if (!CodeInsightUtilBase.prepareFileForWrite(file)) return;
|
||||
PsiMethod wrapper = findWrapper(myExpression.getType(), myExpectedType);
|
||||
PsiMethod wrapper = findWrapper(myExpression.getType(), myExpectedType, myPrimitiveExpected);
|
||||
assert wrapper != null;
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(file.getProject()).getElementFactory();
|
||||
@NonNls String methodCallText = "Foo." + wrapper.getName() + "()";
|
||||
@@ -97,39 +117,43 @@ public class WrapExpressionFix implements IntentionAction {
|
||||
}
|
||||
|
||||
public static void registerWrapAction (JavaResolveResult[] candidates, PsiExpression[] expressions, HighlightInfo highlightInfo) {
|
||||
PsiClassType expectedType = null;
|
||||
PsiType expectedType = null;
|
||||
PsiExpression expr = null;
|
||||
|
||||
nextMethod:
|
||||
for (int i = 0; i < candidates.length && expectedType == null; i++) {
|
||||
JavaResolveResult candidate = candidates[i];
|
||||
PsiSubstitutor substitutor = candidate.getSubstitutor();
|
||||
final JavaResolveResult candidate = candidates[i];
|
||||
final PsiSubstitutor substitutor = candidate.getSubstitutor();
|
||||
final PsiElement element = candidate.getElement();
|
||||
assert element != null;
|
||||
PsiParameter[] parameters = ((PsiMethod)element).getParameterList().getParameters();
|
||||
if (parameters.length != expressions.length) continue;
|
||||
final PsiMethod method = (PsiMethod)element;
|
||||
final PsiParameter[] parameters = method.getParameterList().getParameters();
|
||||
if (!method.isVarArgs() && parameters.length != expressions.length) continue;
|
||||
for (int j = 0; j < expressions.length; j++) {
|
||||
PsiExpression expression = expressions[j];
|
||||
if (expression.getType() != null) {
|
||||
PsiType paramType = parameters[j].getType();
|
||||
final PsiType exprType = expression.getType();
|
||||
if (exprType != null) {
|
||||
PsiType paramType = parameters[Math.min(j, parameters.length -1)].getType();
|
||||
if (paramType instanceof PsiEllipsisType) {
|
||||
paramType = ((PsiEllipsisType)paramType).getComponentType();
|
||||
}
|
||||
paramType = substitutor != null ? substitutor.substitute(paramType) : paramType;
|
||||
if (paramType.isAssignableFrom(expression.getType())) continue;
|
||||
if (paramType instanceof PsiClassType) {
|
||||
if (expectedType == null && findWrapper(expression.getType(), (PsiClassType) paramType) != null) {
|
||||
expectedType = (PsiClassType) paramType;
|
||||
expr = expression;
|
||||
} else {
|
||||
expectedType = null;
|
||||
expr = null;
|
||||
continue nextMethod;
|
||||
}
|
||||
if (paramType.isAssignableFrom(exprType)) continue;
|
||||
final PsiClassType classType = getClassType(paramType, expression);
|
||||
if (expectedType == null && classType != null && findWrapper(exprType, classType, paramType instanceof PsiPrimitiveType) != null) {
|
||||
expectedType = paramType;
|
||||
expr = expression;
|
||||
} else {
|
||||
expectedType = null;
|
||||
expr = null;
|
||||
continue nextMethod;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (expectedType != null) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, expr.getTextRange(), new WrapExpressionFix(expectedType, expr), null);
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, expr.getTextRange(), new WrapExpressionFix(expectedType, expr), null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,10 @@ import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.util.ProgressIndicatorBase;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
@@ -121,6 +123,12 @@ public class JavaDocExternalFilter {
|
||||
return DOC_ELEMENT_PROTOCOL + root + href;
|
||||
}
|
||||
|
||||
if (Comparing.strEqual(VirtualFileManager.extractProtocol(root), LocalFileSystem.PROTOCOL)) {
|
||||
final String path = VirtualFileManager.extractPath(root);
|
||||
if (!path.startsWith("/")) {//skip host for local file system files (format - file://host_name/path)
|
||||
root = VirtualFileManager.constructUrl(LocalFileSystem.PROTOCOL, "/" + path);
|
||||
}
|
||||
}
|
||||
return ourHTMLFilesuffix.matcher(root).replaceAll("/") + href;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.lookup;
|
||||
|
||||
import com.intellij.codeInsight.completion.DefaultInsertHandler;
|
||||
import com.intellij.codeInsight.completion.InsertionContext;
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -33,6 +35,12 @@ public class PsiTypeLookupItem extends LookupItem {
|
||||
return super.equals(o) && o instanceof PsiTypeLookupItem && getBracketsCount() == ((PsiTypeLookupItem) o).getBracketsCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInsert(InsertionContext context) {
|
||||
DefaultInsertHandler.addImportForItem(context.getFile(), context.getStartOffset(), this);
|
||||
super.handleInsert(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int fromSuper = super.hashCode();
|
||||
|
||||
@@ -726,6 +726,10 @@ public class ExtractMethodProcessor implements MatchProvider {
|
||||
myExtractedMethod = (PsiMethod)myTargetClass.addAfter(newMethod, myAnchor);
|
||||
if (myNeedChangeContext) {
|
||||
ChangeContextUtil.decodeContextInfo(myExtractedMethod, myTargetClass, RefactoringUtil.createThisExpression(myManager, null));
|
||||
if (myMethodCall.resolveMethod() != myExtractedMethod) {
|
||||
final PsiReferenceExpression methodExpression = myMethodCall.getMethodExpression();
|
||||
methodExpression.setQualifierExpression(RefactoringUtil.createThisExpression(myManager, myTargetClass));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.intellij.psi.controlFlow.*;
|
||||
import com.intellij.psi.impl.source.codeStyle.CodeEditUtil;
|
||||
import com.intellij.psi.infos.MethodCandidateInfo;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
@@ -592,7 +593,7 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
if (!name.equals(parmName)) {
|
||||
name = myJavaCodeStyle.suggestUniqueVariableName(name, block.getFirstChild(), true);
|
||||
}
|
||||
RefactoringUtil.renameVariableReferences(parm, name, GlobalSearchScope.projectScope(myProject));
|
||||
RefactoringUtil.renameVariableReferences(parm, name, new LocalSearchScope(myMethodCopy.getBody()), true);
|
||||
PsiType paramType = parm.getType();
|
||||
@NonNls String defaultValue;
|
||||
if (paramType instanceof PsiEllipsisType) {
|
||||
@@ -687,7 +688,7 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
name = newName;
|
||||
}
|
||||
if (!name.equals(oldName)) {
|
||||
RefactoringUtil.renameVariableReferences(var, name, GlobalSearchScope.projectScope(myProject));
|
||||
RefactoringUtil.renameVariableReferences(var, name, new LocalSearchScope(myMethodCopy.getBody()), true);
|
||||
var.getNameIdentifier().replace(myFactory.createIdentifier(name));
|
||||
}
|
||||
}
|
||||
@@ -1313,4 +1314,4 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
return myReference == null ? Collections.singletonList(myMethod) : Arrays.asList(myReference, myMethod);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,7 +402,14 @@ public class RefactoringUtil {
|
||||
}
|
||||
|
||||
public static void renameVariableReferences(PsiVariable variable, String newName, SearchScope scope) throws IncorrectOperationException {
|
||||
for (PsiReference reference : ReferencesSearch.search(variable, scope)) {
|
||||
renameVariableReferences(variable, newName, scope, false);
|
||||
}
|
||||
|
||||
public static void renameVariableReferences(PsiVariable variable,
|
||||
String newName,
|
||||
SearchScope scope,
|
||||
final boolean ignoreAccessScope) throws IncorrectOperationException {
|
||||
for (PsiReference reference : ReferencesSearch.search(variable, scope, ignoreAccessScope)) {
|
||||
reference.handleElementRename(newName);
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Wrap using 'Long.parseLong'" "true"
|
||||
public class Test {
|
||||
private long lo = Long.parseLong("42");
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Wrap using 'Long.parseLong'" "true"
|
||||
public class Test {
|
||||
void ba() {
|
||||
fa(Long.parseLong("42"));
|
||||
}
|
||||
|
||||
void fa(long l){}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Wrap using 'Long.parseLong'" "true"
|
||||
public class Test {
|
||||
void ba(long l) {
|
||||
fa(l, Long.parseLong("42"));
|
||||
}
|
||||
|
||||
void fa(long... l){}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Wrap using 'Long.valueOf'" "true"
|
||||
public class Test {
|
||||
private Long lo = Long.valueOf("42");
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Wrap using 'Long.valueOf'" "true"
|
||||
public class Test {
|
||||
void ba() {
|
||||
fa(Long.valueOf("42"));
|
||||
}
|
||||
|
||||
void fa(Long l){}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Wrap using 'Long.valueOf'" "true"
|
||||
public class Test {
|
||||
void ba(Long l) {
|
||||
fa(l, Long.valueOf("42"));
|
||||
}
|
||||
|
||||
void fa(Long... l){}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Wrap using 'Long.valueOf'" "true"
|
||||
public class Test {
|
||||
void ba() {
|
||||
fa(Long.valueOf("42"));
|
||||
}
|
||||
|
||||
void fa(Long l, int... ii){}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Wrap using 'Long.parseLong'" "true"
|
||||
public class Test {
|
||||
private long l<caret>o = "42";
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Wrap using 'Long.parseLong'" "true"
|
||||
public class Test {
|
||||
void ba() {
|
||||
fa("4<caret>2");
|
||||
}
|
||||
|
||||
void fa(long l){}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Wrap using 'Long.parseLong'" "true"
|
||||
public class Test {
|
||||
void ba(long l) {
|
||||
fa(l, "4<caret>2");
|
||||
}
|
||||
|
||||
void fa(long... l){}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Wrap using 'Long.valueOf'" "true"
|
||||
public class Test {
|
||||
private Long l<caret>o = "42";
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Wrap using 'Long.valueOf'" "true"
|
||||
public class Test {
|
||||
void ba() {
|
||||
fa("4<caret>2");
|
||||
}
|
||||
|
||||
void fa(Long l){}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Wrap using 'Long.valueOf'" "true"
|
||||
public class Test {
|
||||
void ba(Long l) {
|
||||
fa(l, "4<caret>2");
|
||||
}
|
||||
|
||||
void fa(Long... l){}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Wrap using 'Long.valueOf'" "true"
|
||||
public class Test {
|
||||
void ba() {
|
||||
fa("4<caret>2");
|
||||
}
|
||||
|
||||
void fa(Long l, int... ii){}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
public class Test {
|
||||
void foo() {
|
||||
new A() {
|
||||
void fe() {<selection>System.out.println("");</selection>}
|
||||
}
|
||||
}
|
||||
}
|
||||
class A {
|
||||
void newMethod(){}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
public class Test {
|
||||
void foo() {
|
||||
new A() {
|
||||
void fe() {
|
||||
Test.this.newMethod();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void newMethod() {
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
class A {
|
||||
void newMethod(){}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
public class ABl {
|
||||
void foo(int fe) {
|
||||
System.out.println(fe);
|
||||
}
|
||||
|
||||
void bar(boolean br) {
|
||||
int fe = 0;
|
||||
if (br) {
|
||||
foo(fe);
|
||||
} else {
|
||||
f<caret>oo(11);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
public class ABl {
|
||||
|
||||
void bar(boolean br) {
|
||||
int fe = 0;
|
||||
if (br) {
|
||||
System.out.println(fe);
|
||||
} else {
|
||||
System.out.println(11);
|
||||
}
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon.quickFix;
|
||||
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
|
||||
public class WrapExpressionFixTest extends LightQuickFixTestCase {
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_6);
|
||||
}
|
||||
|
||||
public void test() throws Exception {
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
protected String getBasePath() {
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/wrapExpression";
|
||||
}
|
||||
}
|
||||
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
package com.intellij.ide.util.frameworkSupport;
|
||||
|
||||
import com.intellij.facet.Facet;
|
||||
import com.intellij.facet.FacetManager;
|
||||
import com.intellij.facet.FacetTypeId;
|
||||
import com.intellij.facet.ui.FacetBasedFrameworkSupportProvider;
|
||||
import com.intellij.ide.util.newProjectWizard.FrameworkSupportNode;
|
||||
import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportCommunicator;
|
||||
import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelImpl;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.IdeaTestCase;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class FrameworkSupportProviderTestCase extends IdeaTestCase {
|
||||
private FrameworkSupportModelImpl myFrameworkSupportModel;
|
||||
private Map<FrameworkSupportProvider, FrameworkSupportConfigurable> myConfigurables;
|
||||
private Map<FrameworkSupportProvider, FrameworkSupportNode> myNodes;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myFrameworkSupportModel = new FrameworkSupportModelImpl(getProject(), null);
|
||||
myNodes = new HashMap<FrameworkSupportProvider, FrameworkSupportNode>();
|
||||
for (FrameworkSupportProvider provider : FrameworkSupportProvider.EXTENSION_POINT.getExtensions()) {
|
||||
final FrameworkSupportNode node = new FrameworkSupportNode(provider, null, myFrameworkSupportModel, null, getTestRootDisposable());
|
||||
myNodes.put(provider, node);
|
||||
myFrameworkSupportModel.registerComponent(provider, node);
|
||||
}
|
||||
myConfigurables = new HashMap<FrameworkSupportProvider, FrameworkSupportConfigurable>();
|
||||
}
|
||||
|
||||
protected void addSupport() throws IOException {
|
||||
final VirtualFile root = getVirtualFile(createTempDir("contentRoot"));
|
||||
PsiTestUtil.addContentRoot(myModule, root);
|
||||
final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
|
||||
try {
|
||||
List<FrameworkSupportConfigurable> selectedConfigurables = new ArrayList<FrameworkSupportConfigurable>();
|
||||
for (FrameworkSupportNode node : myNodes.values()) {
|
||||
if (node.isChecked()) {
|
||||
final FrameworkSupportConfigurable configurable = getOrCreateConfigurable(node.getProvider());
|
||||
configurable.addSupport(myModule, model, null);
|
||||
selectedConfigurables.add(configurable);
|
||||
}
|
||||
}
|
||||
for (FrameworkSupportCommunicator communicator : FrameworkSupportCommunicator.EP_NAME.getExtensions()) {
|
||||
communicator.onFrameworkSupportAdded(myModule, model, selectedConfigurables, myFrameworkSupportModel);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
model.commit();
|
||||
}
|
||||
for (FrameworkSupportConfigurable configurable : myConfigurables.values()) {
|
||||
Disposer.dispose(configurable);
|
||||
}
|
||||
}
|
||||
|
||||
protected FrameworkSupportConfigurable selectFramework(@NotNull FacetTypeId<?> id) {
|
||||
return selectFramework(FacetBasedFrameworkSupportProvider.getProviderId(id));
|
||||
}
|
||||
|
||||
protected FrameworkSupportConfigurable selectFramework(@NotNull String id) {
|
||||
for (FrameworkSupportProvider provider : FrameworkSupportProvider.EXTENSION_POINT.getExtensions()) {
|
||||
if (provider.getId().equals(id)) {
|
||||
return selectFramework(provider);
|
||||
}
|
||||
}
|
||||
fail("Framework provider with id='" + id + "' not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
protected FrameworkSupportConfigurable selectFramework(@NotNull FrameworkSupportProvider provider) {
|
||||
final FrameworkSupportConfigurable configurable = getOrCreateConfigurable(provider);
|
||||
myNodes.get(provider).setChecked(true);
|
||||
configurable.onFrameworkSelectionChanged(true);
|
||||
return configurable;
|
||||
}
|
||||
|
||||
private FrameworkSupportConfigurable getOrCreateConfigurable(FrameworkSupportProvider provider) {
|
||||
FrameworkSupportConfigurable configurable = myConfigurables.get(provider);
|
||||
if (configurable == null) {
|
||||
configurable = provider.createConfigurable(myFrameworkSupportModel);
|
||||
myConfigurables.put(provider, configurable);
|
||||
}
|
||||
return configurable;
|
||||
}
|
||||
|
||||
protected <F extends Facet> F getFacet(FacetTypeId<F> id) {
|
||||
final F facet = FacetManager.getInstance(myModule).getFacetByType(id);
|
||||
assertNotNull(id + " facet not found", facet);
|
||||
return facet;
|
||||
}
|
||||
|
||||
protected VirtualFile getContentRoot() {
|
||||
return ModuleRootManager.getInstance(myModule).getContentRoots()[0];
|
||||
}
|
||||
}
|
||||
@@ -168,6 +168,12 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testConflictingAnonymous() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testFinalParamUsedInsideAnon() throws Exception {
|
||||
CodeStyleSettingsManager.getSettings(getProject()).GENERATE_FINAL_PARAMETERS = false;
|
||||
doTest();
|
||||
|
||||
@@ -157,6 +157,10 @@ public class InlineMethodTest extends LightCodeInsightTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testParamNameConflictsWithLocalVar() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return JavaSdkImpl.getMockJdk17("java 1.5");
|
||||
|
||||
@@ -80,7 +80,7 @@ public abstract class CompletionService {
|
||||
|
||||
for (int i = contributors.indexOf(from) + 1; i < contributors.size(); i++) {
|
||||
final CompletionContributor contributor = contributors.get(i);
|
||||
if (dumb && !(contributor instanceof DumbAware)) continue;
|
||||
if (dumb && !DumbService.isDumbAware(contributor)) continue;
|
||||
|
||||
final CompletionResultSet result = createResultSet(parameters, consumer, contributor);
|
||||
contributor.fillCompletionVariants(parameters, result);
|
||||
|
||||
@@ -33,7 +33,7 @@ public class CompositeFilter implements Filter {
|
||||
public Result applyFilter(final String line, final int entireLength) {
|
||||
final boolean dumb = DumbService.getInstance(myProject).isDumb();
|
||||
for (final Filter filter : myFilters) {
|
||||
if (!dumb || filter instanceof DumbAware) {
|
||||
if (!dumb || DumbService.isDumbAware(filter)) {
|
||||
final Result info = filter.applyFilter(line, entireLength);
|
||||
if (info != null) {
|
||||
return info;
|
||||
|
||||
@@ -55,6 +55,8 @@ public class ExecutionUtil {
|
||||
String error = e.getMessage();
|
||||
HyperlinkListener listener = null;
|
||||
|
||||
LOG.debug(error);
|
||||
|
||||
if (error.contains("87") && e instanceof ProcessNotCreatedException) {
|
||||
final String commandLineString = ((ProcessNotCreatedException)e).getCommandLine().getCommandLineString();
|
||||
if (commandLineString.length() > 1024 * 32) {
|
||||
|
||||
@@ -88,7 +88,7 @@ public abstract class CreateElementActionBase extends AnAction {
|
||||
presentation.setEnabled(enabled);
|
||||
}
|
||||
|
||||
protected boolean isDumbAware() {
|
||||
public boolean isDumbAware() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public interface PsiBuilder extends UserDataHolder {
|
||||
IElementType getTokenType();
|
||||
|
||||
/**
|
||||
* Sets optional remapper that can changs the type of freshly lexed tokens.
|
||||
* Sets optional remapper that can change the type of freshly lexed tokens.
|
||||
* Output of getTokenType() is affected by it.
|
||||
* @param remapper the remapper object, or null.
|
||||
*/
|
||||
@@ -110,17 +110,25 @@ public interface PsiBuilder extends UserDataHolder {
|
||||
*/
|
||||
void done(IElementType type);
|
||||
|
||||
/**
|
||||
* Like done(), but collapses all tokens between start and end markers into single leaf node of given type.
|
||||
*
|
||||
* @param type the type of the node in the AST tree.
|
||||
*/
|
||||
void collapse(IElementType type);
|
||||
|
||||
/**
|
||||
* TODO doc
|
||||
* @param type
|
||||
* @param before
|
||||
* @param type the type of the node in the AST tree.
|
||||
* @param before marker to complete this one before.
|
||||
*/
|
||||
void doneBefore(IElementType type, Marker before);
|
||||
|
||||
/**
|
||||
* TODO doc
|
||||
* @param type
|
||||
* @param before
|
||||
* @param type the type of the node in the AST tree.
|
||||
* @param before marker to complete this one before.
|
||||
* @param errorMessage for error element.
|
||||
*/
|
||||
void doneBefore(IElementType type, Marker before, String errorMessage);
|
||||
|
||||
@@ -128,7 +136,7 @@ public interface PsiBuilder extends UserDataHolder {
|
||||
* Completes this marker and labels it as error element with specified message. Before calling this method,
|
||||
* all markers added after the beginning of this marker must be either dropped or completed.
|
||||
*
|
||||
* @param message for error element
|
||||
* @param message for error element.
|
||||
*/
|
||||
void error(String message);
|
||||
}
|
||||
@@ -162,7 +170,7 @@ public interface PsiBuilder extends UserDataHolder {
|
||||
ASTNode getTreeBuilt();
|
||||
|
||||
/**
|
||||
* Same as {@link #getTreeBuilt()} but returns a light tree, which is build faster, produces less garbage but is uncapable of creating a PSI over.
|
||||
* Same as {@link #getTreeBuilt()} but returns a light tree, which is build faster, produces less garbage but is incapable of creating a PSI over.
|
||||
* @return the light tree built.
|
||||
*/
|
||||
FlyweightCapableTreeStructure<LighterASTNode> getLightTree();
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.util.Set;
|
||||
*
|
||||
* @author max
|
||||
* @see FoldingBuilder
|
||||
*/
|
||||
*/
|
||||
public class FoldingDescriptor {
|
||||
public static final FoldingDescriptor[] EMPTY = new FoldingDescriptor[0];
|
||||
|
||||
@@ -86,7 +86,7 @@ public class FoldingDescriptor {
|
||||
/**
|
||||
* @return the node to which the folding region is related.
|
||||
*/
|
||||
@NotNull
|
||||
@NotNull
|
||||
public ASTNode getElement() {
|
||||
return myElement;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class FoldingDescriptor {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public Set<Object> getDependencies() {
|
||||
return myDependencies;
|
||||
|
||||
@@ -63,7 +63,7 @@ public class LanguageFolding extends LanguageExtension<FoldingBuilder> {
|
||||
}
|
||||
|
||||
public static FoldingDescriptor[] buildFoldingDescriptors(FoldingBuilder builder, PsiElement root, Document document, boolean quick) {
|
||||
if (!(builder instanceof DumbAware) && DumbService.getInstance(root.getProject()).isDumb()) {
|
||||
if (!DumbService.isDumbAware(builder) && DumbService.getInstance(root.getProject()).isDumb()) {
|
||||
return FoldingDescriptor.EMPTY;
|
||||
}
|
||||
|
||||
|
||||
@@ -118,10 +118,14 @@ public interface PsiElementProcessor<T extends PsiElement> {
|
||||
return myFoundElement;
|
||||
}
|
||||
|
||||
public boolean execute(T element) {
|
||||
public boolean setFound(T element) {
|
||||
myFoundElement = element;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean execute(T element) {
|
||||
return setFound(element);
|
||||
}
|
||||
}
|
||||
|
||||
class FindFilteredElement<T extends PsiElement> extends FindElement<T> {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class PsiIconUtil {
|
||||
public static Icon getProvidersIcon(PsiElement element, int flags) {
|
||||
final boolean dumb = DumbService.getInstance(element.getProject()).isDumb();
|
||||
for (final IconProvider iconProvider : getIconProviders()) {
|
||||
if (dumb && !(iconProvider instanceof DumbAware)) {
|
||||
if (dumb && !DumbService.isDumbAware(iconProvider)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ public abstract class TextEditorHighlightingPass implements HighlightingPass {
|
||||
}
|
||||
|
||||
private boolean isValid() {
|
||||
if (isDumbMode() && !(this instanceof DumbAware)) {
|
||||
if (isDumbMode() && !DumbService.isDumbAware(this)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -148,7 +148,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
result.setResult(initializationContext);
|
||||
|
||||
for (final CompletionContributor contributor : CompletionContributor.forLanguage(PsiUtilBase.getLanguageInEditor(editor, project))) {
|
||||
if (DumbService.getInstance(project).isDumb() && !(contributor instanceof DumbAware)) {
|
||||
if (DumbService.getInstance(project).isDumb() && !DumbService.isDumbAware(contributor)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -18,11 +18,12 @@ package com.intellij.codeInsight.completion.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
|
||||
public class CodeCompletionGroup extends DefaultActionGroup {
|
||||
public class CodeCompletionGroup extends DefaultActionGroup implements DumbAware {
|
||||
|
||||
public void update(AnActionEvent event){
|
||||
Presentation presentation = event.getPresentation();
|
||||
|
||||
+2
-2
@@ -111,7 +111,7 @@ public abstract class PassExecutorService implements Disposable {
|
||||
|
||||
for (int i = 0; i < passes.length; i++) {
|
||||
final HighlightingPass pass = passes[i];
|
||||
if (dumb && !(pass instanceof DumbAware)) {
|
||||
if (dumb && !DumbService.isDumbAware(pass)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ public abstract class PassExecutorService implements Disposable {
|
||||
boolean success = ApplicationManagerEx.getApplicationEx().tryRunReadAction(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
if (DumbService.getInstance(myProject).isDumb() && !(myPass instanceof DumbAware)) {
|
||||
if (DumbService.getInstance(myProject).isDumb() && !DumbService.isDumbAware(myPass)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -127,7 +127,7 @@ public class DefaultHighlightVisitor implements HighlightVisitor, DumbAware {
|
||||
|
||||
JobUtil.invokeConcurrentlyUnderMyProgress(annotators, new Processor<Annotator>() {
|
||||
public boolean process(Annotator annotator) {
|
||||
if (dumb && !(annotator instanceof DumbAware)) {
|
||||
if (dumb && !DumbService.isDumbAware(annotator)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -162,8 +162,11 @@ public class BackspaceHandler extends EditorWriteActionHandler {
|
||||
|
||||
final CharSequence charSeq = editor.getDocument().getCharsSequence();
|
||||
// smart backspace is activated only if all characters in the check range are whitespace characters
|
||||
for(int pos=startCheckRange; pos<endCheckRange; pos++) {
|
||||
final char c = charSeq.charAt(pos);
|
||||
for(int pos=0; pos<caretPos.column; pos++) {
|
||||
// use logicalPositionToOffset to make sure tabs are handled correctly
|
||||
final LogicalPosition checkPos = new LogicalPosition(caretPos.line, pos);
|
||||
final int offset = editor.logicalPositionToOffset(checkPos);
|
||||
final char c = charSeq.charAt(offset);
|
||||
if (c != '\t' && c != ' ' && c != '\n') {
|
||||
return null;
|
||||
}
|
||||
@@ -177,5 +180,4 @@ public class BackspaceHandler extends EditorWriteActionHandler {
|
||||
}
|
||||
return new LogicalPosition(caretPos.line, column);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-1
@@ -19,8 +19,9 @@ package com.intellij.codeInsight.folding.impl.actions;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ex.FoldingModelEx;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
|
||||
public class FoldingActionGroup extends DefaultActionGroup {
|
||||
public class FoldingActionGroup extends DefaultActionGroup implements DumbAware {
|
||||
public FoldingActionGroup() {
|
||||
super();
|
||||
}
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ public abstract class UnresolvedReferenceQuickFixProvider<T extends PsiReference
|
||||
UnresolvedReferenceQuickFixProvider[] fixProviders = Extensions.getExtensions(EXTENSION_NAME);
|
||||
Class<? extends PsiReference> referenceClass = ref.getClass();
|
||||
for (UnresolvedReferenceQuickFixProvider each : fixProviders) {
|
||||
if (dumb && !(each instanceof DumbAware)) {
|
||||
if (dumb && !DumbService.isDumbAware(each)) {
|
||||
continue;
|
||||
}
|
||||
if (ReflectionCache.isAssignable(each.getReferenceClass(), referenceClass)) {
|
||||
|
||||
+1
-6
@@ -178,12 +178,7 @@ public abstract class BaseRunConfigurationAction extends ActionGroup {
|
||||
final RunnerAndConfigurationSettings existing = context.findExisting();
|
||||
RunnerAndConfigurationSettings configuration = existing;
|
||||
if (configuration == null) {
|
||||
try {
|
||||
configuration = context.getConfiguration();
|
||||
}
|
||||
catch (IndexNotReadyException e) {
|
||||
configuration = null;
|
||||
}
|
||||
configuration = context.getConfiguration();
|
||||
}
|
||||
if (configuration == null){
|
||||
presentation.setEnabled(false);
|
||||
|
||||
@@ -197,7 +197,7 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
|
||||
|
||||
myHistoryViewer.getContentComponent().addKeyListener(new KeyAdapter() {
|
||||
public void keyTyped(KeyEvent event) {
|
||||
if (UIUtil.isReallyTypedEvent(event)) {
|
||||
if (myFullEditor == null && UIUtil.isReallyTypedEvent(event)) {
|
||||
myConsoleEditor.getContentComponent().requestFocus();
|
||||
myConsoleEditor.processKeyTyped(event);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class CreateFileAction extends CreateElementActionBase implements DumbAwa
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isDumbAware() {
|
||||
public boolean isDumbAware() {
|
||||
return CreateFileAction.class.equals(getClass());
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,11 @@ public class ExcludingActionGroup extends ActionGroup {
|
||||
myDelegate.update(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDumbAware() {
|
||||
return myDelegate.isDumbAware();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public AnAction[] getChildren(@Nullable AnActionEvent e) {
|
||||
List<AnAction> result = new ArrayList<AnAction>();
|
||||
|
||||
+2
-1
@@ -27,13 +27,14 @@ import com.intellij.ide.fileTemplates.ui.SelectTemplateDialog;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CreateFromTemplateGroup extends ActionGroup{
|
||||
public class CreateFromTemplateGroup extends ActionGroup implements DumbAware {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.fileTemplates.actions.CreateFromTemplateGroup");
|
||||
|
||||
public void update(AnActionEvent event){
|
||||
|
||||
+1
-1
@@ -87,7 +87,7 @@ public abstract class ContributorsBasedGotoByModel implements ChooseByNameModel
|
||||
|
||||
for (ChooseByNameContributor contributor : myContributors) {
|
||||
try {
|
||||
if (dumb && !(contributor instanceof DumbAware)) {
|
||||
if (dumb && !DumbService.isDumbAware(contributor)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -277,6 +277,11 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
myBuilder.done(this);
|
||||
}
|
||||
|
||||
public void collapse(IElementType type) {
|
||||
myType = type;
|
||||
myBuilder.collapse(this);
|
||||
}
|
||||
|
||||
public void doneBefore(IElementType type, Marker before) {
|
||||
myType = type;
|
||||
myBuilder.doneBefore(this, before);
|
||||
@@ -373,6 +378,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
|
||||
private static class DoneMarker extends ProductionMarker {
|
||||
public StartMarker myStart;
|
||||
public boolean myCollapse = false;
|
||||
|
||||
public DoneMarker() {}
|
||||
|
||||
@@ -470,6 +476,8 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
}
|
||||
|
||||
public void advanceLexer() {
|
||||
if (eof()) return;
|
||||
|
||||
if (!myTokenTypeChecked) {
|
||||
LOG.assertTrue(eof(), "Probably a bug: eating token without its type checking");
|
||||
}
|
||||
@@ -593,10 +601,9 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
myProduction.add(doneMarker);
|
||||
}
|
||||
|
||||
public void done(Marker marker) {
|
||||
public void done(final Marker marker) {
|
||||
doValidityChecks(marker);
|
||||
|
||||
|
||||
DoneMarker doneMarker = DONE_MARKERS.alloc();
|
||||
doneMarker.myStart = (StartMarker)marker;
|
||||
doneMarker.myLexemeIndex = myCurrentLexeme;
|
||||
@@ -605,6 +612,11 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
myProduction.add(doneMarker);
|
||||
}
|
||||
|
||||
public void collapse(final Marker marker) {
|
||||
done(marker);
|
||||
((StartMarker)marker).myDoneMarker.myCollapse = true;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UseOfSystemOutOrSystemErr", "SuspiciousMethodCalls"})
|
||||
private void doValidityChecks(final Marker marker) {
|
||||
if (myDebugMode) {
|
||||
@@ -828,9 +840,14 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
|
||||
lexIndex = insertLeafs(lexIndex, childMarker.myLexemeIndex, ast);
|
||||
|
||||
CompositeElement childNode = createComposite(childMarker);
|
||||
ast.rawAddChildren(childNode);
|
||||
lexIndex = bind(childNode, childMarker, lexIndex);
|
||||
if (!childMarker.myDoneMarker.myCollapse) {
|
||||
CompositeElement childNode = createComposite(childMarker);
|
||||
ast.rawAddChildren(childNode);
|
||||
lexIndex = bind(childNode, childMarker, lexIndex);
|
||||
}
|
||||
else {
|
||||
lexIndex = collapseLeafs(ast, childMarker);
|
||||
}
|
||||
|
||||
lexIndex = insertLeafs(lexIndex, childMarker.myDoneMarker.myLexemeIndex, ast);
|
||||
}
|
||||
@@ -863,6 +880,14 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
return curToken;
|
||||
}
|
||||
|
||||
private int collapseLeafs(CompositeElement ast, StartMarker startMarker) {
|
||||
final int start = myLexStarts[startMarker.myLexemeIndex];
|
||||
final int end = myLexStarts[startMarker.myDoneMarker.myLexemeIndex];
|
||||
final TreeElement leaf = createLeaf(startMarker.myType, start, end);
|
||||
ast.rawAddChildren(leaf);
|
||||
return startMarker.myDoneMarker.myLexemeIndex;
|
||||
}
|
||||
|
||||
private static CompositeElement createComposite(final StartMarker marker) {
|
||||
final IElementType type = marker.myType;
|
||||
if (type == TokenType.ERROR_ELEMENT) {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.intellij.psi;
|
||||
|
||||
/**
|
||||
* Can be implemented by {@link com.intellij.psi.PsiReference}
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public interface ResolvingHint {
|
||||
|
||||
+1
-1
@@ -307,7 +307,7 @@ public class InjectedLanguageManagerImpl extends InjectedLanguageManager {
|
||||
MultiHostInjector[] infos = cachedInjectors.get(element.getClass());
|
||||
if (infos != null) {
|
||||
for (MultiHostInjector injector : infos) {
|
||||
if (dumb && !(injector instanceof DumbAware)) {
|
||||
if (dumb && !DumbService.isDumbAware(injector)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
+2
-10
@@ -80,20 +80,12 @@ public class CopyFilesOrDirectoriesHandler implements CopyHandlerDelegate {
|
||||
dialog.show();
|
||||
if (dialog.isOK()) {
|
||||
final String newName = elements.length == 1 ? dialog.getNewName() : null;
|
||||
final PsiManager psiManager = PsiManager.getInstance(project);
|
||||
final PsiDirectory targetDirectory = dialog.getTargetDirectory();
|
||||
try {
|
||||
for (PsiElement element : elements) {
|
||||
PsiFileSystemItem psiElement = (PsiFileSystemItem)element;
|
||||
if (newName != null) {
|
||||
if (!psiElement.isDirectory()) {
|
||||
psiElement = (PsiFileSystemItem)psiElement.copy();
|
||||
psiElement.setName(newName);
|
||||
psiManager.checkMove(psiElement, targetDirectory);
|
||||
} else {
|
||||
targetDirectory.checkCreateSubdirectory(newName);
|
||||
MoveFilesOrDirectoriesUtil.checkIfMoveIntoSelf(psiElement, targetDirectory);
|
||||
}
|
||||
if (psiElement.isDirectory()) {
|
||||
MoveFilesOrDirectoriesUtil.checkIfMoveIntoSelf(psiElement, targetDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-4
@@ -67,7 +67,9 @@ public class VariableInplaceRenameHandler implements RenameHandler {
|
||||
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file, final DataContext dataContext) {
|
||||
PsiElement element = PsiElementRenameHandler.getElement(dataContext);
|
||||
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
|
||||
doRename(element, editor, dataContext);
|
||||
if (checkAvailable(element, editor, dataContext)) {
|
||||
doRename(element, editor, dataContext);
|
||||
}
|
||||
}
|
||||
|
||||
public void invoke(@NotNull final Project project, @NotNull final PsiElement[] elements, final DataContext dataContext) {
|
||||
@@ -75,10 +77,12 @@ public class VariableInplaceRenameHandler implements RenameHandler {
|
||||
if (element == null) element = PsiElementRenameHandler.getElement(dataContext);
|
||||
LOG.assertTrue(element != null);
|
||||
Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
|
||||
doRename(element, editor, dataContext);
|
||||
if (checkAvailable(element, editor, dataContext)) {
|
||||
doRename(element, editor, dataContext);
|
||||
}
|
||||
}
|
||||
|
||||
private void doRename(final PsiElement elementToRename, final Editor editor, final DataContext dataContext) {
|
||||
boolean checkAvailable(final PsiElement elementToRename, final Editor editor, final DataContext dataContext) {
|
||||
if (!isAvailableOnDataContext(dataContext)) {
|
||||
LOG.error("Recursive invocation");
|
||||
RenameHandlerRegistry.getInstance().getRenameHandler(dataContext).invoke(
|
||||
@@ -86,8 +90,13 @@ public class VariableInplaceRenameHandler implements RenameHandler {
|
||||
editor,
|
||||
elementToRename.getContainingFile(), dataContext
|
||||
);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public VariableInplaceRenamer doRename(final PsiElement elementToRename, final Editor editor, final DataContext dataContext) {
|
||||
|
||||
VariableInplaceRenamer renamer = createRenamer(elementToRename, editor);
|
||||
boolean startedRename = renamer == null ? false : renamer.performInplaceRename();
|
||||
@@ -107,6 +116,7 @@ public class VariableInplaceRenameHandler implements RenameHandler {
|
||||
ourPreventInlineRenameFlag.set(null);
|
||||
}
|
||||
}
|
||||
return renamer;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+6
-4
@@ -162,12 +162,13 @@ public class VariableInplaceRenamer {
|
||||
final TemplateBuilderImpl builder = new TemplateBuilderImpl(scope);
|
||||
|
||||
PsiElement nameIdentifier = myElementToRename instanceof PsiNameIdentifierOwner ? ((PsiNameIdentifierOwner)myElementToRename).getNameIdentifier() : null;
|
||||
PsiElement selectedElement = getSelectedInEditorElement(nameIdentifier, refs, myEditor.getCaretModel().getOffset());
|
||||
int offset = myEditor.getCaretModel().getOffset();
|
||||
PsiElement selectedElement = getSelectedInEditorElement(nameIdentifier, refs, offset);
|
||||
if (!CommonRefactoringUtil.checkReadOnlyStatus(myProject, myElementToRename)) return true;
|
||||
|
||||
if (nameIdentifier != null) addVariable(nameIdentifier, selectedElement, builder);
|
||||
for (PsiReference ref : refs) {
|
||||
addVariable(ref, selectedElement, builder);
|
||||
addVariable(ref, selectedElement, builder, offset);
|
||||
}
|
||||
|
||||
final PsiElement scope1 = scope;
|
||||
@@ -379,8 +380,9 @@ public class VariableInplaceRenamer {
|
||||
return range.getStartOffset() <= offset && offset <= range.getEndOffset();
|
||||
}
|
||||
|
||||
private void addVariable(final PsiReference reference, final PsiElement selectedElement, final TemplateBuilderImpl builder) {
|
||||
if (reference.getElement() == selectedElement) {
|
||||
private void addVariable(final PsiReference reference, final PsiElement selectedElement, final TemplateBuilderImpl builder, int offset) {
|
||||
if (reference.getElement() == selectedElement &&
|
||||
contains(reference.getRangeInElement().shiftRight(selectedElement.getTextRange().getStartOffset()), offset)) {
|
||||
Expression expression = new MyExpression(myElementToRename.getName());
|
||||
builder.replaceElement(reference, PRIMARY_VARIABLE_NAME, expression, true);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author: msk
|
||||
@@ -107,11 +109,19 @@ public abstract class RefactoringDialog extends DialogWrapper {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean hasPreviewButton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected Action[] createActions() {
|
||||
List<Action> actions = new ArrayList<Action>();
|
||||
actions.add(getRefactorAction());
|
||||
if(hasPreviewButton()) actions.add(getPreviewAction());
|
||||
actions.add(getCancelAction());
|
||||
|
||||
if (hasHelpAction ())
|
||||
return new Action[]{getRefactorAction(), getPreviewAction(), getCancelAction(), getHelpAction()};
|
||||
else
|
||||
return new Action[]{getRefactorAction(), getPreviewAction(), getCancelAction()};
|
||||
actions.add(getHelpAction());
|
||||
return actions.toArray(new Action[actions.size()]);
|
||||
}
|
||||
|
||||
protected Project getProject() {
|
||||
|
||||
@@ -17,12 +17,13 @@
|
||||
package com.intellij.tools;
|
||||
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
/**
|
||||
* @author Eugene Belyaev
|
||||
*/
|
||||
public class ExternalToolsGroup extends SimpleActionGroup {
|
||||
public class ExternalToolsGroup extends SimpleActionGroup implements DumbAware {
|
||||
public void update(AnActionEvent event){
|
||||
Presentation presentation = event.getPresentation();
|
||||
removeAll();
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.lang.impl.PsiBuilderImpl;
|
||||
import com.intellij.lexer.LexerBase;
|
||||
import com.intellij.psi.impl.DebugUtil;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
||||
public class LightPsiBuilderTest {
|
||||
|
||||
@Test
|
||||
public void testPlain() {
|
||||
doTest(
|
||||
"a<<b",
|
||||
new PsiParser() {
|
||||
@NotNull
|
||||
public ASTNode parse(IElementType root, PsiBuilder builder) {
|
||||
final PsiBuilder.Marker rootMarker = builder.mark();
|
||||
while (builder.getTokenType() != null) {
|
||||
builder.advanceLexer();
|
||||
}
|
||||
rootMarker.done(root);
|
||||
return builder.getTreeBuilt();
|
||||
}
|
||||
},
|
||||
"Element(ROOT)\n" +
|
||||
" PsiElement(TOKEN)('a')\n" +
|
||||
" PsiElement(TOKEN)('<')\n" +
|
||||
" PsiElement(TOKEN)('<')\n" +
|
||||
" PsiElement(TOKEN)('b')\n"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCollapse() {
|
||||
doTest(
|
||||
"a<<b",
|
||||
new PsiParser() {
|
||||
@NotNull
|
||||
public ASTNode parse(IElementType root, PsiBuilder builder) {
|
||||
final PsiBuilder.Marker rootMarker = builder.mark();
|
||||
PsiBuilder.Marker inner = null;
|
||||
while (builder.getTokenType() != null) {
|
||||
if ("<".equals(builder.getTokenText()) && inner == null) inner = builder.mark();
|
||||
builder.advanceLexer();
|
||||
if (!"<".equals(builder.getTokenText()) && inner != null) { inner.collapse(new IElementType("COLLAPSE", Language.ANY)); inner = null; }
|
||||
}
|
||||
rootMarker.done(root);
|
||||
return builder.getTreeBuilt();
|
||||
}
|
||||
},
|
||||
"Element(ROOT)\n" +
|
||||
" PsiElement(TOKEN)('a')\n" +
|
||||
" PsiElement(COLLAPSE)('<<')\n" +
|
||||
" PsiElement(TOKEN)('b')\n"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private static void doTest(final String text, final PsiParser parser, final String expected) {
|
||||
final PsiBuilder builder = new PsiBuilderImpl(new MyTestLexer(), TokenSet.EMPTY, TokenSet.EMPTY, text);
|
||||
final ASTNode root = parser.parse(new IElementType("ROOT", Language.ANY), builder);
|
||||
assertEquals(expected, DebugUtil.nodeTreeToString(root, true));
|
||||
}
|
||||
|
||||
private static class MyTestLexer extends LexerBase {
|
||||
public static IElementType TOKEN = new IElementType("TOKEN", Language.ANY);
|
||||
|
||||
private CharSequence myBuffer = "";
|
||||
private int myIndex = 0;
|
||||
private int myBufferEnd = 1;
|
||||
|
||||
public void start(CharSequence buffer, int startOffset, int endOffset, int initialState) {
|
||||
myBuffer = buffer.subSequence(startOffset, endOffset);
|
||||
myIndex = 0;
|
||||
myBufferEnd = myBuffer.length();
|
||||
}
|
||||
|
||||
public int getState() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public IElementType getTokenType() {
|
||||
return myIndex < myBufferEnd ? TOKEN : null;
|
||||
}
|
||||
|
||||
public int getTokenStart() {
|
||||
return myIndex;
|
||||
}
|
||||
|
||||
public int getTokenEnd() {
|
||||
return myIndex + 1;
|
||||
}
|
||||
|
||||
public void advance() {
|
||||
if (myIndex < myBufferEnd) myIndex++;
|
||||
}
|
||||
|
||||
public CharSequence getBufferSequence() {
|
||||
return myBuffer;
|
||||
}
|
||||
|
||||
public int getBufferEnd() {
|
||||
return myBufferEnd;
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -20,8 +20,9 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
|
||||
public class LocalHistoryGroup extends DefaultActionGroup {
|
||||
public class LocalHistoryGroup extends DefaultActionGroup implements DumbAware {
|
||||
public void update(AnActionEvent event) {
|
||||
Presentation p = event.getPresentation();
|
||||
boolean hasProject = event.getData(PlatformDataKeys.PROJECT) != null;
|
||||
|
||||
@@ -20,8 +20,6 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingManager;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
@@ -29,7 +27,6 @@ import java.util.concurrent.*;
|
||||
|
||||
public class OSProcessHandler extends ProcessHandler {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.execution.process.OSProcessHandler");
|
||||
private static final ReaderThread ourReaderThread;
|
||||
private final Process myProcess;
|
||||
private final String myCommandLine;
|
||||
|
||||
@@ -48,14 +45,6 @@ public class OSProcessHandler extends ProcessHandler {
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
ourReaderThread = new ReaderThread();
|
||||
ourReaderThread.setDaemon(true);
|
||||
ourReaderThread.setName("OSProcessHandler streams reader");
|
||||
ourReaderThread.start();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Override this method in order to execute the task with a custom pool
|
||||
*
|
||||
@@ -75,6 +64,13 @@ public class OSProcessHandler extends ProcessHandler {
|
||||
return ExecutorServiceHolder.ourThreadExecutorsService.submit(task);
|
||||
}
|
||||
|
||||
protected static void shutdownExecutorService() {
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
if (application == null) {
|
||||
ExecutorServiceHolder.ourThreadExecutorsService.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public OSProcessHandler(final Process process, final String commandLine) {
|
||||
myProcess = process;
|
||||
myCommandLine = commandLine;
|
||||
@@ -121,13 +117,13 @@ public class OSProcessHandler extends ProcessHandler {
|
||||
}
|
||||
|
||||
public void startNotify() {
|
||||
final ReadProcessRequest stdoutThread = new ReadProcessRequest(createProcessOutReader()) {
|
||||
final ReadProcessThread stdoutThread = new ReadProcessThread(createProcessOutReader()) {
|
||||
protected void textAvailable(String s) {
|
||||
notifyTextAvailable(s, ProcessOutputTypes.STDOUT);
|
||||
}
|
||||
};
|
||||
|
||||
final ReadProcessRequest stderrThread = new ReadProcessRequest(createProcessErrReader()) {
|
||||
final ReadProcessThread stderrThread = new ReadProcessThread(createProcessErrReader()) {
|
||||
protected void textAvailable(String s) {
|
||||
notifyTextAvailable(s, ProcessOutputTypes.STDERR);
|
||||
}
|
||||
@@ -138,8 +134,8 @@ public class OSProcessHandler extends ProcessHandler {
|
||||
addProcessListener(new ProcessAdapter() {
|
||||
public void startNotified(final ProcessEvent event) {
|
||||
try {
|
||||
final Semaphore outSemaphore = stdoutThread.schedule();
|
||||
final Semaphore errSemaphore = stderrThread.schedule();
|
||||
final Future<?> stdOutReadingFuture = executeOnPooledThread(stdoutThread);
|
||||
final Future<?> stdErrReadingFuture = executeOnPooledThread(stderrThread);
|
||||
|
||||
myWaitFor.setTerminationCallback(new Consumer<Integer>() {
|
||||
@Override
|
||||
@@ -149,8 +145,13 @@ public class OSProcessHandler extends ProcessHandler {
|
||||
stderrThread.setProcessTerminated(true);
|
||||
stdoutThread.setProcessTerminated(true);
|
||||
|
||||
outSemaphore.waitFor();
|
||||
errSemaphore.waitFor();
|
||||
stdErrReadingFuture.get();
|
||||
stdOutReadingFuture.get();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
finally {
|
||||
onOSProcessTerminated(exitCode);
|
||||
@@ -228,56 +229,38 @@ public class OSProcessHandler extends ProcessHandler {
|
||||
return EncodingManager.getInstance().getDefaultCharset();
|
||||
}
|
||||
|
||||
private abstract class ReadProcessRequest {
|
||||
private abstract static class ReadProcessThread implements Runnable {
|
||||
private final Reader myReader;
|
||||
private boolean skipLF = false;
|
||||
|
||||
private boolean myIsClosed = false;
|
||||
private volatile boolean myIsProcessTerminated = false;
|
||||
private final Semaphore mySemaphore = new Semaphore();
|
||||
private final BlockingQueue<String> myNotificationQueue = new LinkedBlockingQueue<String>();
|
||||
private boolean myIsProcessTerminated = false;
|
||||
private final char[] myBuffer = new char[8192];
|
||||
|
||||
public ReadProcessRequest(final Reader reader) {
|
||||
public ReadProcessThread(final Reader reader) {
|
||||
myReader = reader;
|
||||
}
|
||||
|
||||
public boolean isProcessTerminated() {
|
||||
return myIsProcessTerminated;
|
||||
}
|
||||
|
||||
public void setProcessTerminated(boolean isProcessTerminated) {
|
||||
public synchronized void setProcessTerminated(boolean isProcessTerminated) {
|
||||
myIsProcessTerminated = isProcessTerminated;
|
||||
}
|
||||
|
||||
public Semaphore schedule() {
|
||||
ourReaderThread.addRequest(this);
|
||||
|
||||
executeOnPooledThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
public void run() {
|
||||
try {
|
||||
while (readAvailable()) {
|
||||
try {
|
||||
while (true) {
|
||||
final String token = myNotificationQueue.take();
|
||||
if (token.isEmpty()) break;
|
||||
textAvailable(token);
|
||||
}
|
||||
Thread.sleep(50L);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
// Ignore
|
||||
}
|
||||
finally {
|
||||
mySemaphore.up();
|
||||
catch (InterruptedException ignore) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mySemaphore.down();
|
||||
return mySemaphore;
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void readAvailable(char[] buffer) throws IOException {
|
||||
int fairCount = 0;
|
||||
boolean checkForTermination = true;
|
||||
private synchronized boolean readAvailable() throws IOException {
|
||||
char[] buffer = myBuffer;
|
||||
StringBuilder token = new StringBuilder();
|
||||
while (myReader.ready()) {
|
||||
int n = myReader.read(buffer);
|
||||
@@ -298,98 +281,31 @@ public class OSProcessHandler extends ProcessHandler {
|
||||
}
|
||||
|
||||
if (c == '\n') {
|
||||
myNotificationQueue.offer(token.toString());
|
||||
textAvailable(token.toString());
|
||||
token.setLength(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (++fairCount > 10) {
|
||||
checkForTermination = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (token.length() != 0) {
|
||||
myNotificationQueue.offer(token.toString());
|
||||
textAvailable(token.toString());
|
||||
token.setLength(0);
|
||||
}
|
||||
|
||||
if (checkForTermination && isProcessTerminated()) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
if (myIsProcessTerminated) {
|
||||
try {
|
||||
myReader.close();
|
||||
}
|
||||
catch (IOException e1) {
|
||||
// supressed
|
||||
}
|
||||
|
||||
private void close() {
|
||||
LOG.assertTrue(!myIsClosed);
|
||||
myIsClosed = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
myReader.close();
|
||||
}
|
||||
catch (IOException e1) {
|
||||
// supressed
|
||||
}
|
||||
finally {
|
||||
myNotificationQueue.offer("");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected abstract void textAvailable(final String s);
|
||||
|
||||
private boolean isClosed() {
|
||||
return myIsClosed;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ReaderThread extends Thread {
|
||||
private final BlockingQueue<ReadProcessRequest> queue = new LinkedBlockingQueue<ReadProcessRequest>();
|
||||
private final char[] myBuffer = new char[8192];
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
ReadProcessRequest request = takeRequest();
|
||||
if (request == null) return;
|
||||
|
||||
processRequest(request);
|
||||
if (!request.isClosed()) addRequest(request);
|
||||
|
||||
//noinspection UnusedAssignment
|
||||
request = null; //leak?
|
||||
|
||||
try {
|
||||
Thread.sleep(1L);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void processRequest(ReadProcessRequest request) {
|
||||
try {
|
||||
request.readAvailable(myBuffer);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ReadProcessRequest takeRequest() {
|
||||
try {
|
||||
return queue.take();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void addRequest(ReadProcessRequest request) {
|
||||
queue.offer(request);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,14 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Represents a group of actions.
|
||||
*/
|
||||
public abstract class ActionGroup extends AnAction implements DumbAware {
|
||||
public abstract class ActionGroup extends AnAction {
|
||||
private boolean myPopup;
|
||||
private final PropertyChangeSupport myChangeSupport = new PropertyChangeSupport(this);
|
||||
public static final ActionGroup EMPTY_GROUP = new ActionGroup() {
|
||||
@@ -47,6 +48,8 @@ public abstract class ActionGroup extends AnAction implements DumbAware {
|
||||
*/
|
||||
@NonNls public static final String PROP_POPUP = "popup";
|
||||
|
||||
private Boolean myDumbAware;
|
||||
|
||||
/**
|
||||
* Creates a new <code>ActionGroup</code> with shortName set to <code>null</code> and
|
||||
* popup set to false.
|
||||
@@ -79,6 +82,11 @@ public abstract class ActionGroup extends AnAction implements DumbAware {
|
||||
public void actionPerformed(AnActionEvent e){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
super.update(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if {@link #actionPerformed(AnActionEvent)} should be called
|
||||
*/
|
||||
@@ -152,4 +160,28 @@ public abstract class ActionGroup extends AnAction implements DumbAware {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDumbAware() {
|
||||
if (myDumbAware != null) {
|
||||
return myDumbAware;
|
||||
}
|
||||
|
||||
boolean dumbAware = super.isDumbAware();
|
||||
if (dumbAware) {
|
||||
myDumbAware = Boolean.valueOf(dumbAware);
|
||||
} else {
|
||||
if (myDumbAware == null) {
|
||||
try {
|
||||
Method updateMethod = getClass().getMethod("update", AnActionEvent.class);
|
||||
myDumbAware = updateMethod.getDeclaringClass().equals(AnAction.class);
|
||||
}
|
||||
catch (NoSuchMethodException e) {
|
||||
myDumbAware = Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return myDumbAware;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.openapi.actionSystem;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -298,4 +299,8 @@ public abstract class AnAction {
|
||||
public void setTransparentUpdate(boolean transparentUpdate) {
|
||||
myTransparentUpdate = transparentUpdate;
|
||||
}
|
||||
|
||||
public boolean isDumbAware() {
|
||||
return this instanceof DumbAware;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public abstract class AsyncUpdateAction<T> extends AnAction {
|
||||
public final void update(AnActionEvent e) {
|
||||
final T data = prepareDataFromContext(e);
|
||||
final Presentation originalPresentation = e.getPresentation();
|
||||
if (!forceSyncUpdate(e) && this instanceof DumbAware) {
|
||||
if (!forceSyncUpdate(e) && isDumbAware()) {
|
||||
final Presentation realPresentation = (Presentation)originalPresentation.clone();
|
||||
ourUpdaterService.submit(new Runnable() {
|
||||
public void run() {
|
||||
|
||||
@@ -88,7 +88,7 @@ public class ActionUtil {
|
||||
}
|
||||
final boolean enabledBeforeUpdate = presentation.isEnabled();
|
||||
|
||||
final boolean notAllowed = dumbMode && !(action instanceof DumbAware) && !(action instanceof ActionGroup);
|
||||
final boolean notAllowed = dumbMode && !action.isDumbAware();
|
||||
|
||||
try {
|
||||
if (beforeActionPerformed) {
|
||||
@@ -122,7 +122,7 @@ public class ActionUtil {
|
||||
performDumbAwareUpdate(action, e, true);
|
||||
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
|
||||
if (project != null && DumbService.getInstance(project).isDumb() && !(action instanceof DumbAware)) {
|
||||
if (project != null && DumbService.getInstance(project).isDumb() && !action.isDumbAware()) {
|
||||
if (Boolean.FALSE.equals(e.getPresentation().getClientProperty(WOULD_BE_ENABLED_IF_NOT_DUMB_MODE))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.openapi.project;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
@@ -91,7 +92,7 @@ public abstract class DumbService {
|
||||
if (isDumb()) {
|
||||
final ArrayList<T> result = new ArrayList<T>(collection);
|
||||
for (Iterator<T> iterator = result.iterator(); iterator.hasNext();) {
|
||||
if (!(iterator.next() instanceof DumbAware)) {
|
||||
if (!isDumbAware(iterator.next())) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
@@ -139,6 +140,14 @@ public abstract class DumbService {
|
||||
|
||||
public abstract Project getProject();
|
||||
|
||||
public static boolean isDumbAware(Object o) {
|
||||
if (o instanceof AnAction) {
|
||||
return ((AnAction)o).isDumbAware();
|
||||
} else {
|
||||
return o instanceof DumbAware;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #DUMB_MODE
|
||||
*/
|
||||
|
||||
@@ -581,7 +581,14 @@ public class Messages {
|
||||
if (messageComponent.getCaret() != null) {
|
||||
messageComponent.setCaretPosition(0);
|
||||
}
|
||||
messageComponent.setBackground(UIUtil.getOptionPaneBackground());
|
||||
|
||||
if (UIUtil.isUnderNimbusLookAndFeel()) {
|
||||
messageComponent.setOpaque(false);
|
||||
messageComponent.setBackground(new Color(0, 0, 0, 0));
|
||||
} else {
|
||||
messageComponent.setBackground(UIUtil.getOptionPaneBackground());
|
||||
}
|
||||
|
||||
messageComponent.setForeground(label.getForeground());
|
||||
|
||||
final Dimension screenSize = messageComponent.getToolkit().getScreenSize();
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.util.AsyncResult;
|
||||
@@ -105,7 +106,7 @@ public class QuickActionManager implements ProjectComponent {
|
||||
|
||||
}
|
||||
|
||||
private class Group extends DefaultActionGroup {
|
||||
private class Group extends DefaultActionGroup implements DumbAware {
|
||||
private String myTitle;
|
||||
|
||||
private Group(List<AnAction> actions, String title) {
|
||||
|
||||
@@ -117,7 +117,7 @@ public class IconUtil {
|
||||
|
||||
final boolean dumb = project != null && DumbService.getInstance(project).isDumb();
|
||||
for (FileIconPatcher patcher : getPatchers()) {
|
||||
if (dumb && !(patcher instanceof DumbAware)) {
|
||||
if (dumb && !DumbService.isDumbAware(patcher)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,11 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
|
||||
public class CodeEditorActionGroup extends DefaultActionGroup {
|
||||
public class CodeEditorActionGroup extends DefaultActionGroup implements DumbAware {
|
||||
public CodeEditorActionGroup() {
|
||||
super();
|
||||
}
|
||||
|
||||
+4
-8
@@ -28,7 +28,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
|
||||
public class OpenProjectFileChooserDescriptor extends FileChooserDescriptor {
|
||||
private final Icon myProjectIcon = IconLoader.getIcon(ApplicationInfoImpl.getInstanceEx().getSmallIconUrl());
|
||||
private static final Icon ourProjectIcon = IconLoader.getIcon(ApplicationInfoImpl.getInstanceEx().getSmallIconUrl());
|
||||
|
||||
public OpenProjectFileChooserDescriptor(final boolean chooseFiles) {
|
||||
super(chooseFiles, true, false, false, false, false);
|
||||
@@ -39,7 +39,7 @@ public class OpenProjectFileChooserDescriptor extends FileChooserDescriptor {
|
||||
}
|
||||
|
||||
public Icon getOpenIcon(final VirtualFile virtualFile) {
|
||||
if (isProjectDirectory(virtualFile)) return myProjectIcon;
|
||||
if (isProjectDirectory(virtualFile)) return ourProjectIcon;
|
||||
final Icon icon = getImporterIcon(virtualFile, true);
|
||||
if(icon!=null){
|
||||
return icon;
|
||||
@@ -48,7 +48,7 @@ public class OpenProjectFileChooserDescriptor extends FileChooserDescriptor {
|
||||
}
|
||||
|
||||
public Icon getClosedIcon(final VirtualFile virtualFile) {
|
||||
if (isProjectDirectory(virtualFile)) return myProjectIcon;
|
||||
if (isProjectDirectory(virtualFile)) return ourProjectIcon;
|
||||
final Icon icon = getImporterIcon(virtualFile, false);
|
||||
if(icon!=null){
|
||||
return icon;
|
||||
@@ -60,7 +60,7 @@ public class OpenProjectFileChooserDescriptor extends FileChooserDescriptor {
|
||||
public static Icon getImporterIcon(final VirtualFile virtualFile, final boolean open) {
|
||||
final ProjectOpenProcessor provider = ProjectOpenProcessor.getImportProvider(virtualFile);
|
||||
if(provider!=null) {
|
||||
return provider.getIcon();
|
||||
return virtualFile.isDirectory() ? ourProjectIcon : provider.getIcon();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -94,10 +94,6 @@ public class OpenProjectFileChooserDescriptor extends FileChooserDescriptor {
|
||||
if (isIprFile(file)) {
|
||||
return true;
|
||||
}
|
||||
final ProjectOpenProcessor importProvider = ProjectOpenProcessor.getImportProvider(file);
|
||||
if (importProvider != null && importProvider.lookForProjectsInDirectory()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -18,8 +18,9 @@ package com.intellij.ide.actions;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
|
||||
public class OtherGroup extends DefaultActionGroup {
|
||||
public class OtherGroup extends DefaultActionGroup implements DumbAware {
|
||||
public OtherGroup() {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -21,11 +21,12 @@ import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class RecentProjectsGroup extends ActionGroup {
|
||||
public class RecentProjectsGroup extends ActionGroup implements DumbAware {
|
||||
public RecentProjectsGroup() {
|
||||
super();
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ public class StartupManagerImpl extends StartupManagerEx {
|
||||
final List<Runnable> nonDumbAware = CollectionFactory.arrayList();
|
||||
|
||||
for (Runnable each : myPostStartupActivities) {
|
||||
if (each instanceof DumbAware) {
|
||||
if (DumbService.isDumbAware(each)) {
|
||||
dumbAware.add(each);
|
||||
}
|
||||
else {
|
||||
@@ -186,7 +186,7 @@ public class StartupManagerImpl extends StartupManagerEx {
|
||||
final Runnable runnable;
|
||||
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
if (action instanceof DumbAware) {
|
||||
if (DumbService.isDumbAware(action)) {
|
||||
runnable = new DumbAwareRunnable() {
|
||||
public void run() {
|
||||
application.runWriteAction(action);
|
||||
|
||||
@@ -138,6 +138,11 @@ public class CustomizationUtil {
|
||||
public void update(AnActionEvent e) {
|
||||
myGroup.update(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDumbAware() {
|
||||
return myGroup.isDumbAware();
|
||||
}
|
||||
}
|
||||
|
||||
public static void optimizeSchema(final JTree tree, final CustomActionsSchema schema) {
|
||||
|
||||
+7
@@ -22,6 +22,7 @@ import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.*;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.openapi.wm.impl.IdeFrameImpl;
|
||||
import com.intellij.ui.BalloonLayout;
|
||||
@@ -163,7 +164,13 @@ public class NotificationsManagerImpl extends NotificationsManager implements No
|
||||
final JLabel label = new JLabel(text.getText());
|
||||
final Dimension size = label.getPreferredSize();
|
||||
text.setEditable(false);
|
||||
|
||||
text.setOpaque(false);
|
||||
|
||||
if (UIUtil.isUnderNimbusLookAndFeel()) {
|
||||
text.setBackground(new Color(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
text.setBorder(null);
|
||||
text.setPreferredSize(size);
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ public class Utils{
|
||||
continue;
|
||||
}
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(context);
|
||||
if (project != null && DumbService.getInstance(project).isDumb() && !(anAction instanceof DumbAware) && !(anAction instanceof ActionGroup)) {
|
||||
if (project != null && DumbService.getInstance(project).isDumb() && !anAction.isDumbAware()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -254,6 +254,7 @@ public class FileBasedStorage extends XmlElementStorage {
|
||||
|
||||
private Document processReadException(final Exception e) {
|
||||
myBlockSavingTheContent = isProjectOrModuleFile();
|
||||
LOG.warn(e);
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode() && !ApplicationManager.getApplication().isHeadlessEnvironment()) {
|
||||
SwingUtilities.invokeLater(new Runnable(){
|
||||
public void run() {
|
||||
|
||||
+2
-2
@@ -495,7 +495,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
|
||||
if (DumbService.getInstance(myProject).isDumb()) {
|
||||
final List<FileEditorProvider> dumbAware = ContainerUtil.findAll(providers, new Condition<FileEditorProvider>() {
|
||||
public boolean value(FileEditorProvider fileEditorProvider) {
|
||||
return fileEditorProvider instanceof DumbAware;
|
||||
return DumbService.isDumbAware(fileEditorProvider);
|
||||
}
|
||||
});
|
||||
providers = dumbAware.toArray(new FileEditorProvider[dumbAware.size()]);
|
||||
@@ -520,7 +520,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
|
||||
editors[i] = editor;
|
||||
// Register PropertyChangeListener into editor
|
||||
editor.addPropertyChangeListener(myEditorPropertyChangeListener);
|
||||
editor.putUserData(DUMB_AWARE, provider instanceof DumbAware);
|
||||
editor.putUserData(DUMB_AWARE, DumbService.isDumbAware(provider));
|
||||
|
||||
if (current && editor instanceof TextEditorImpl) {
|
||||
((TextEditorImpl)editor).initFolding();
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ public final class FileEditorProviderManagerImpl extends FileEditorProviderManag
|
||||
final boolean dumb = DumbService.getInstance(project).isDumb();
|
||||
for(int i = myProviders.size() -1 ; i >= 0; i--){
|
||||
FileEditorProvider provider=myProviders.get(i);
|
||||
if((!dumb || provider instanceof DumbAware) && provider.accept(project, file)){
|
||||
if((!dumb || DumbService.isDumbAware(provider)) && provider.accept(project, file)){
|
||||
mySharedProviderList.add(provider);
|
||||
doNotShowTextEditor |= provider.getPolicy() == FileEditorPolicy.HIDE_DEFAULT_EDITOR;
|
||||
}
|
||||
|
||||
+1
-1
@@ -505,7 +505,7 @@ public final class IdeKeyEventDispatcher implements Disposable {
|
||||
|
||||
ActionUtil.performDumbAwareUpdate(action, actionEvent, true);
|
||||
|
||||
if (dumb && !(action instanceof DumbAware)) {
|
||||
if (dumb && !action.isDumbAware()) {
|
||||
if (Boolean.FALSE.equals(presentation.getClientProperty(ActionUtil.WOULD_BE_ENABLED_IF_NOT_DUMB_MODE))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
final Color treeFg = UIManager.getColor("Tree.foreground");
|
||||
label.setForeground(new Color(treeFg.getRed(), treeFg.getGreen(), treeFg.getBlue(), 180));
|
||||
final ToolWindowFactory factory = bean.getToolWindowFactory();
|
||||
final ToolWindowImpl toolWindow = (ToolWindowImpl)registerToolWindow(bean.id, label, toolWindowAnchor, myProject, factory instanceof DumbAware);
|
||||
final ToolWindowImpl toolWindow = (ToolWindowImpl)registerToolWindow(bean.id, label, toolWindowAnchor, myProject, DumbService.isDumbAware(factory));
|
||||
toolWindow.setContentFactory(factory);
|
||||
if (bean.icon != null) {
|
||||
Icon icon = IconLoader.findIcon(bean.icon, factory.getClass());
|
||||
|
||||
@@ -99,8 +99,26 @@ abstract public class AbstractExpandableItemsHandler<KeyType, ComponentType exte
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
handleSelectionChange(myKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
handleSelectionChange(myKey);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
myComponent.addHierarchyBoundsListener(new HierarchyBoundsAdapter() {
|
||||
@Override
|
||||
public void ancestorMoved(HierarchyEvent e) {
|
||||
handleSelectionChange(myKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ancestorResized(HierarchyEvent e) {
|
||||
handleSelectionChange(myKey);
|
||||
}
|
||||
});
|
||||
|
||||
myComponent.addHierarchyListener(
|
||||
new HierarchyListener() {
|
||||
public void hierarchyChanged(HierarchyEvent e) {
|
||||
|
||||
@@ -156,12 +156,6 @@ public class TreeExpandableItemsHandler extends AbstractExpandableItemsHandler<I
|
||||
super.doFillBackground(ui instanceof UIUtil.MacTreeUI && ((UIUtil.MacTreeUI)ui).isWideSelection()? height - 1 : height, width, g);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doPaintBorder(final Integer row) {
|
||||
final TreeUI ui = myComponent.getUI();
|
||||
return (!(ui instanceof UIUtil.MacTreeUI) || !((UIUtil.MacTreeUI)ui).isWideSelection()) || !myComponent.isRowSelected(row);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPaintTooltipImage(final Component rComponent, final Rectangle cellBounds, final int height, final Graphics2D g, Integer key) {
|
||||
if (myComponent.isRowSelected(key) && rComponent instanceof JComponent) {
|
||||
|
||||
@@ -564,7 +564,7 @@ automatic.renamer.rename.to.column=Rename To
|
||||
rename.0.and.its.usages.to=Rename {0} and its usages to:
|
||||
rename.variables=Rename &variables
|
||||
rename.inheritors=Rename &inheritors
|
||||
rename.tests=Rename &tests
|
||||
rename.tests=Rename t&ests
|
||||
rename.parameters.hierarchy=Rename parameters in hier&archy
|
||||
rename.bound.forms=Rename bound &forms
|
||||
inner.class.0.is.already.defined.in.class.1=Inner class {0} is already defined in class {1}.\nContinue anyway?
|
||||
|
||||
+10
@@ -16,7 +16,9 @@
|
||||
package com.intellij.testFramework.fixtures;
|
||||
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.testFramework.UsefulTestCase;
|
||||
import com.intellij.testFramework.builders.EmptyModuleFixtureBuilder;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -73,4 +75,12 @@ public abstract class CodeInsightFixtureTestCase extends UsefulTestCase {
|
||||
protected final String getTestDataPath() {
|
||||
return PathManager.getHomePath().replace(File.separatorChar, '/') + getBasePath();
|
||||
}
|
||||
|
||||
protected Project getProject() {
|
||||
return myFixture.getProject();
|
||||
}
|
||||
|
||||
protected Editor getEditor() {
|
||||
return myFixture.getEditor();
|
||||
}
|
||||
}
|
||||
|
||||
+46
@@ -24,6 +24,9 @@ import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInsight.lookup.Lookup;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.codeInsight.lookup.impl.LookupImpl;
|
||||
import com.intellij.codeInsight.template.TemplateManager;
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.codeInsight.template.impl.actions.ListTemplatesAction;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.lang.surroundWith.Surrounder;
|
||||
@@ -31,7 +34,12 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.refactoring.rename.inplace.VariableInplaceRenameHandler;
|
||||
import com.intellij.refactoring.rename.inplace.VariableInplaceRenamer;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -139,4 +147,42 @@ public class CodeInsightTestUtil {
|
||||
fixture.checkResultByFile(after, false);
|
||||
}
|
||||
|
||||
|
||||
public static void doInlineRename(VariableInplaceRenameHandler handler, final String newName, CodeInsightTestFixture fixture) {
|
||||
final Editor editor = fixture.getEditor();
|
||||
PsiElement element = fixture.getElementAtCaret();
|
||||
VariableInplaceRenamer renamer = null;
|
||||
Project project = editor.getProject();
|
||||
TemplateManagerImpl templateManager = (TemplateManagerImpl)TemplateManager.getInstance(project);
|
||||
try {
|
||||
templateManager.setTemplateTesting(true);
|
||||
renamer = handler.doRename(element, editor, null);
|
||||
TemplateState state = TemplateManagerImpl.getTemplateState(editor);
|
||||
final TextRange range = state.getCurrentVariableRange();
|
||||
assert range != null;
|
||||
new WriteCommandAction.Simple(project) {
|
||||
@Override
|
||||
protected void run() throws Throwable {
|
||||
editor.getDocument().replaceString(range.getStartOffset(), range.getEndOffset(), newName);
|
||||
}
|
||||
}.execute().throwException();
|
||||
}
|
||||
finally {
|
||||
assert renamer != null;
|
||||
renamer.finish();
|
||||
|
||||
TemplateManagerImpl.getTemplateState(editor).gotoEnd();
|
||||
renamer.performAutomaticRename(newName, element);
|
||||
templateManager.setTemplateTesting(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void doInlineRenameTest(VariableInplaceRenameHandler handler, String file,
|
||||
String extension, String newName,
|
||||
CodeInsightTestFixture fixture) {
|
||||
fixture.configureByFile(file + "." + extension);
|
||||
doInlineRename(handler, newName, fixture);
|
||||
fixture.checkResultByFile(file + "_after." + extension);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,6 +329,11 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
|
||||
super.update(e);
|
||||
myButtonPanel.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDumbAware() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
AnAction[] actions = createActions();
|
||||
|
||||
@@ -19,13 +19,14 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class StandardVcsGroup extends DefaultActionGroup {
|
||||
public abstract class StandardVcsGroup extends DefaultActionGroup implements DumbAware {
|
||||
public abstract AbstractVcs getVcs(Project project);
|
||||
|
||||
public void update(AnActionEvent e) {
|
||||
|
||||
@@ -19,12 +19,13 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
/**
|
||||
* @author mike
|
||||
*/
|
||||
public class VcsActionGroup extends DefaultActionGroup {
|
||||
public class VcsActionGroup extends DefaultActionGroup implements DumbAware {
|
||||
public void update(AnActionEvent event) {
|
||||
super.update(event);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user