@Override
public void initActions(RunContentDescriptor content, DefaultActionGroup actionGroup) {
Executor executor = myExecutionEnvironment.getExecutor();
- RestartAction restartAction = new RestartAction(executor, content, myExecutionEnvironment);
+ RestartAction restartAction = new RestartAction(content, myExecutionEnvironment);
actionGroup.add(restartAction, Constraints.FIRST);
restartAction.registerShortcut(content.getComponent());
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.ui.Messages;
-import com.intellij.openapi.ui.popup.ListItemDescriptor;
+import com.intellij.openapi.ui.popup.ListItemDescriptorAdapter;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.IconLoader;
super(new BorderLayout());
add(myPanel, BorderLayout.CENTER);
- GroupedItemsListRenderer renderer = new GroupedItemsListRenderer(new ListItemDescriptor<ProjectTemplate>() {
+ GroupedItemsListRenderer renderer = new GroupedItemsListRenderer(new ListItemDescriptorAdapter<ProjectTemplate>() {
@Nullable
@Override
public String getTextFor(ProjectTemplate value) {
return value.getName();
}
- @Nullable
- @Override
- public String getTooltipFor(ProjectTemplate value) {
- return null;
- }
-
@Nullable
@Override
public Icon getIconFor(ProjectTemplate value) {
return value.getIcon();
}
-
- @Override
- public boolean hasSeparatorAboveOf(ProjectTemplate value) {
- return false;
- }
-
- @Nullable
- @Override
- public String getCaptionAboveOf(ProjectTemplate value) {
- return null;
- }
}) {
@Override
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainerFactory;
import com.intellij.openapi.ui.Messages;
-import com.intellij.openapi.ui.popup.ListItemDescriptor;
+import com.intellij.openapi.ui.popup.ListItemDescriptorAdapter;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Disposer;
updateSelection();
}
});
- myProjectTypeList.setCellRenderer(new GroupedItemsListRenderer(new ListItemDescriptor<TemplatesGroup>() {
+ myProjectTypeList.setCellRenderer(new GroupedItemsListRenderer(new ListItemDescriptorAdapter<TemplatesGroup>() {
@Nullable
@Override
public String getTextFor(TemplatesGroup value) {
return !Comparing.equal(upper.getParentGroup(), value.getParentGroup()) &&
!Comparing.equal(upper.getName(), value.getParentGroup());
}
-
- @Nullable
- @Override
- public String getCaptionAboveOf(TemplatesGroup value) {
- return null;
- }
}) {
@Override
protected JComponent createItemComponent() {
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.intellij.ide.util.newProjectWizard;
import com.intellij.framework.FrameworkOrGroup;
}
});
for (FrameworkSupportNodeBase node : nodes) {
- sortByName(node.children, null);
+ sortByName((List)node.children, null);
}
}
@NotNull
public List<FrameworkSupportNodeBase> getChildren() {
- return children != null ? children : Collections.<FrameworkSupportNodeBase>emptyList();
+ return children != null ? (List)children : Collections.<FrameworkSupportNodeBase>emptyList();
}
public FrameworkSupportNodeBase getParentNode() {
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
-import com.intellij.openapi.ui.popup.ListItemDescriptor;
+import com.intellij.openapi.ui.popup.ListItemDescriptorAdapter;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.platform.ProjectTemplate;
}
});
- myList.setCellRenderer(new GroupedItemsListRenderer(new ListItemDescriptor() {
+ myList.setCellRenderer(new GroupedItemsListRenderer(new ListItemDescriptorAdapter() {
@Nullable
@Override
public String getTextFor(Object value) {
return ((TemplateItem)value).getName();
}
- @Nullable
- @Override
- public String getTooltipFor(Object value) {
- return null;
- }
-
@Nullable
@Override
public Icon getIconFor(Object value) {
private boolean myMayNeedExplicitTypeParameters;
public JavaMethodCallElement(@NotNull PsiMethod method) {
- super(method, method.getName());
+ this(method, method.getName());
+ }
+
+ public JavaMethodCallElement(@NotNull PsiMethod method, String methodName) {
+ super(method, methodName);
myMethod = method;
myHelper = null;
myContainingClass = method.getContainingClass();
final PsiElement resolve = referenceExpression.resolve();
if (resolve != null && PsiEquivalenceUtil.areElementsEquivalent(element, resolve) &&
PsiMethodReferenceUtil.checkMethodReferenceContext(referenceExpression, resolve, functionalType) == null) {
- result.addElement(new JavaMethodReferenceElement((PsiMethod)element, refPlace, referenceExpression));
+ result.addElement(new JavaMethodReferenceElement((PsiMethod)element, refPlace));
}
}
finally {
}
private PsiMethodReferenceExpression createMethodReferenceExpression(PsiMethod method) {
+ PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(method.getProject());
if (refPlace instanceof PsiMethodReferenceExpression) {
final PsiMethodReferenceExpression referenceExpression = (PsiMethodReferenceExpression)refPlace.copy();
final PsiElement referenceNameElement = referenceExpression.getReferenceNameElement();
LOG.assertTrue(referenceNameElement != null, referenceExpression);
- referenceNameElement.replace(JavaPsiFacade.getElementFactory(method.getProject()).createIdentifier(method.getName()));
+ referenceNameElement.replace(method.isConstructor() ? elementFactory.createKeyword("new") : elementFactory.createIdentifier(method.getName()));
return referenceExpression;
}
else if (method.hasModifierProperty(PsiModifier.STATIC)) {
final PsiClass aClass = method.getContainingClass();
LOG.assertTrue(aClass != null);
final String qualifiedName = aClass.getQualifiedName();
- return (PsiMethodReferenceExpression)JavaPsiFacade.getElementFactory(method.getProject()).createExpressionFromText(
- qualifiedName + "::" + method.getName(), refPlace);
+ return (PsiMethodReferenceExpression)elementFactory.createExpressionFromText(
+ qualifiedName + "::" + (method.isConstructor() ? "new" : method.getName()), refPlace);
}
else {
return null;
private static class JavaMethodReferenceElement extends JavaMethodCallElement {
private final PsiMethod myMethod;
private final PsiElement myRefPlace;
- private PsiMethodReferenceExpression myReferenceExpression;
- public JavaMethodReferenceElement(PsiMethod method, PsiElement refPlace, PsiMethodReferenceExpression referenceExpression) {
- super(method);
+ public JavaMethodReferenceElement(PsiMethod method, PsiElement refPlace) {
+ super(method, method.isConstructor() ? "new" : method.getName());
myMethod = method;
myRefPlace = refPlace;
- myReferenceExpression = referenceExpression;
}
@Override
InspectionsBundle.message("inspection.scope.for.title"), true),
BorderFactory.createEmptyBorder(0, 3, 3, 3)));
- final Hashtable<Integer, JLabel> sliderLabels = new Hashtable<Integer, JLabel>();
+ final Hashtable<Integer, JComponent> sliderLabels = new Hashtable<Integer, JComponent>();
for (int i = 0; i < modifiers.length; i++) {
sliderLabels.put(i + 1, new JLabel(modifiers[i]));
}
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
);
//noinspection UseOfObsoleteCollectionType
- Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();
+ Hashtable<Integer, JComponent> labelTable = new Hashtable<Integer, JComponent>();
labelTable.put(new Integer(1), new JLabel(PsiKeyword.PUBLIC));
labelTable.put(new Integer(2), new JLabel(PsiKeyword.PROTECTED));
labelTable.put(new Integer(3), new JLabel(PsiKeyword.PACKAGE));
return JavaPsiFacade.getInstance(element.getProject()).getElementFactory().createType((PsiClass)element);
}
if(element instanceof PsiMethod){
+ if (((PsiMethod)element).isConstructor()) {
+ final PsiClass containingClass = ((PsiMethod)element).getContainingClass();
+ if (containingClass != null) {
+ return JavaPsiFacade.getInstance(element.getProject()).getElementFactory().createType(containingClass);
+ }
+ }
return ((PsiMethod)element).getReturnType();
}
if(element instanceof PsiVariable){
PsiClass[] classes = ((PsiClassOwner)element).getClasses();
ArrayList<PsiClass> buffer = new ArrayList<PsiClass>();
for (final PsiClass aClass : classes) {
- if (!(aClass instanceof SyntheticElement)) {
- buffer.add(aClass);
+ if (isSynthetic(aClass)) {
+ return null;
}
+ buffer.add(aClass);
}
return buffer.toArray(new PsiClass[buffer.size()]);
}
import com.intellij.refactoring.util.javadoc.MethodJavaDocHelper;
import com.intellij.usageView.UsageInfo;
import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.containers.MultiMap;
import java.util.ArrayList;
import java.util.List;
super(project, method, settings);
}
+ @Override
+ protected MultiMap<PsiElement, String> getConflictDescriptions(UsageInfo[] usages) {
+ MultiMap<PsiElement, String> descriptions = super.getConflictDescriptions(usages);
+ if (mySettings.isMakeClassParameter()) {
+ for (UsageInfo usage : usages) {
+ PsiElement element = usage.getElement();
+ if (element instanceof PsiMethodReferenceExpression) {
+ descriptions.putValue(element, "Method reference will be corrupted");
+ }
+ }
+ }
+ return descriptions;
+ }
+
protected void changeSelfUsage(SelfUsageInfo usageInfo) throws IncorrectOperationException {
PsiElement parent = usageInfo.getElement().getParent();
LOG.assertTrue(parent instanceof PsiMethodCallExpression);
final Set<ConstraintFormula> subset = buildSubset(additionalConstraints);
//collect all input variables of selection
- final Set<InferenceVariable> varsToResolve = new HashSet<InferenceVariable>();
+ final Set<InferenceVariable> varsToResolve = new LinkedHashSet<InferenceVariable>();
for (ConstraintFormula formula : subset) {
if (formula instanceof InputOutputConstraintFormula) {
final Set<InferenceVariable> inputVariables = ((InputOutputConstraintFormula)formula).getInputVariables(this);
if (inputVariables != null) {
+ for (InferenceVariable inputVariable : inputVariables) {
+ varsToResolve.addAll(inputVariable.getDependencies(this));
+ }
varsToResolve.addAll(inputVariables);
}
}
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field;
+import java.util.Locale;
public class PsiKeywordImpl extends LeafPsiElement implements PsiKeyword, PsiJavaToken {
public PsiKeywordImpl(@NotNull IElementType type, CharSequence text) {
static {
for(Field field: PsiKeyword.class.getFields()) {
- CharTableImpl.staticIntern(field.getName().toLowerCase());
+ CharTableImpl.staticIntern(field.getName().toLowerCase(Locale.ENGLISH));
}
}
}
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.util.Locale;
+
public class PsiLiteralExpressionImpl
extends ExpressionPsiElement
implements PsiLiteralExpression, PsiLanguageInjectionHost, ContributedReferenceHost {
@Override
public Object getValue() {
final IElementType type = getLiteralElementType();
- String text = NUMERIC_LITERALS.contains(type) ? getCanonicalText().toLowerCase() : getCanonicalText();
+ String text = NUMERIC_LITERALS.contains(type) ? getCanonicalText().toLowerCase(Locale.ENGLISH) : getCanonicalText();
final int textLength = text.length();
if (type == JavaTokenType.INTEGER_LITERAL) {
--- /dev/null
+@FunctionalInterface
+interface Foo9 {
+ Bar test(int p);
+}
+
+class Bar {
+ public Bar(int p) {}
+}
+
+class Test88 {
+ void foo(Foo9 foo) {
+ foo(Bar::new<caret>);
+ }
+}
\ No newline at end of file
--- /dev/null
+@FunctionalInterface
+interface Foo9 {
+ Bar test(int p);
+}
+
+class Bar {
+ public Bar(int p) {}
+}
+
+class Test88 {
+ void foo(Foo9 foo) {
+ foo(Bar::<caret>);
+ }
+}
\ No newline at end of file
-// "Fix all 'Constant conditions & exceptions' problems" "true"
+// "Fix all 'Constant conditions & exceptions' problems in file" "true"
public class Test {
void foo() {
int k = 0;
-// "Fix all 'Constant conditions & exceptions' problems" "true"
+// "Fix all 'Constant conditions & exceptions' problems in file" "true"
public class Test {
void foo1() {
int k = 0;
-// "Fix all 'Constant conditions & exceptions' problems" "true"
+// "Fix all 'Constant conditions & exceptions' problems in file" "true"
public class Test {
void foo2() {
int k = 0;
-// "Fix all 'Constant conditions & exceptions' problems" "true"
+// "Fix all 'Constant conditions & exceptions' problems in file" "true"
public class Test {
void foo2() {
int k = 0;
-// "Fix all 'Constant conditions & exceptions' problems" "true"
+// "Fix all 'Constant conditions & exceptions' problems in file" "true"
public class Test {
void foo() {
int k = 0;
-// "Fix all 'Constant conditions & exceptions' problems" "true"
+// "Fix all 'Constant conditions & exceptions' problems in file" "true"
public class Test {
void foo1() {
int k = 0;
-// "Fix all 'Constant conditions & exceptions' problems" "true"
+// "Fix all 'Constant conditions & exceptions' problems in file" "true"
public class Test {
void foo2() {
int k = 0;
-// "Fix all 'Constant conditions & exceptions' problems" "true"
+// "Fix all 'Constant conditions & exceptions' problems in file" "true"
public class Test {
void foo2() {
int k = 0;
-// "Fix all 'Annotator' problems" "true"
+// "Fix all 'Annotator' problems in file" "true"
public class Test {
void fooF() {
}
-// "Fix all 'Annotator' problems" "true"
+// "Fix all 'Annotator' problems in file" "true"
public class Test {
void f<caret>oo() {
}
doTest();
}
+ public void testConstructorRef() throws Exception {
+ doTest(false);
+ }
+
public void testFilteredMethodReference() throws Exception {
doTest(false);
}
public void testIDEA120992() { doTest(); }
public void testTargetTypeConflictResolverShouldNotTryToEvaluateCurrentArgumentType() { doTest(); }
public void testIDEA119535() { doTest(); }
-
- @Bombed(day = 20, month = Calendar.AUGUST)
public void testIDEA119003() { doTest(); }
public void testIDEA125674() { doTest(); }
public void testIDEA117124() { doTest(); }
public void testIDEA122700() { doTest(); }
public void testIDEA122406() { doTest(); }
public void testNestedCallsInsideLambdaReturnExpression() { doTest(); }
+ @Bombed(day = 20, month = Calendar.AUGUST)
public void testIDEA123731() { doTest(); }
public void testIDEA123869() { doTest(); }
public void testIDEA123848() { doTest(); }
doTest();
}
- @Bombed(day = 20, month = Calendar.AUGUST)
public void testIDEA124190() throws Exception {
doTest();
}
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.intellij.codeInspection.i18n.JavaI18nUtil;
import com.intellij.ide.DataManager;
import com.intellij.lang.properties.psi.PropertiesFile;
+import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.application.ex.PathManagerEx;
configureByFile(getBasePath() + "/before"+getTestName(false)+"."+ext);
I18nizeAction action = new I18nizeAction();
DataContext dataContext = DataManager.getInstance().getDataContext(myEditor.getComponent());
- AnActionEvent event = new AnActionEvent(null, dataContext, "place", action.getTemplatePresentation(), null, 0);
+ AnActionEvent event = new AnActionEvent(null, dataContext, "place", action.getTemplatePresentation(), ActionManager.getInstance(), 0);
action.update(event);
@NonNls String afterFile = getBasePath() + "/after" + getTestName(false) + "." + ext;
boolean afterFileExists = new File(PathManagerEx.getTestDataPath() + afterFile).exists();
<item name="java.awt.CardLayout void show(java.awt.Container, java.lang.String) 1">
<annotation name="org.jetbrains.annotations.NonNls" />
</item>
+ <item name='java.awt.Component java.awt.Cursor getCursor()'>
+ <annotation name='org.jetbrains.annotations.NotNull'/>
+ </item>
<item name='java.awt.Component java.awt.Point getLocation()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<val name="valuesFromClass" val="java.awt.Cursor.class" />
</annotation>
</item>
+ <item name='java.awt.Cursor java.awt.Cursor getPredefinedCursor(int)'>
+ <annotation name='org.jetbrains.annotations.NotNull'/>
+ </item>
<item name="java.awt.Cursor java.awt.Cursor getPredefinedCursor(int) 0">
<annotation name="org.intellij.lang.annotations.MagicConstant">
<val name="valuesFromClass" val="java.awt.Cursor.class" />
<item name='java.util.ResourceBundle boolean containsKey(java.lang.String) 0'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
+ <item name='java.util.ResourceBundle java.lang.Object getObject(java.lang.String)'>
+ <annotation name='org.jetbrains.annotations.NotNull'/>
+ </item>
<item name='java.util.ResourceBundle java.lang.Object getObject(java.lang.String) 0'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='java.util.ResourceBundle java.lang.Object handleGetObject(java.lang.String) 0'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
+ <item name='java.util.ResourceBundle java.lang.String getString(java.lang.String)'>
+ <annotation name='org.jetbrains.annotations.NotNull'/>
+ </item>
<item name='java.util.ResourceBundle java.lang.String getString(java.lang.String) 0'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
+ <item name='java.util.ResourceBundle java.lang.String[] getStringArray(java.lang.String)'>
+ <annotation name='org.jetbrains.annotations.NotNull'/>
+ </item>
<item name='java.util.ResourceBundle java.lang.String[] getStringArray(java.lang.String) 0'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
--- /dev/null
+<root>
+ <item name='java.util.concurrent.atomic.AtomicReferenceFieldUpdater V get(T) 0'>
+ <annotation name='org.jetbrains.annotations.NotNull'/>
+ </item>
+ <item name='java.util.concurrent.atomic.AtomicReferenceFieldUpdater V getAndSet(T, V) 0'>
+ <annotation name='org.jetbrains.annotations.NotNull'/>
+ </item>
+ <item name='java.util.concurrent.atomic.AtomicReferenceFieldUpdater boolean compareAndSet(T, V, V) 0'>
+ <annotation name='org.jetbrains.annotations.NotNull'/>
+ </item>
+ <item name='java.util.concurrent.atomic.AtomicReferenceFieldUpdater boolean weakCompareAndSet(T, V, V) 0'>
+ <annotation name='org.jetbrains.annotations.NotNull'/>
+ </item>
+ <item
+ name='java.util.concurrent.atomic.AtomicReferenceFieldUpdater java.util.concurrent.atomic.AtomicReferenceFieldUpdater<U,W> newUpdater(java.lang.Class<U>, java.lang.Class<W>, java.lang.String)'>
+ <annotation name='org.jetbrains.annotations.NotNull'/>
+ </item>
+ <item
+ name='java.util.concurrent.atomic.AtomicReferenceFieldUpdater java.util.concurrent.atomic.AtomicReferenceFieldUpdater<U,W> newUpdater(java.lang.Class<U>, java.lang.Class<W>, java.lang.String) 0'>
+ <annotation name='org.jetbrains.annotations.NotNull'/>
+ </item>
+ <item
+ name='java.util.concurrent.atomic.AtomicReferenceFieldUpdater java.util.concurrent.atomic.AtomicReferenceFieldUpdater<U,W> newUpdater(java.lang.Class<U>, java.lang.Class<W>, java.lang.String) 1'>
+ <annotation name='org.jetbrains.annotations.NotNull'/>
+ </item>
+ <item
+ name='java.util.concurrent.atomic.AtomicReferenceFieldUpdater java.util.concurrent.atomic.AtomicReferenceFieldUpdater<U,W> newUpdater(java.lang.Class<U>, java.lang.Class<W>, java.lang.String) 2'>
+ <annotation name='org.jetbrains.annotations.NotNull'/>
+ </item>
+ <item name='java.util.concurrent.atomic.AtomicReferenceFieldUpdater void lazySet(T, V) 0'>
+ <annotation name='org.jetbrains.annotations.NotNull'/>
+ </item>
+ <item name='java.util.concurrent.atomic.AtomicReferenceFieldUpdater void set(T, V) 0'>
+ <annotation name='org.jetbrains.annotations.NotNull'/>
+ </item>
+</root>
\ No newline at end of file
private static void enableRemoveOnCancelPolicy(ScheduledThreadPoolExecutor executor) {
if (Patches.USE_REFLECTION_TO_ACCESS_JDK7) {
try {
- Method setRemoveOnCancelPolicy = ScheduledThreadPoolExecutor.class.getDeclaredMethod("setRemoveOnCancelPolicy", boolean.class);
- setRemoveOnCancelPolicy.setAccessible(true);
+ Method setRemoveOnCancelPolicy = ReflectionUtil.getDeclaredMethod(ScheduledThreadPoolExecutor.class, "setRemoveOnCancelPolicy", boolean.class);
setRemoveOnCancelPolicy.invoke(executor, true);
}
catch (Exception ignored) {
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@Nullable
public static ProgressIndicatorProvider ourInstance;
- @Nullable
public static ProgressIndicatorProvider getInstance() {
return ourInstance;
}
return ourInstance != null ? ourInstance.getProgressIndicator() : null;
}
+ @NotNull
public abstract NonCancelableSection startNonCancelableSection();
@NotNull
public static void checkCanceled() throws ProcessCanceledException {
// smart optimization! There's a thread started in ProgressManagerImpl, that set's this flag up once in 10 milliseconds
if (ourNeedToCheckCancel && ourInstance != null) {
+ ourNeedToCheckCancel = false; // doCheckCanceled() may flip it back to true
ourInstance.doCheckCanceled();
- ourNeedToCheckCancel = false;
}
}
}
putUserData(BOM_KEY, BOM);
}
+ @Override
@NonNls
public String toString() {
return "VirtualFile: " + getPresentableUrl();
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
protected PsiWalkingState(@NotNull PsiElementVisitor delegate) {
- super(PsiTreeGuide.instance);
+ this(delegate, PsiTreeGuide.instance);
+ }
+ protected PsiWalkingState(@NotNull PsiElementVisitor delegate, @NotNull TreeGuide<PsiElement> guide) {
+ super(guide);
myVisitor = delegate;
}
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package com.intellij.psi;
import com.intellij.openapi.util.TextRange;
+import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collections;
private ReferenceRange() {
}
- public static List<TextRange> getRanges(PsiReference ref) {
+ @NotNull
+ public static List<TextRange> getRanges(@NotNull PsiReference ref) {
if (ref instanceof MultiRangeReference) {
return ((MultiRangeReference)ref).getRanges();
}
return Collections.singletonList(ref.getRangeInElement());
}
- public static List<TextRange> getAbsoluteRanges(PsiReference ref) {
+ @NotNull
+ public static List<TextRange> getAbsoluteRanges(@NotNull PsiReference ref) {
final PsiElement elt = ref.getElement();
final List<TextRange> relativeRanges = getRanges(ref);
final List<TextRange> answer = new ArrayList<TextRange>(relativeRanges.size());
return answer;
}
- public static TextRange getRange(PsiReference ref) {
+ public static TextRange getRange(@NotNull PsiReference ref) {
if (ref instanceof MultiRangeReference) {
final List<TextRange> ranges = ((MultiRangeReference)ref).getRanges();
return new TextRange(ranges.get(0).getStartOffset(), ranges.get(ranges.size() - 1).getEndOffset());
return ref.getRangeInElement();
}
- public static boolean containsOffsetInElement(PsiReference ref, int offset) {
+ public static boolean containsOffsetInElement(@NotNull PsiReference ref, int offset) {
if (ref instanceof MultiRangeReference) {
for (TextRange range : ((MultiRangeReference)ref).getRanges()) {
if (range.containsOffset(offset)) return true;
return rangeInElement != null && rangeInElement.containsOffset(offset);
}
- public static boolean containsRangeInElement(PsiReference ref, TextRange rangeInElement) {
+ public static boolean containsRangeInElement(@NotNull PsiReference ref, @NotNull TextRange rangeInElement) {
if (ref instanceof MultiRangeReference) {
for (TextRange range : ((MultiRangeReference)ref).getRanges()) {
if (range.contains(rangeInElement)) return true;
protected void doCheckCanceled() throws ProcessCanceledException {
}
+ @NotNull
@Override
public NonCancelableSection startNonCancelableSection() {
return NonCancelableSection.EMPTY;
throw new CannotRunReadActionException();
}
+ public static void tryRunReadAction(@NotNull final Runnable computable) throws CannotRunReadActionException {
+ if (!((ApplicationEx)ApplicationManager.getApplication()).tryRunReadAction(computable)) {
+ throw new CannotRunReadActionException();
+ }
+ }
+
public static class CannotRunReadActionException extends RuntimeException{
@Override
public Throwable fillInStackTrace() {
public class AnActionEvent implements PlaceProvider<String> {
private final InputEvent myInputEvent;
- private final ActionManager myActionManager;
+ @NotNull private final ActionManager myActionManager;
@NotNull private final DataContext myDataContext;
@NotNull private final String myPlace;
@NotNull private final Presentation myPresentation;
/**
* @throws IllegalArgumentException if <code>dataContext</code> is <code>null</code> or
* <code>place</code> is <code>null</code> or <code>presentation</code> is <code>null</code>
+ *
+ * @see ActionManager#getInstance()
*/
public AnActionEvent(InputEvent inputEvent,
@NotNull DataContext dataContext,
@NotNull @NonNls String place,
@NotNull Presentation presentation,
- ActionManager actionManager,
+ @NotNull ActionManager actionManager,
@JdkConstants.InputEventMask int modifiers) {
// TODO[vova,anton] make this constructor package local. No one is allowed to create AnActionEvents
myInputEvent = inputEvent;
public static AnActionEvent createFromInputEvent(@NotNull AnAction action, InputEvent event, @NotNull String place) {
DataContext context = event == null ? DataManager.getInstance().getDataContext() : DataManager.getInstance().getDataContext(event.getComponent());
int modifiers = event == null ? 0 : event.getModifiers();
- return new AnActionEvent(
+ AnActionEvent anActionEvent = new AnActionEvent(
event,
context,
place,
ActionManager.getInstance(),
modifiers
);
+ anActionEvent.setInjectedContext(action.isInInjectedContext());
+ return anActionEvent;
}
/**
return myModifiers;
}
+ @NotNull
public ActionManager getActionManager() {
return myActionManager;
}
+
public void setInjectedContext(boolean worksInInjected) {
myWorksInInjected = worksInInjected;
}
public abstract void restartRunProfile(@Nullable ProgramRunner runner,
@NotNull ExecutionEnvironment environment,
@Nullable RunContentDescriptor currentDescriptor);
+
+ public abstract void restartRunProfile(@NotNull ExecutionEnvironment environment, @Nullable RunContentDescriptor currentDescriptor);
}
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package com.intellij.execution;
+import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.project.Project;
* @author spleaner
*/
public abstract class ExecutorRegistry implements ApplicationComponent {
-
public static ExecutorRegistry getInstance() {
return ApplicationManager.getApplication().getComponent(ExecutorRegistry.class);
}
public abstract Executor getExecutorById(final String executorId);
+ @Deprecated
+ /**
+ * @deprecated
+ * to remove in IDEA 15
+ */
public abstract boolean isStarting(Project project, String executorId, String runnerId);
+
+ public abstract boolean isStarting(@NotNull ExecutionEnvironment environment);
}
package com.intellij.execution.runners;
-import com.intellij.execution.ExecutionBundle;
-import com.intellij.execution.ExecutionException;
-import com.intellij.execution.RunCanceledByUserException;
+import com.intellij.execution.*;
import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.process.ProcessNotCreatedException;
+import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.notification.NotificationGroup;
import com.intellij.notification.NotificationListener;
import com.intellij.util.ObjectUtils;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
}
});
}
+
+ public static void restart(@NotNull ExecutionEnvironment environment) {
+ restart(environment, null);
+ }
+
+ public static void restart(@NotNull ExecutionEnvironment environment, @Nullable RunContentDescriptor contentDescriptor) {
+ if (!ExecutorRegistry.getInstance().isStarting(environment)) {
+ ExecutionManager.getInstance(environment.getProject()).restartRunProfile(environment, contentDescriptor == null ? environment.getContentToReuse() : contentDescriptor);
+ }
+ }
}
import com.intellij.ide.HelpIdProvider;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.DataProvider;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Disposer;
import com.intellij.ui.content.Content;
@Nullable
@Override
public Object getData(@NonNls String dataId) {
- if (RunContentManager.RUN_CONTENT_DESCRIPTOR.is(dataId)) {
- return this;
- }
- return null;
+ return LangDataKeys.RUN_CONTENT_DESCRIPTOR.is(dataId) ? this : null;
}
public ExecutionConsole getExecutionConsole() {
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.DataKey;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.wm.ToolWindow;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public interface RunContentManager {
-
- DataKey<RunContentDescriptor> RUN_CONTENT_DESCRIPTOR = DataKey.create("RUN_CONTENT_DESCRIPTOR");
+ @Deprecated
+ DataKey<RunContentDescriptor> RUN_CONTENT_DESCRIPTOR = LangDataKeys.RUN_CONTENT_DESCRIPTOR;
@Nullable
RunContentDescriptor getSelectedContent();
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
ContentManager getContentManager();
+ @NotNull
ActionManager getActionManager();
IdeFocusManager getFocusManager();
package com.intellij.openapi.actionSystem;
+import com.intellij.execution.configurations.RunProfile;
+import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.ui.ConsoleView;
+import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.ide.IdeView;
import com.intellij.lang.Language;
import com.intellij.openapi.module.ModifiableModuleModel;
public static final DataKey<Library> LIBRARY = DataKey.create("project.model.library");
+
+ public static final DataKey<RunProfile> RUN_PROFILE = DataKey.create("runProfile");
+ public static final DataKey<ExecutionEnvironment> EXECUTION_ENVIRONMENT = DataKey.create("executionEnvironment");
+ public static final DataKey<RunContentDescriptor> RUN_CONTENT_DESCRIPTOR = DataKey.create("RUN_CONTENT_DESCRIPTORy6gfv");
}
<grid id="27dc6" binding="myRootPanel" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
- <xy x="20" y="20" width="500" height="585"/>
+ <xy x="20" y="20" width="500" height="614"/>
</constraints>
<properties/>
<border type="none"/>
<children>
- <grid id="ed507" layout-manager="GridLayoutManager" row-count="7" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <grid id="ed507" layout-manager="GridLayoutManager" row-count="8" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="9" fill="3" indent="0" use-parent-layout="false"/>
<text resource-bundle="messages/ApplicationBundle" key="checkbox.show.tabs.tooltips"/>
</properties>
</component>
+ <grid id="e3283" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <margin top="0" left="0" bottom="0" right="0"/>
+ <constraints>
+ <grid row="7" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+ </constraints>
+ <properties/>
+ <border type="none"/>
+ <children>
+ <component id="2479d" class="javax.swing.JLabel">
+ <constraints>
+ <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
+ </constraints>
+ <properties>
+ <text resource-bundle="messages/ApplicationBundle" key="editbox.tab.title.limit"/>
+ </properties>
+ </component>
+ <component id="3499c" class="javax.swing.JTextField" binding="myTabTitleLimitField">
+ <constraints>
+ <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="0" indent="0" use-parent-layout="false">
+ <preferred-size width="30" height="27"/>
+ </grid>
+ </constraints>
+ <properties>
+ <columns value="2"/>
+ <text value="30"/>
+ </properties>
+ </component>
+ </children>
+ </grid>
</children>
</grid>
<vspacer id="651b4">
</clientProperties>
<border type="none" title-resource-bundle="messages/ApplicationBundle" title-key="group.tab.closing.policy"/>
<children>
- <grid id="5a5a7" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <grid id="5a5a7" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<text value="15"/>
</properties>
</component>
- <component id="2479d" class="javax.swing.JLabel">
- <constraints>
- <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties>
- <text resource-bundle="messages/ApplicationBundle" key="editbox.tab.title.limit"/>
- </properties>
- </component>
- <component id="3499c" class="javax.swing.JTextField" binding="myTabTitleLimitField">
- <constraints>
- <grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="0" indent="0" use-parent-layout="false">
- <preferred-size width="30" height="27"/>
- </grid>
- </constraints>
- <properties>
- <columns value="2"/>
- <text value="30"/>
- </properties>
- </component>
</children>
</grid>
<grid id="9b723" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="2">
private final ProjectLevelVcsManager myProjectLevelVcsManager;
private final VcsDirtyScopeManager myVcsDirtyScopeManager;
private final FileStatusManager myFileStatusManager;
- private final ActionManager myActionManager;
+ @NotNull private final ActionManager myActionManager;
private final TooltipController myTooltipController;
private boolean myEscPressed;
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Collections.sort(languages, PsiUtilBase.LANGUAGE_COMPARATOR);
for (Language language : languages) {
@SuppressWarnings("UseOfObsoleteCollectionType")
- final Hashtable<Integer, JLabel> sliderLabels = new Hashtable<Integer, JLabel>();
+ final Hashtable<Integer, JComponent> sliderLabels = new Hashtable<Integer, JComponent>();
sliderLabels.put(1, new JLabel(EditorBundle.message("hector.none.slider.label")));
sliderLabels.put(2, new JLabel(EditorBundle.message("hector.syntax.slider.label")));
if (notInLibrary) {
import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.codeInsight.TargetElementUtilBase;
import com.intellij.codeInsight.documentation.DocumentationManager;
+import com.intellij.codeInsight.documentation.DocumentationManagerProtocol;
import com.intellij.codeInsight.hint.HintManager;
import com.intellij.codeInsight.hint.HintManagerImpl;
import com.intellij.codeInsight.hint.HintUtil;
import com.intellij.openapi.actionSystem.Shortcut;
import com.intellij.openapi.actionSystem.impl.ActionButton;
import com.intellij.openapi.actionSystem.impl.PresentationFactory;
-import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.components.AbstractProjectComponent;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.util.Comparing;
-import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
public class CtrlMouseHandler extends AbstractProjectComponent {
private static final AbstractDocumentationTooltipAction[] ourTooltipActions = {new ShowQuickDocAtPinnedWindowFromTooltipAction()};
- private static Key<?> ourDebuggerHighlighterKey;
- private static Key<?> ourXDebuggerHighlighterKey;
private final EditorColorsManager myEditorColorsManager;
- private HighlightersSet myHighlighter;
- @JdkConstants.InputEventMask private int myStoredModifiers = 0;
- private TooltipProvider myTooltipProvider = null;
- private final FileEditorManager myFileEditorManager;
- private final DocumentationManager myDocumentationManager;
- @Nullable private Point myPrevMouseLocation;
+ private HighlightersSet myHighlighter;
+ @JdkConstants.InputEventMask private int myStoredModifiers = 0;
+ private TooltipProvider myTooltipProvider = null;
+ private final FileEditorManager myFileEditorManager;
+ private final DocumentationManager myDocumentationManager;
+ @Nullable private Point myPrevMouseLocation;
private LightweightHint myHint;
private enum BrowseMode {None, Declaration, TypeDeclaration, Implementation}
BrowseMode browseMode = getBrowseMode(modifiers);
- if (browseMode != BrowseMode.None) {
+ if (browseMode == BrowseMode.None) {
+ disposeHighlighter();
+ cancelPreviousTooltip();
+ }
+ else {
TooltipProvider tooltipProvider = myTooltipProvider;
if (tooltipProvider != null) {
if (browseMode != tooltipProvider.getBrowseMode()) {
myTooltipProvider.execute(browseMode);
}
}
- else {
- disposeHighlighter();
- cancelPreviousTooltip();
- }
}
};
EditorColorsManager colorsManager,
FileEditorManager fileEditorManager,
@NotNull DocumentationManager documentationManager,
- @NotNull final EditorFactory editorFactory)
- {
+ @NotNull final EditorFactory editorFactory) {
super(project);
myEditorColorsManager = colorsManager;
startupManager.registerPostStartupActivity(new DumbAwareRunnable() {
return new Rectangle(hintComponent.getLocationOnScreen(), hintComponent.getSize());
}
+ @NotNull
private static BrowseMode getBrowseMode(@JdkConstants.InputEventMask int modifiers) {
if (modifiers != 0) {
final Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap();
private abstract static class Info {
@NotNull protected final PsiElement myElementAtPointer;
- private final List<TextRange> myRanges;
+ @NotNull private final List<TextRange> myRanges;
- public Info(@NotNull PsiElement elementAtPointer, List<TextRange> ranges) {
+ public Info(@NotNull PsiElement elementAtPointer, @NotNull List<TextRange> ranges) {
myElementAtPointer = elementAtPointer;
myRanges = ranges;
}
elementAtPointer.getTextOffset() + elementAtPointer.getTextLength())));
}
- boolean isSimilarTo(final Info that) {
+ boolean isSimilarTo(@NotNull Info that) {
return Comparing.equal(myElementAtPointer, that.myElementAtPointer) && myRanges.equals(that.myRanges);
}
+ @NotNull
public List<TextRange> getRanges() {
return myRanges;
}
@NotNull
public abstract DocInfo getInfo();
- public abstract boolean isValid(Document document);
+ public abstract boolean isValid(@NotNull Document document);
public abstract void showDocInfo(@NotNull DocumentationManager docManager);
- protected boolean rangesAreCorrect(Document document) {
+ protected boolean rangesAreCorrect(@NotNull Document document) {
final TextRange docRange = new TextRange(0, document.getTextLength());
for (TextRange range : getRanges()) {
if (!docRange.contains(range)) return false;
}
}
- private static void showDumbModeNotification(final Project project) {
+ private static void showDumbModeNotification(@NotNull Project project) {
DumbService.getInstance(project).showDumbModeNotification("Element information is not available during index update");
}
myTargetElement = targetElement;
}
- public InfoSingle(final PsiReference ref, @NotNull final PsiElement targetElement) {
+ public InfoSingle(@NotNull PsiReference ref, @NotNull final PsiElement targetElement) {
super(ref.getElement(), ReferenceRange.getAbsoluteRanges(ref));
myTargetElement = targetElement;
}
@Override
@NotNull
public DocInfo getInfo() {
- AccessToken token = ReadAction.start();
- try {
- return generateInfo(myTargetElement, myElementAtPointer);
- }
- catch (IndexNotReadyException e) {
- showDumbModeNotification(myTargetElement.getProject());
- return DocInfo.EMPTY;
- }
- finally {
- token.finish();
- }
+ return ApplicationManager.getApplication().runReadAction(new Computable<DocInfo>() {
+ @Override
+ public DocInfo compute() {
+ try {
+ return generateInfo(myTargetElement, myElementAtPointer);
+ }
+ catch (IndexNotReadyException e) {
+ showDumbModeNotification(myTargetElement.getProject());
+ return DocInfo.EMPTY;
+ }
+ }
+ });
}
@Override
- public boolean isValid(Document document) {
+ public boolean isValid(@NotNull Document document) {
if (!myTargetElement.isValid()) return false;
if (!myElementAtPointer.isValid()) return false;
if (myTargetElement == myElementAtPointer) return false;
}
private static class InfoMultiple extends Info {
-
public InfoMultiple(@NotNull final PsiElement elementAtPointer) {
super(elementAtPointer);
}
}
@Override
- public boolean isValid(Document document) {
+ public boolean isValid(@NotNull Document document) {
return rangesAreCorrect(document);
}
}
@Nullable
- private Info getInfoAt(@NotNull Editor editor, PsiFile file, int offset, BrowseMode browseMode) {
+ private Info getInfoAt(@NotNull Editor editor, @NotNull PsiFile file, int offset, @NotNull BrowseMode browseMode) {
PsiElement targetElement = null;
if (browseMode == BrowseMode.TypeDeclaration) {
}
else if (browseMode == BrowseMode.Declaration) {
final PsiReference ref = TargetElementUtilBase.findReference(editor, offset);
- final List<PsiElement> resolvedElements = ref != null ? resolve(ref) : Collections.<PsiElement>emptyList();
+ final List<PsiElement> resolvedElements = ref == null ? Collections.<PsiElement>emptyList() : resolve(ref);
final PsiElement resolvedElement = resolvedElements.size() == 1 ? resolvedElements.get(0) : null;
final PsiElement[] targetElements = GotoDeclarationAction.findTargetElementsNoVS(myProject, editor, offset, false);
return null;
}
- private static List<PsiElement> resolve(final PsiReference ref) {
+ @NotNull
+ private static List<PsiElement> resolve(@NotNull PsiReference ref) {
// IDEA-56727 try resolve first as in GotoDeclarationAction
PsiElement resolvedElement = ref.resolve();
}
private class TooltipProvider {
- private final Editor myEditor;
- private final LogicalPosition myPosition;
+ @NotNull private final Editor myEditor;
+ @NotNull private final LogicalPosition myPosition;
private BrowseMode myBrowseMode;
private boolean myDisposed;
private final ProgressIndicator myProgress = new ProgressIndicatorBase();
- TooltipProvider(Editor editor, LogicalPosition pos) {
+ TooltipProvider(@NotNull Editor editor, @NotNull LogicalPosition pos) {
myEditor = editor;
myPosition = pos;
}
return myBrowseMode;
}
- void execute(BrowseMode browseMode) {
+ void execute(@NotNull BrowseMode browseMode) {
myBrowseMode = browseMode;
Document document = myEditor.getDocument();
});
}
- private void doExecute(PsiFile file, int offset) {
+ private void doExecute(@NotNull PsiFile file, int offset) {
final Info info;
try {
info = getInfoAt(myEditor, file, offset, myBrowseMode);
+ if (info == null) return;
}
catch (IndexNotReadyException e) {
showDumbModeNotification(myProject);
return;
}
- if (info == null) return;
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
});
}
- private void showHint(Info info) {
+ private void showHint(@NotNull Info info) {
if (myDisposed || myEditor.isDisposed()) return;
Component internalComponent = myEditor.getContentComponent();
if (myHighlighter != null) {
@Override
public void mouseClicked(MouseEvent e) {
- QuickDocInfoPane pane = quickDocPaneRef.get();
- if (pane != null) {
- pane.mouseClicked(e);
- }
}
};
Ref<Consumer<String>> newTextConsumerRef = new Ref<Consumer<String>>();
showHint(hint);
}
- public void showHint(LightweightHint hint) {
+ public void showHint(@NotNull LightweightHint hint) {
final HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl();
Point p = HintManagerImpl.getHintPosition(hint, myEditor, myPosition, HintManager.ABOVE);
hintManager.showEditorHint(hint, myEditor, p,
}
}
- private HighlightersSet installHighlighterSet(Info info, Editor editor) {
+ @NotNull
+ private HighlightersSet installHighlighterSet(@NotNull Info info, @NotNull Editor editor) {
final JComponent internalComponent = editor.getContentComponent();
internalComponent.addKeyListener(myEditorKeyListener);
editor.getScrollingModel().addVisibleAreaListener(myVisibleAreaListener);
private class HighlightersSet {
- private final List<RangeHighlighter> myHighlighters;
- private final Editor myHighlighterView;
- private final Cursor myStoredCursor;
- private final Info myStoredInfo;
-
- private HighlightersSet(List<RangeHighlighter> highlighters, Editor highlighterView, Cursor storedCursor, Info storedInfo) {
+ @NotNull private final List<RangeHighlighter> myHighlighters;
+ @NotNull private final Editor myHighlighterView;
+ @NotNull private final Cursor myStoredCursor;
+ @NotNull private final Info myStoredInfo;
+
+ private HighlightersSet(@NotNull List<RangeHighlighter> highlighters,
+ @NotNull Editor highlighterView,
+ @NotNull Cursor storedCursor,
+ @NotNull Info storedInfo) {
myHighlighters = highlighters;
myHighlighterView = highlighterView;
myStoredCursor = storedCursor;
myFileEditorManager.removeFileEditorManagerListener(myFileEditorManagerListener);
}
+ @NotNull
public Info getStoredInfo() {
return myStoredInfo;
}
}
private static class DocInfo {
-
public static final DocInfo EMPTY = new DocInfo(null, null, null);
- @Nullable public final String text;
+ @Nullable public final String text;
@Nullable public final DocumentationProvider docProvider;
- @Nullable public final PsiElement documentationAnchor;
+ @Nullable public final PsiElement documentationAnchor;
DocInfo(@Nullable String text, @Nullable DocumentationProvider provider, @Nullable PsiElement documentationAnchor) {
this.text = text;
}
private class QuickDocInfoPane extends JBLayeredPane {
-
private static final int BUTTON_HGAP = 5;
@NotNull private final List<JComponent> myButtons = new ArrayList<JComponent>();
processStateChangeIfNecessary(e.getLocationOnScreen(), false);
}
- public void mouseClicked(@NotNull MouseEvent e) {
- // TODO den check the processing.
- int i = 1;
- }
-
private void processStateChangeIfNecessary(@NotNull Point mouseScreenLocation, boolean mouseEntered) {
// Don't show 'view quick doc' buttons if docked quick doc control is already active.
if (myDocumentationManager.hasActiveDockedDocWindow()) {
}
private class QuickDocHyperlinkListener implements HyperlinkListener {
-
@NotNull private final DocumentationProvider myProvider;
- @NotNull private final PsiElement myContext;
+ @NotNull private final PsiElement myContext;
QuickDocHyperlinkListener(@NotNull DocumentationProvider provider, @NotNull PsiElement context) {
myProvider = provider;
}
String description = e.getDescription();
- if (StringUtil.isEmpty(description) || !description.startsWith(DocumentationManager.PSI_ELEMENT_PROTOCOL)) {
+ if (StringUtil.isEmpty(description) || !description.startsWith(DocumentationManagerProtocol.PSI_ELEMENT_PROTOCOL)) {
return;
}
- String elementName = e.getDescription().substring(DocumentationManager.PSI_ELEMENT_PROTOCOL.length());
+ String elementName = e.getDescription().substring(DocumentationManagerProtocol.PSI_ELEMENT_PROTOCOL.length());
final PsiElement targetElement = myProvider.getDocumentationElementForLink(PsiManager.getInstance(myProject), elementName, myContext);
if (targetElement != null) {
@Override
public boolean isStarting(Project project, final String executorId, final String runnerId) {
- return myInProgress.contains(new Trinity<Project, String, String>(project, executorId, runnerId));
+ return myInProgress.contains(Trinity.create(project, executorId, runnerId));
+ }
+
+ @Override
+ public boolean isStarting(@NotNull ExecutionEnvironment environment) {
+ return isStarting(environment.getProject(), environment.getExecutor().getId(), environment.getRunnerId());
}
@Override
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.execution.actions;
+import com.intellij.execution.ExecutionBundle;
import com.intellij.execution.ExecutionManager;
import com.intellij.execution.KillableProcess;
+import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.ui.RunContentDescriptor;
-import com.intellij.execution.ui.RunContentManager;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.JBPopupFactory;
-import com.intellij.openapi.ui.popup.ListItemDescriptor;
+import com.intellij.openapi.ui.popup.ListItemDescriptorAdapter;
import com.intellij.openapi.ui.popup.PopupChooserBuilder;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Pair;
import java.util.Collections;
import java.util.List;
-public class StopAction extends DumbAwareAction implements AnAction.TransparentUpdate {
+class StopAction extends DumbAwareAction implements AnAction.TransparentUpdate {
@Override
public void update(final AnActionEvent e) {
boolean enable = false;
Icon icon = getTemplatePresentation().getIcon();
String description = getTemplatePresentation().getDescription();
- final Presentation presentation = e.getPresentation();
-
+ Presentation presentation = e.getPresentation();
if (ActionPlaces.MAIN_MENU.equals(e.getPlace())) {
enable = !getCancellableProcesses(e.getProject()).isEmpty() || !getActiveDescriptors(e.getDataContext()).isEmpty();
+ presentation.setText(getTemplatePresentation().getText());
}
else {
- final ProcessHandler processHandler = getHandler(e.getDataContext());
+ RunContentDescriptor contentDescriptor = e.getData(LangDataKeys.RUN_CONTENT_DESCRIPTOR);
+ ProcessHandler processHandler = contentDescriptor == null ? null : contentDescriptor.getProcessHandler();
if (processHandler != null && !processHandler.isProcessTerminated()) {
if (!processHandler.isProcessTerminating()) {
enable = true;
description = "Kill process";
}
}
+
+ RunProfile runProfile = e.getData(LangDataKeys.RUN_PROFILE);
+ if (runProfile == null && contentDescriptor == null) {
+ presentation.setText(getTemplatePresentation().getText());
+ }
+ else {
+ presentation.setText(ExecutionBundle.message("stop.configuration.action.name", runProfile == null ? contentDescriptor.getDisplayName() : runProfile.getName()));
+ }
}
presentation.setEnabled(enable);
final JBList list = new JBList(handlerItems.first);
if (handlerItems.second != null) list.setSelectedValue(handlerItems.second, true);
- list.setCellRenderer(new GroupedItemsListRenderer(new ListItemDescriptor() {
+ list.setCellRenderer(new GroupedItemsListRenderer(new ListItemDescriptorAdapter() {
@Nullable
@Override
public String getTextFor(Object value) {
return value instanceof HandlerItem ? ((HandlerItem)value).displayName : null;
}
- @Nullable
- @Override
- public String getTooltipFor(Object value) {
- return null;
- }
-
@Nullable
@Override
public Icon getIconFor(Object value) {
public boolean hasSeparatorAboveOf(Object value) {
return value instanceof HandlerItem && ((HandlerItem)value).hasSeparator;
}
-
- @Nullable
- @Override
- public String getCaptionAboveOf(Object value) {
- return null;
- }
}));
final PopupChooserBuilder builder = JBPopupFactory.getInstance().createListPopupBuilder(list);
}
@Nullable
- static ProcessHandler getHandler(final DataContext dataContext) {
- final RunContentDescriptor contentDescriptor = RunContentManager.RUN_CONTENT_DESCRIPTOR.getData(dataContext);
- final ProcessHandler processHandler;
+ static ProcessHandler getHandler(@NotNull DataContext dataContext) {
+ final RunContentDescriptor contentDescriptor = LangDataKeys.RUN_CONTENT_DESCRIPTOR.getData(dataContext);
if (contentDescriptor != null) {
// toolwindow case
- processHandler = contentDescriptor.getProcessHandler();
+ return contentDescriptor.getProcessHandler();
}
else {
// main menu toolbar
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final RunContentDescriptor selectedContent =
project == null ? null : ExecutionManager.getInstance(project).getContentManager().getSelectedContent();
- processHandler = selectedContent == null ? null : selectedContent.getProcessHandler();
+ return selectedContent == null ? null : selectedContent.getProcessHandler();
}
- return processHandler;
}
@NotNull
restartRunProfile(project, null, null, null, null, null, executor, target, configuration, currentDescriptor);
}
+ @Override
+ public void restartRunProfile(@NotNull ExecutionEnvironment environment, @Nullable RunContentDescriptor currentDescriptor) {
+ restartRunProfile(RunnerRegistry.getInstance().findRunnerById(environment.getRunnerId()), environment, currentDescriptor);
+ }
+
@Override
public void restartRunProfile(@Nullable ProgramRunner runner,
@NotNull ExecutionEnvironment environment,
return;
}
}
- start(project, context, runner, runProfile, runnerSettings, configurationPerRunnerSettings, configuration, executor, target,
+ start(project, context, runner, runProfile, configuration, executor, target,
currentDescriptor);
}
};
@Nullable DataContext context,
@Nullable ProgramRunner runner,
@Nullable RunProfile runProfile,
- @Nullable RunnerSettings runnerSettings,
- @Nullable ConfigurationPerRunnerSettings configurationPerRunnerSettings,
@Nullable RunnerAndConfigurationSettings configuration,
@NotNull Executor executor,
@NotNull ExecutionTarget target,
*/
package com.intellij.execution.runners;
+import com.intellij.execution.ExecutionBundle;
+import com.intellij.execution.ExecutorRegistry;
+import com.intellij.execution.process.ProcessHandler;
+import com.intellij.execution.ui.RunContentDescriptor;
+import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.project.DumbAware;
import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import javax.swing.*;
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
/**
* @author Roman.Chernyatchik
*/
-public class FakeRerunAction extends AnAction implements DumbAware {
- protected static final List<RestartAction> registry = ContainerUtil.createLockFreeCopyOnWriteList();
+class FakeRerunAction extends AnAction implements DumbAware {
+ @SuppressWarnings("deprecation")
+ static final List<RestartAction> registry = ContainerUtil.createLockFreeCopyOnWriteList();
@Override
- public void actionPerformed(AnActionEvent e) {
- RestartAction action = RestartAction.findActualAction();
- if (action != null && action.isEnabled()) {
- action.actionPerformed(e);
+ public void update(AnActionEvent event) {
+ Presentation presentation = event.getPresentation();
+ ExecutionEnvironment environment = getEnvironment(event);
+ if (environment != null) {
+ presentation.setText(ExecutionBundle.message("rerun.configuration.action.name", environment.getRunProfile().getName()));
+
+ RunContentDescriptor descriptor = getDescriptor(event);
+ ProcessHandler processHandler = descriptor == null ? null : descriptor.getProcessHandler();
+ presentation.setIcon(processHandler != null && !processHandler.isProcessTerminated() ? AllIcons.Actions.Restart : environment.getExecutor().getIcon());
+ presentation.setEnabledAndVisible(isEnabled(event));
+ return;
}
+
+ FakeRerunAction action = findActualAction(event);
+ presentation.setEnabled(action != null && action.isEnabled(event));
+ presentation.setVisible(false);
}
@Override
- public void update(AnActionEvent e) {
- final Presentation presentation = e.getPresentation();
- RestartAction action = RestartAction.findActualAction();
- presentation.setEnabled(action != null && action.isEnabled());
- presentation.setVisible(false);
+ public void actionPerformed(AnActionEvent event) {
+ ExecutionEnvironment environment = getEnvironment(event);
+ if (environment != null) {
+ ExecutionUtil.restart(environment, getDescriptor(event));
+ return;
+ }
+
+ FakeRerunAction action = findActualAction(event);
+ if (action != null && action.isEnabled(event)) {
+ action.actionPerformed(event);
+ }
+ }
+
+ @Nullable
+ protected RunContentDescriptor getDescriptor(AnActionEvent event) {
+ return event.getData(LangDataKeys.RUN_CONTENT_DESCRIPTOR);
+ }
+
+ @Nullable
+ protected ExecutionEnvironment getEnvironment(AnActionEvent event) {
+ return event.getData(LangDataKeys.EXECUTION_ENVIRONMENT);
+ }
+
+ protected boolean isEnabled(AnActionEvent event) {
+ RunContentDescriptor descriptor = getDescriptor(event);
+ ProcessHandler processHandler = descriptor == null ? null : descriptor.getProcessHandler();
+ ExecutionEnvironment environment = getEnvironment(event);
+ return environment != null &&
+ !ExecutorRegistry.getInstance().isStarting(environment) &&
+ !(processHandler != null && processHandler.isProcessTerminating());
+ }
+
+ @Nullable
+ private JComponent getRunComponent(@NotNull AnActionEvent event) {
+ RunContentDescriptor descriptor = getDescriptor(event);
+ return descriptor == null ? null : descriptor.getComponent();
+ }
+
+ @Nullable
+ private static FakeRerunAction findActualAction(@NotNull final AnActionEvent event) {
+ if (registry.isEmpty()) {
+ return null;
+ }
+
+ List<FakeRerunAction> candidates = new ArrayList<FakeRerunAction>(registry);
+ Collections.sort(candidates, new Comparator<FakeRerunAction>() {
+ @Override
+ public int compare(@NotNull FakeRerunAction action1, @NotNull FakeRerunAction action2) {
+ boolean isActive1 = action1.isEnabled(event);
+ if (isActive1 != action2.isEnabled(event)) {
+ return isActive1 ? -1 : 1;
+ }
+
+ JComponent component1 = action1.getRunComponent(event);
+ JComponent component2 = action2.getRunComponent(event);
+ Window window1 = component1 == null ? null : SwingUtilities.windowForComponent(component1);
+ Window window2 = component2 == null ? null : SwingUtilities.windowForComponent(component2);
+ if (window1 == null) {
+ return 1;
+ }
+ if (window2 == null) {
+ return -1;
+ }
+
+ boolean showing1 = component1.isShowing();
+ boolean showing2 = component2.isShowing();
+ if (showing1 && !showing2) {
+ return -1;
+ }
+ if (showing2 && !showing1) {
+ return 1;
+ }
+ return (window1.isActive() ? -1 : 1);
+ }
+ });
+ return candidates.get(0);
}
}
package com.intellij.execution.runners;
-import com.intellij.execution.ExecutionManager;
-import com.intellij.execution.ExecutorRegistry;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.Disposable;
public static final String ID = "RerunTests";
private static final List<RerunInfo> REGISTRY = ContainerUtil.createLockFreeCopyOnWriteList();
- public static void register(@NotNull RunContentDescriptor descriptor,
- @NotNull ExecutionEnvironment env,
- @NotNull ProgramRunner runner) {
- final RerunInfo rerunInfo = new RerunInfo(descriptor, env, runner);
+ public static void register(@NotNull RunContentDescriptor descriptor, @NotNull ExecutionEnvironment environment) {
+ final RerunInfo rerunInfo = new RerunInfo(descriptor, environment);
REGISTRY.add(rerunInfo);
Disposer.register(descriptor, new Disposable() {
@Override
if (project == null) {
return;
}
- ExecutionManager executionManager = ExecutionManager.getInstance(project);
for (RerunInfo rerunInfo : REGISTRY) {
RunContentDescriptor descriptor = rerunInfo.getDescriptor();
if (!Disposer.isDisposed(descriptor)) {
- ExecutionEnvironment env = rerunInfo.getEnv();
- ProgramRunner runner = rerunInfo.getRunner();
ProcessHandler processHandler = descriptor.getProcessHandler();
if (processHandler != null && processHandler.isProcessTerminated()) {
- if (!ExecutorRegistry.getInstance().isStarting(project, env.getExecutor().getId(), runner.getRunnerId())) {
- executionManager.restartRunProfile(runner, env, descriptor);
- }
+ ExecutionUtil.restart(rerunInfo.getEnvironment(), descriptor);
}
}
}
}
private static class RerunInfo {
-
private final RunContentDescriptor myDescriptor;
private final ExecutionEnvironment myEnv;
- private final ProgramRunner myRunner;
- public RerunInfo(@NotNull RunContentDescriptor descriptor,
- @NotNull ExecutionEnvironment env,
- @NotNull ProgramRunner runner) {
+ public RerunInfo(@NotNull RunContentDescriptor descriptor, @NotNull ExecutionEnvironment env) {
myDescriptor = descriptor;
myEnv = env;
- myRunner = runner;
}
private RunContentDescriptor getDescriptor() {
return myDescriptor;
}
- private ExecutionEnvironment getEnv() {
+ private ExecutionEnvironment getEnvironment() {
return myEnv;
}
-
- private ProgramRunner getRunner() {
- return myRunner;
- }
}
-
}
*/
package com.intellij.execution.runners;
-import com.intellij.execution.*;
-import com.intellij.execution.process.ProcessHandler;
+import com.intellij.execution.Executor;
import com.intellij.execution.ui.RunContentDescriptor;
-import com.intellij.icons.AllIcons;
import com.intellij.openapi.Disposable;
-import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.actionSystem.AnAction;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.CustomShortcutSet;
+import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.project.DumbAware;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-import java.awt.*;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
+@Deprecated
+/**
+ * to remove in IDEA 15
+ */
public class RestartAction extends FakeRerunAction implements DumbAware, AnAction.TransparentUpdate, Disposable {
- private final ProgramRunner myRunner;
- @NotNull private final RunContentDescriptor myDescriptor;
- @NotNull private final Executor myExecutor;
- private final ExecutionEnvironment myEnvironment;
+ private final RunContentDescriptor descriptor;
+ private final ExecutionEnvironment environment;
- public RestartAction(@NotNull Executor executor,
- @NotNull RunContentDescriptor descriptor,
- @NotNull ExecutionEnvironment environment) {
+ public RestartAction(@NotNull RunContentDescriptor descriptor, @NotNull ExecutionEnvironment environment) {
//noinspection deprecation
- this(executor, null, descriptor, environment);
+ this(environment.getExecutor(), null, descriptor, environment);
}
@Deprecated
* @deprecated environment must provide runner id
* to remove in IDEA 15
*/
- public RestartAction(@NotNull Executor executor,
+ public RestartAction(@SuppressWarnings("UnusedParameters") @NotNull Executor executor,
@Nullable ProgramRunner runner,
@NotNull RunContentDescriptor descriptor,
@NotNull ExecutionEnvironment environment) {
Disposer.register(descriptor, this);
- registry.add(this);
+ FakeRerunAction.registry.add(this);
- myEnvironment = environment;
+ this.environment = runner == null ? environment : ExecutionEnvironmentBuilder.fix(environment, runner);
getTemplatePresentation().setEnabled(false);
- myRunner = runner;
- myDescriptor = descriptor;
- myExecutor = executor;
- // see IDEADEV-698
-
- if (descriptor.getRestarter() == null) {
- descriptor.setRestarter(new Runnable() {
- @Override
- public void run() {
- restart();
- }
- });
- }
+ this.descriptor = descriptor;
}
@Override
public void dispose() {
- registry.remove(this);
- }
-
- @Nullable
- static RestartAction findActualAction() {
- if (registry.isEmpty()) {
- return null;
- }
-
- List<RestartAction> candidates = new ArrayList<RestartAction>(registry);
- Collections.sort(candidates, new Comparator<RestartAction>() {
- @Override
- public int compare(@NotNull RestartAction action1, @NotNull RestartAction action2) {
- boolean isActive1 = action1.isEnabled();
- boolean isActive2 = action2.isEnabled();
- if (isActive1 != isActive2)
- return isActive1? - 1 : 1;
- Window window1 = SwingUtilities.windowForComponent(action1.myDescriptor.getComponent());
- Window window2 = SwingUtilities.windowForComponent(action2.myDescriptor.getComponent());
- if (window1 == null)
- return 1;
- if (window2 == null)
- return -1;
- boolean showing1 = action1.myDescriptor.getComponent().isShowing();
- boolean showing2 = action2.myDescriptor.getComponent().isShowing();
- if (showing1 && !showing2)
- return -1;
- if (showing2 && !showing1)
- return 1;
- return (window1.isActive() ? -1 : 1);
- }
- });
- return candidates.get(0);
+ FakeRerunAction.registry.remove(this);
}
@Override
- public void actionPerformed(final AnActionEvent e) {
- restart();
- }
-
- public void restart() {
- Project project = myEnvironment.getProject();
- if (!ExecutorRegistry.getInstance().isStarting(project, myExecutor.getId(), getRunnerId())) {
- ProgramRunner runner = myRunner == null ? RunnerRegistry.getInstance().findRunnerById(myEnvironment.getRunnerId()) : myRunner;
- ExecutionManager.getInstance(project).restartRunProfile(runner, myEnvironment, myDescriptor);
- }
- }
-
- private String getRunnerId() {
- return myRunner == null ? myEnvironment.getRunnerId() : myRunner.getRunnerId();
+ @NotNull
+ protected RunContentDescriptor getDescriptor(AnActionEvent event) {
+ return descriptor;
}
@Override
- public void update(final AnActionEvent event) {
- final Presentation presentation = event.getPresentation();
- String name = myEnvironment.getRunProfile().getName();
- ProcessHandler processHandler = myDescriptor.getProcessHandler();
- final boolean isRunning = processHandler != null && !processHandler.isProcessTerminated();
-
- presentation.setText(ExecutionBundle.message("rerun.configuration.action.name", name));
- presentation.setIcon(isRunning ? AllIcons.Actions.Restart : myExecutor.getIcon());
- presentation.setEnabled(isEnabled());
- }
-
- boolean isEnabled() {
- ProcessHandler processHandler = myDescriptor.getProcessHandler();
- return !ExecutorRegistry.getInstance().isStarting(myEnvironment.getProject(), myExecutor.getId(), getRunnerId()) &&
- !(processHandler != null && processHandler.isProcessTerminating());
+ @NotNull
+ protected ExecutionEnvironment getEnvironment(AnActionEvent event) {
+ return environment;
}
public void registerShortcut(JComponent component) {
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.intellij.diagnostic.logging.LogConsoleManagerBase;
import com.intellij.diagnostic.logging.LogFilesManager;
import com.intellij.diagnostic.logging.OutputFileUtil;
-import com.intellij.execution.DefaultExecutionResult;
-import com.intellij.execution.ExecutionManager;
-import com.intellij.execution.ExecutionResult;
-import com.intellij.execution.Executor;
+import com.intellij.execution.*;
import com.intellij.execution.configurations.RunConfigurationBase;
import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.configurations.SearchScopeProvider;
private final LogFilesManager myManager;
private RunnerLayoutUi myUi;
- private final Executor myExecutor;
/**
* @deprecated use {@link #RunContentBuilder(ProgramRunner, com.intellij.execution.ExecutionResult, ExecutionEnvironment)}
public RunContentBuilder(ExecutionResult executionResult, @NotNull ExecutionEnvironment environment) {
super(environment.getProject(), SearchScopeProvider.createSearchScope(environment.getProject(), environment.getRunProfile()));
- myExecutor = environment.getExecutor();
myManager = new LogFilesManager(environment.getProject(), this, this);
myExecutionResult = executionResult;
setEnvironment(environment);
runnerType = JAVA_RUNNER + "." + id;
}
}
- myUi = RunnerLayoutUi.Factory.getInstance(getProject()).create(runnerType, myExecutor.getId(), profile.getName(), this);
+ myUi = RunnerLayoutUi.Factory.getInstance(getProject()).create(runnerType, getEnvironment().getExecutor().getId(), profile.getName(), this);
myUi.getOptions().setMoveToGridActionEnabled(false).setMinimizeActionEnabled(false);
if (ApplicationManager.getApplication().isUnitTestMode()) {
if (console instanceof ObservableConsoleView && !ApplicationManager.getApplication().isUnitTestMode()) {
((ObservableConsoleView)console).addChangeListener(new ConsoleToFrontListener((RunConfigurationBase)profile,
getProject(),
- myExecutor,
+ getEnvironment().getExecutor(),
contentDescriptor,
myUi),
this);
final DefaultActionGroup consoleActions = new DefaultActionGroup();
if (console instanceof ConsoleView) {
AnAction[] actions = ((ConsoleView)console).createConsoleActions();
- for (AnAction goaction: actions) {
- consoleActions.add(goaction);
+ for (AnAction action: actions) {
+ consoleActions.add(action);
}
}
private ActionGroup createActionToolbar(final RunContentDescriptor contentDescriptor, final JComponent component) {
final DefaultActionGroup actionGroup = new DefaultActionGroup();
- final RestartAction restartAction = new RestartAction(myExecutor, contentDescriptor, getEnvironment());
+ final RestartAction restartAction = new RestartAction(contentDescriptor, getEnvironment());
restartAction.registerShortcut(component);
actionGroup.add(restartAction);
+ contentDescriptor.setRestarter(new Runnable() {
+ @Override
+ public void run() {
+ ExecutionUtil.restart(getEnvironment(), contentDescriptor);
+ }
+ });
if (myExecutionResult instanceof DefaultExecutionResult) {
final AnAction[] actions = ((DefaultExecutionResult)myExecutionResult).getRestartActions();
actionGroup.add(myUi.getOptions().getLayoutActions());
actionGroup.addSeparator();
actionGroup.add(PinToolwindowTabAction.getPinAction());
- actionGroup.add(new CloseAction(myExecutor, contentDescriptor, getProject()));
+ actionGroup.add(new CloseAction(getEnvironment().getExecutor(), contentDescriptor, getProject()));
final String helpId = contentDescriptor.getHelpId();
- actionGroup.add(new ContextHelpAction(helpId != null ? helpId : myExecutor.getHelpId()));
+ actionGroup.add(new ContextHelpAction(helpId != null ? helpId : getEnvironment().getExecutor().getHelpId()));
return actionGroup;
}
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
public class
JBRunnerTabs extends JBTabsImpl {
- public JBRunnerTabs(@Nullable Project project, ActionManager actionManager, IdeFocusManager focusManager, @NotNull Disposable parent) {
+ public JBRunnerTabs(@Nullable Project project, @NotNull ActionManager actionManager, IdeFocusManager focusManager, @NotNull Disposable parent) {
super(project, actionManager, focusManager, parent);
}
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private ContentManager myManager;
private final RunnerLayout myLayoutSettings;
- private final ActionManager myActionManager;
+ @NotNull private final ActionManager myActionManager;
private final String mySessionName;
private final MyComponent myComponent = new MyComponent();
@NotNull String sessionName) {
myProject = project;
myRunnerUi = ui;
- myLayoutSettings = settings;
+ myLayoutSettings = settings;
myActionManager = actionManager;
mySessionName = sessionName;
myFocusManager = focusManager;
}
private void rebuildTabPopup() {
- if (myTabs == null) return;
+ initUi();
myTabs.setPopupGroup(getCellPopupGroup(TAB_POPUP_PLACE), TAB_POPUP_PLACE, true);
- final ArrayList<GridImpl> grids = getGrids();
- for (GridImpl each : grids) {
+ for (GridImpl each : getGrids()) {
each.rebuildTabPopup();
}
}
}
}
+ @SuppressWarnings("NullableProblems")
@Override
- @NotNull
public String getName() {
return RunnerContentUi.this.getName();
}
return myManager;
}
+ @NotNull
@Override
public ActionManager getActionManager() {
return myActionManager;
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import javax.swing.tree.*;
import java.awt.*;
import java.awt.event.*;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import java.util.*;
import java.util.List;
protected void doSort() {
Pair<ElementNode, List<ElementNode>> pair = storeSelection();
- Enumeration<ParentNode> children = getRootNodeChildren();
+ Enumeration<TreeNode> children = getRootNodeChildren();
while (children.hasMoreElements()) {
- ParentNode classNode = children.nextElement();
+ ParentNode classNode = (ParentNode)children.nextElement();
sortNode(classNode, myComparator);
myTreeModel.nodeStructureChanged(classNode);
}
private static void sortNode(ParentNode node, final Comparator<ElementNode> sortComparator) {
ArrayList<MemberNode> arrayList = new ArrayList<MemberNode>();
- Enumeration<MemberNode> children = node.children();
+ Enumeration<TreeNode> children = node.children();
while (children.hasMoreElements()) {
- arrayList.add(children.nextElement());
+ arrayList.add((MemberNode)children.nextElement());
}
Collections.sort(arrayList, sortComparator);
DefaultMutableTreeNode root = getRootNode();
if (!myShowClasses || myContainerNodes.isEmpty()) {
List<ParentNode> otherObjects = new ArrayList<ParentNode>();
- Enumeration<ParentNode> children = getRootNodeChildren();
+ Enumeration<TreeNode> children = getRootNodeChildren();
ParentNode newRoot = new ParentNode(null, new MemberChooserObjectBase(getAllContainersNodeName()), new Ref<Integer>(0));
while (children.hasMoreElements()) {
- final ParentNode nextElement = children.nextElement();
+ final ParentNode nextElement = (ParentNode)children.nextElement();
if (nextElement instanceof ContainerNode) {
final ContainerNode containerNode = (ContainerNode)nextElement;
- Enumeration<MemberNode> memberNodes = containerNode.children();
+ Enumeration<TreeNode> memberNodes = containerNode.children();
List<MemberNode> memberNodesList = new ArrayList<MemberNode>();
while (memberNodes.hasMoreElements()) {
- memberNodesList.add(memberNodes.nextElement());
+ memberNodesList.add((MemberNode)memberNodes.nextElement());
}
for (MemberNode memberNode : memberNodesList) {
newRoot.add(memberNode);
if (newRoot.children().hasMoreElements()) root.add(newRoot);
}
else {
- Enumeration<ParentNode> children = getRootNodeChildren();
+ Enumeration<TreeNode> children = getRootNodeChildren();
while (children.hasMoreElements()) {
- ParentNode allClassesNode = children.nextElement();
- Enumeration<MemberNode> memberNodes = allClassesNode.children();
+ ParentNode allClassesNode = (ParentNode)children.nextElement();
+ Enumeration<TreeNode> memberNodes = allClassesNode.children();
ArrayList<MemberNode> arrayList = new ArrayList<MemberNode>();
while (memberNodes.hasMoreElements()) {
- arrayList.add(memberNodes.nextElement());
+ arrayList.add((MemberNode)memberNodes.nextElement());
}
Collections.sort(arrayList, myComparator);
for (MemberNode memberNode : arrayList) {
return IdeBundle.message("node.memberchooser.all.classes");
}
- private Enumeration<ParentNode> getRootNodeChildren() {
+ private Enumeration<TreeNode> getRootNodeChildren() {
return getRootNode().children();
}
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
public abstract class BaseToolManager<T extends Tool> implements ExportableApplicationComponent {
- private final ActionManagerEx myActionManager;
+ @NotNull private final ActionManagerEx myActionManager;
private final SchemesManager<ToolsGroup<T>, ToolsGroup<T>> mySchemesManager;
- public BaseToolManager(ActionManagerEx actionManagerEx, SchemesManagerFactory factory) {
+ public BaseToolManager(@NotNull ActionManagerEx actionManagerEx, SchemesManagerFactory factory) {
myActionManager = actionManagerEx;
mySchemesManager = factory.createSchemesManager(
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.util.Enumeration;
private static Rectangle getExpandedNodesRect(JTree tree, DefaultMutableTreeNode node, TreePath path) {
Rectangle rect = tree.getRowBounds(tree.getRowForPath(path));
if (tree.isExpanded(path)) {
- Enumeration<DefaultMutableTreeNode> children = node.children();
+ Enumeration<TreeNode> children = node.children();
while (children.hasMoreElements()) {
- DefaultMutableTreeNode child = children.nextElement();
+ DefaultMutableTreeNode child = (DefaultMutableTreeNode)children.nextElement();
TreePath childPath = path.pathByAddingChild(child);
assert !path.equals(childPath) : path+";"+child;
rect = union(rect, getExpandedNodesRect(tree, child, childPath));
--- /dev/null
+/*
+ * Copyright 2000-2009 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.ui.popup;
+
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+
+public abstract class ListItemDescriptorAdapter<T> implements ListItemDescriptor<T> {
+ @Nullable
+ @Override
+ public String getCaptionAboveOf(T value) {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public String getTooltipFor(T value) {
+ return null;
+ }
+
+ @Override
+ public Icon getIconFor(T value) {
+ return null;
+ }
+
+ @Override
+ public boolean hasSeparatorAboveOf(T value) {
+ return false;
+ }
+}
\ No newline at end of file
private JBEditorTabsPainter myDefaultPainter = new DefaultEditorTabsPainter();
- public JBEditorTabs(@Nullable Project project, ActionManager actionManager, IdeFocusManager focusManager, @NotNull Disposable parent) {
+ public JBEditorTabs(@Nullable Project project, @NotNull ActionManager actionManager, IdeFocusManager focusManager, @NotNull Disposable parent) {
super(project, actionManager, focusManager, parent);
}
import com.intellij.ui.*;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.awt.RelativeRectangle;
+import com.intellij.ui.components.OrphanGuardian;
import com.intellij.ui.switcher.QuickActionProvider;
import com.intellij.ui.switcher.SwitchProvider;
import com.intellij.ui.switcher.SwitchTarget;
import com.intellij.ui.tabs.impl.singleRow.SingleRowPassInfo;
import com.intellij.ui.tabs.impl.table.TableLayout;
import com.intellij.ui.tabs.impl.table.TablePassInfo;
+import com.intellij.util.Consumer;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.Animator;
public static final Color MAC_AQUA_BG_COLOR = Gray._200;
- final ActionManager myActionManager;
+ @NotNull final ActionManager myActionManager;
private final List<TabInfo> myVisibleInfos = new ArrayList<TabInfo>();
private final Map<TabInfo, Integer> myHiddenInfos = new HashMap<TabInfo, Integer>();
private JBTabsPosition myPosition = JBTabsPosition.top;
private final TabsBorder myBorder = new TabsBorder(this);
- private BaseNavigationAction myNextAction;
- private BaseNavigationAction myPrevAction;
+ private final BaseNavigationAction myNextAction;
+ private final BaseNavigationAction myPrevAction;
private boolean myTabDraggingEnabled;
private DragHelper myDragHelper;
this(project, ActionManager.getInstance(), focusManager, parent);
}
- public JBTabsImpl(@Nullable Project project, ActionManager actionManager, IdeFocusManager focusManager, @NotNull Disposable parent) {
+ public JBTabsImpl(@Nullable Project project, @NotNull ActionManager actionManager, IdeFocusManager focusManager, @NotNull Disposable parent) {
myProject = project;
myActionManager = actionManager;
myFocusManager = focusManager != null ? focusManager : IdeFocusManager.getGlobalInstance();
myNavigationActions = new DefaultActionGroup();
- if (myActionManager != null) {
- myNextAction = new SelectNextAction(this, myActionManager);
- myPrevAction = new SelectPreviousAction(this, myActionManager);
+ myNextAction = new SelectNextAction(this, myActionManager);
+ myPrevAction = new SelectPreviousAction(this, myActionManager);
- myNavigationActions.add(myNextAction);
- myNavigationActions.add(myPrevAction);
- }
+ myNavigationActions.add(myNextAction);
+ myNavigationActions.add(myPrevAction);
setUiDecorator(null);
}
}
};
+ putClientProperty(OrphanGuardian.CLIENT_PROPERTY_KEY, new OrphanGuardian() {
+
+ @Override
+ public void iterateOrphans(Consumer<JComponent> consumer) {
+ for (TabInfo info : getVisibleInfos()) {
+ if (info == mySelectedInfo) continue;
+ consumer.consume(info.getComponent());
+ }
+ }
+ });
}
protected SingleRowLayout createSingleRowLayout() {
}
private void addTimerUpdate() {
- if (myActionManager != null && !myListenerAdded) {
+ if (!myListenerAdded) {
myActionManager.addTimerListener(500, this);
myListenerAdded = true;
}
}
private void removeTimerUpdate() {
- if (myActionManager != null && myListenerAdded) {
+ if (myListenerAdded) {
myActionManager.removeTimerListener(this);
myListenerAdded = false;
}
final ActionGroup group = info.getGroup();
final JComponent side = info.getSideComponent();
- if (group != null && myTabs.myActionManager != null) {
+ if (group != null) {
final String place = info.getPlace();
ActionToolbar toolbar =
myTabs.myActionManager.createActionToolbar(place != null ? place : ActionPlaces.UNKNOWN, group, myTabs.myHorizontalSide);
}
private static boolean isChanged(Object oldObject, Object newObject) {
- if (oldObject == null && newObject == null) return false;
- return oldObject != null && !oldObject.equals(newObject) || newObject != null && !newObject.equals(oldObject);
+ return !Comparing.equal(oldObject, newObject);
}
@Override
}
private abstract static class BaseNavigationAction extends AnAction {
-
private final ShadowAction myShadow;
- private final ActionManager myActionManager;
+ @NotNull private final ActionManager myActionManager;
private final JBTabsImpl myTabs;
- protected BaseNavigationAction(final String copyFromID, JBTabsImpl tabs, ActionManager mgr) {
+ protected BaseNavigationAction(@NotNull String copyFromID, @NotNull JBTabsImpl tabs, @NotNull ActionManager mgr) {
myActionManager = mgr;
myTabs = tabs;
myShadow = new ShadowAction(this, myActionManager.getAction(copyFromID), tabs);
private static class SelectNextAction extends BaseNavigationAction {
- private SelectNextAction(JBTabsImpl tabs, ActionManager mgr) {
+ private SelectNextAction(JBTabsImpl tabs, @NotNull ActionManager mgr) {
super(IdeActions.ACTION_NEXT_TAB, tabs, mgr);
}
}
private static class SelectPreviousAction extends BaseNavigationAction {
- private SelectPreviousAction(JBTabsImpl tabs, ActionManager mgr) {
+ private SelectPreviousAction(JBTabsImpl tabs, @NotNull ActionManager mgr) {
super(IdeActions.ACTION_PREVIOUS_TAB, tabs, mgr);
}
@Override
public String getHTMLFooter() {
- return "Keymap scheme can be later changed in " + CommonBundle.settingsTitle() + " | Keymap";
+ return "Keymap scheme can be changed later in " + CommonBundle.settingsTitle() + " | Keymap";
}
}
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
myComponent.myLafComboBox.setModel(new DefaultComboBoxModel(LafManager.getInstance().getInstalledLookAndFeels()));
myComponent.myLafComboBox.setRenderer(new LafComboBoxRenderer());
- Dictionary<Integer, JLabel> delayDictionary = new Hashtable<Integer, JLabel>();
+ Dictionary<Integer, JComponent> delayDictionary = new Hashtable<Integer, JComponent>();
delayDictionary.put(new Integer(0), new JLabel("0"));
delayDictionary.put(new Integer(1200), new JLabel("1200"));
//delayDictionary.put(new Integer(2400), new JLabel("2400"));
myComponent.myAlphaModeRatioSlider.setSize(100, 50);
@SuppressWarnings({"UseOfObsoleteCollectionType"})
- Dictionary<Integer, JLabel> dictionary = new Hashtable<Integer, JLabel>();
+ Dictionary<Integer, JComponent> dictionary = new Hashtable<Integer, JComponent>();
dictionary.put(new Integer(0), new JLabel("0%"));
dictionary.put(new Integer(50), new JLabel("50%"));
dictionary.put(new Integer(100), new JLabel("100%"));
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private final ActionButtonLook myButtonLook = null;
private final ActionButtonLook myMinimalButtonLook = new InplaceActionButtonLook();
private final DataManager myDataManager;
- protected final ActionManagerEx myActionManager;
+ @NotNull protected final ActionManagerEx myActionManager;
private Rectangle myAutoPopupRec;
@NotNull final ActionGroup actionGroup,
final boolean horizontal,
DataManager dataManager,
- ActionManagerEx actionManager,
+ @NotNull ActionManagerEx actionManager,
KeymapManagerEx keymapManager) {
this(place, actionGroup, horizontal, false, dataManager, actionManager, keymapManager, false);
}
final boolean horizontal,
final boolean decorateButtons,
DataManager dataManager,
- ActionManagerEx actionManager,
+ @NotNull ActionManagerEx actionManager,
KeymapManagerEx keymapManager) {
this(place, actionGroup, horizontal, decorateButtons, dataManager, actionManager, keymapManager, false);
}
final boolean horizontal,
final boolean decorateButtons,
DataManager dataManager,
- ActionManagerEx actionManager,
+ @NotNull ActionManagerEx actionManager,
KeymapManagerEx keymapManager,
boolean updateActionsNow) {
super(null);
final ActionGroup actionGroup,
final boolean horizontal,
final DataManager dataManager,
- final ActionManagerEx actionManager,
+ @NotNull ActionManagerEx actionManager,
final KeymapManagerEx keymapManager,
JComponent parent) {
super(place, actionGroup, horizontal, false, dataManager, actionManager, keymapManager, true);
}
@Override
- public void restart(boolean exitConfirmed) {
- exit(exitConfirmed, exitConfirmed, true, true);
+ public void restart(final boolean exitConfirmed) {
+ exit(false, exitConfirmed, true, true);
}
/*
exiting = true;
try {
- if (!force && getDefaultModalityState() != ModalityState.NON_MODAL) {
+ if (!force && !exitConfirmed && getDefaultModalityState() != ModalityState.NON_MODAL) {
return;
}
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
void setErrorStripeVisible(boolean val);
- void setErrorStripeRenderer(ErrorStripeRenderer renderer);
+ void setErrorStripeRenderer(@NotNull ErrorStripeRenderer renderer);
ErrorStripeRenderer getErrorStripeRenderer();
void addErrorMarkerListener(@NotNull ErrorStripeListener listener, @NotNull Disposable parent);
public Insets getBorderInsets(Component c) {
Container splitters = SwingUtilities.getAncestorOfClass(EditorsSplitters.class, c);
boolean thereIsSomethingAbove = !SystemInfo.isMac || UISettings.getInstance().SHOW_MAIN_TOOLBAR || UISettings.getInstance().SHOW_NAVIGATION_BAR ||
- myProject != null && !ToolWindowManagerEx.getInstanceEx(myProject).getIdsOn(ToolWindowAnchor.TOP).isEmpty();
+ toolWindowIsNotEmpty();
return splitters == null ? super.getBorderInsets(c) : new Insets(thereIsSomethingAbove ? 1 : 0, 0, 0, 0);
}
+ public boolean toolWindowIsNotEmpty() {
+ if (myProject == null) return false;
+ ToolWindowManagerEx m = ToolWindowManagerEx.getInstanceEx(myProject);
+ if (m == null) return false;
+ return !m.getIdsOn(ToolWindowAnchor.TOP).isEmpty();
+ }
+
@Override
public boolean isBorderOpaque() {
return true;
}
@Override
- public void setErrorStripeRenderer(ErrorStripeRenderer renderer) {
+ public void setErrorStripeRenderer(@NotNull ErrorStripeRenderer renderer) {
assertIsDispatchThread();
if (myErrorStripeRenderer instanceof Disposable) {
Disposer.dispose((Disposable)myErrorStripeRenderer);
myList = new JBList();
myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- myList.setCellRenderer(new GroupedItemsListRenderer(new ListItemDescriptor() {
+ myList.setCellRenderer(new GroupedItemsListRenderer(new ListItemDescriptorAdapter() {
public String getTextFor(final Object value) {
final LookupFile file = (LookupFile)value;
}
- public String getTooltipFor(final Object value) {
- return null;
- }
-
public Icon getIconFor(final Object value) {
final LookupFile file = (LookupFile)value;
return file.getIcon();
DocumentEx documentEx = (DocumentEx)document;
documentEx.setReadOnly(false);
LoadTextUtil.setCharsetWasDetectedFromBytes(file, null);
+ file.setBOM(null); // reset BOM in case we had one and the external change stripped it away
documentEx.replaceText(LoadTextUtil.loadText(file), file.getModificationStamp());
documentEx.setReadOnly(!wasWritable);
}
*/
private final class MyVirtualFileListener extends VirtualFileAdapter {
@Override
- public void beforeFileDeletion(VirtualFileEvent e) {
+ public void beforeFileDeletion(@NotNull VirtualFileEvent e) {
assertDispatchThread();
boolean moveFocus = moveFocusOnDelete();
}
@Override
- public void propertyChanged(VirtualFilePropertyEvent e) {
+ public void propertyChanged(@NotNull VirtualFilePropertyEvent e) {
if (VirtualFile.PROP_NAME.equals(e.getPropertyName())) {
assertDispatchThread();
final VirtualFile file = e.getFile();
}
@Override
- public void fileMoved(VirtualFileMoveEvent e) {
+ public void fileMoved(@NotNull VirtualFileMoveEvent e) {
final VirtualFile file = e.getFile();
final VirtualFile[] openFiles = getOpenFiles();
for (final VirtualFile openFile : openFiles) {
SimpleNode node = myTree.getNodeFor(path);
if (node instanceof FilteringTreeStructure.FilteringNode) {
Object delegate = ((FilteringTreeStructure.FilteringNode)node).getDelegate();
- if (delegate instanceof EditorNode) {
+ while (delegate instanceof EditorNode) {
EditorNode editor = (EditorNode)delegate;
ConfigurableGroup group = editor.getGroup();
if (group != null) {
name = group.getDisplayName();
+ break;
}
+ delegate = editor.getParent();
}
}
if (name != null) {
bounds.height = height;
}
g.setColor(myTree.getBackground());
- g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
- g.setColor(myTree.getForeground());
- g.drawLine(0, bounds.height, bounds.width, bounds.height);
+ if (g instanceof Graphics2D) {
+ int h = bounds.height / 3;
+ int y = bounds.y + bounds.height - h;
+ g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height - h);
+ ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(
+ 0, y, g.getColor(),
+ 0, y + h, ColorUtil.toAlpha(g.getColor(), 0)));
+ g.fillRect(bounds.x, y, bounds.width, h);
+ }
+ else {
+ g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
+ }
mySeparator.setBounds(bounds);
mySeparator.paint(g);
}
import com.intellij.concurrency.JobScheduler;
import com.intellij.openapi.Disposable;
-import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.ex.ApplicationEx;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-public class ProgressManagerImpl extends ProgressManager implements Disposable{
+public class ProgressManagerImpl extends ProgressManager implements Disposable {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.progress.impl.ProgressManagerImpl");
private final AtomicInteger myCurrentUnsafeProgressCount = new AtomicInteger(0);
private final AtomicInteger myCurrentModalProgressCount = new AtomicInteger(0);
private static final boolean DISABLED = "disabled".equals(System.getProperty("idea.ProcessCanceledException"));
private final ScheduledFuture<?> myCheckCancelledFuture;
- public ProgressManagerImpl(Application application) {
+ public ProgressManagerImpl() {
if (DISABLED) {
myCheckCancelledFuture = null;
}
@Override
public void dispose() {
- stopCheckCanceled();
- }
-
- private void stopCheckCanceled() {
if (myCheckCancelledFuture != null) myCheckCancelledFuture.cancel(false);
}
package com.intellij.ui.popup.list;
import com.intellij.icons.AllIcons;
-import com.intellij.openapi.ui.popup.ListItemDescriptor;
+import com.intellij.openapi.ui.popup.ListItemDescriptorAdapter;
import com.intellij.openapi.ui.popup.ListPopupStep;
import com.intellij.ui.ColorUtil;
import com.intellij.util.ui.UIUtil;
private final ListPopupImpl myPopup;
public PopupListElementRenderer(final ListPopupImpl aPopup) {
- super(new ListItemDescriptor() {
+ super(new ListItemDescriptorAdapter() {
@Override
public String getTextFor(Object value) {
return aPopup.getListStep().getTextFor(value);
}
- @Override
- public String getTooltipFor(Object value) {
- return null;
- }
-
@Override
public Icon getIconFor(Object value) {
return aPopup.getListStep().getIconFor(value);
checkbox.show.code.folding.outline=Show code folding outline
group.tab.appearance=Tab Appearance
editbox.tab.limit=Tab limit:
-editbox.tab.title.limit=Tab title limit:
+editbox.tab.title.limit=Tab title limit (characters):
combobox.editor.tab.placement=Placement:
checkbox.editor.tabs.in.single.row=Show tabs in single row
checkbox.editor.tabs.show.close.button=Show "close" button on editor tabs
waiting.for.vm.detach.progress.text=Waiting for process detach
restart.error.message.title=Restart Error
rerun.configuration.action.name=Rerun ''{0}''
+stop.configuration.action.name=Stop ''{0}''
rerun.singleton.confirmation.message=''{0}'' is single-instance run configuration.\nAre you sure you want to stop {1, choice, 1#the running one|2#{1, number} running instances}?
rerun.confirmation.button.text=Stop and Rerun
rerun.confirmation.checkbox=Confirm rerun with process termination
unused.library.backward.analysis.job.description=Perform backward analysis
inspection.duplicates.option.report.propertykey.expressions=&Ignore @PropertyKey expressions
inspection.same.parameter.fix.name=Inline value ''{1}'' for parameter ''{0}''
-fix.all.inspection.problems.in.file=Fix all ''{0}'' problems
+fix.all.inspection.problems.in.file=Fix all ''{0}'' problems in file
cleanup.in.file=Cleanup code
cleanup.in.scope=Cleanup code on...
severities.default.settings.message=Edit Settings|Colors \\& Fonts
</group>
<group id="XDebugger.ToolWindow.LeftToolbar">
+ <reference ref="Rerun"/>
<reference ref="Resume"/>
<reference ref="Pause"/>
<reference ref="Stop"/>
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.intellij.history.integration.ui.actions.LocalHistoryAction;
import com.intellij.history.integration.ui.actions.ShowHistoryAction;
import com.intellij.history.integration.ui.actions.ShowSelectionHistoryAction;
-import com.intellij.openapi.actionSystem.AnAction;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
+import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
return null;
}
};
- return new AnActionEvent(null, dc, "", a.getTemplatePresentation(), null, -1);
+ return new AnActionEvent(null, dc, "", a.getTemplatePresentation(), ActionManager.getInstance(), -1);
}
}
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package com.intellij.ui.tabs.impl;
import com.intellij.icons.AllIcons;
+import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.IconLoader;
final JFrame frame = new JFrame();
frame.getContentPane().setLayout(new BorderLayout(0, 0));
final int[] count = new int[1];
- final JBTabsImpl tabs = new JBTabsImpl(null, null, null, Disposer.newDisposable());
+ final JBTabsImpl tabs = new JBTabsImpl(null, ActionManager.getInstance(), null, Disposer.newDisposable());
tabs.setTestMode(true);
private void visitLiteral(PsiElement literal) {
String value = literal.getText();
- if (value.length() <= 2) {
- return;
- }
- if ((value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') ||
- (value.charAt(0) == '\'' && value.charAt(value.length() - 1) == '\'')) {
-
+ if (value.length() > 2 && StringUtil.isQuotedString(value)) {
if (mySubstitutionPatterns == null) {
final String[] prefixes = myGlobalVisitor.getContext().getPattern().getTypedVarPrefixes();
mySubstitutionPatterns = createPatterns(prefixes);
ex = e;
}
assertNotNull(ex);
+
+ String pattern3 = "class $Class$ { \n" +
+ " class $n$$FieldType$ $FieldName$ = $Init$;\n" +
+ "}";
+ try {
+ findMatchesCount(source, pattern3);
+ } catch (MalformedPatternException e) {
+ ex = e;
+ }
+ assertNotNull(ex);
}
}
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
getApplication().getPicoContainer().registerComponent(new AbstractComponentAdapter(ProgressManager.class.getName(), Object.class) {
@Override
public Object getComponentInstance(PicoContainer container) throws PicoInitializationException, PicoIntrospectionException {
- return new ProgressManagerImpl(getApplication());
+ return new ProgressManagerImpl();
}
@Override
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.intellij.util.containers.HashMap;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.PropertyKey;
import java.awt.*;
@NonNls
private static final String REGISTRY_BUNDLE = "misc.registry";
- private final LinkedHashMap<String, String> myUserProperties = new LinkedHashMap<String, String>();
+ private final Map<String, String> myUserProperties = new LinkedHashMap<String, String>();
private final Map<String, String> myLoadedUserProperties = new HashMap<String, String>();
private final Map<String, RegistryValue> myValues = new ConcurrentHashMap<String, RegistryValue>();
private static final Registry ourInstance = new Registry();
- public static RegistryValue get(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) String key) {
+ @NotNull
+ public static RegistryValue get(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) @NotNull String key) {
final Registry registry = getInstance();
- if (registry.myValues.containsKey(key)) {
- return registry.myValues.get(key);
- }
- else {
- final RegistryValue value = new RegistryValue(registry, key);
+ RegistryValue value = registry.myValues.get(key);
+ if (value == null) {
+ value = new RegistryValue(registry, key);
registry.myValues.put(key, value);
- return value;
}
+ return value;
}
- public static boolean is(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) String key) {
+ public static boolean is(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) @NotNull String key) throws MissingResourceException {
return get(key).asBoolean();
}
- public static boolean is(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) String key, boolean defaultValue) {
+ public static boolean is(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) @NotNull String key, boolean defaultValue) {
try {
return get(key).asBoolean();
}
}
}
- public static int intValue(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) String key) {
+ public static int intValue(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) @NotNull String key) throws MissingResourceException {
return get(key).asInteger();
}
- public static int intValue(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) String key, int defaultValue) {
+ public static int intValue(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) @NotNull String key, int defaultValue) {
try {
return get(key).asInteger();
}
}
}
- public static double doubleValue(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) String key) {
+ public static double doubleValue(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) @NotNull String key) throws MissingResourceException {
return get(key).asDouble();
}
- public static String stringValue(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) String key) {
+ @NotNull
+ public static String stringValue(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) @NotNull String key) throws MissingResourceException {
return get(key).asString();
}
- public static Color getColor(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) String key, Color defaultValue) {
+ public static Color getColor(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) @NotNull String key, Color defaultValue) throws MissingResourceException {
return get(key).asColor(defaultValue);
}
+ @NotNull
static ResourceBundle getBundle() {
ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
if (bundle == null) {
return ourInstance;
}
+ @NotNull
public Element getState() {
final Element state = new Element("registry");
for (String eachKey : myUserProperties.keySet()) {
return state;
}
- public void loadState(Element state) {
+ public void loadState(@NotNull Element state) {
final List entries = state.getChildren("entry");
for (Object each : entries) {
final Element eachEntry = (Element) each;
}
}
+ @NotNull
Map<String, String> getUserProperties() {
return myUserProperties;
}
+ @NotNull
public static List<RegistryValue> getAll() {
final ResourceBundle bundle = getBundle();
final Enumeration<String> keys = bundle.getKeys();
- final ArrayList<RegistryValue> result = new ArrayList<RegistryValue>();
+ List<RegistryValue> result = new ArrayList<RegistryValue>();
while (keys.hasMoreElements()) {
final String each = keys.nextElement();
}
public void restoreDefaults() {
- final HashMap<String, String> old = new HashMap<String, String>();
+ Map<String, String> old = new HashMap<String, String>();
old.putAll(myUserProperties);
for (String each : old.keySet()) {
get(each).resetToDefault();
return isRestartNeeded(myUserProperties) || isRestartNeeded(myLoadedUserProperties);
}
- private static boolean isRestartNeeded(Map<String, String> map) {
+ private static boolean isRestartNeeded(@NotNull Map<String, String> map) {
for (String s : map.keySet()) {
final RegistryValue eachValue = get(s);
if (eachValue.isRestartRequired() && eachValue.isChangedSinceAppStart()) return true;
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private Double myDoubleCachedValue;
private Boolean myBooleanCachedValue;
- RegistryValue(Registry registry, String key) {
+ RegistryValue(@NotNull Registry registry, @NotNull String key) {
myRegistry = registry;
myKey = key;
}
+ @NotNull
public String getKey() {
return myKey;
}
+ @NotNull
public String asString() {
final String value = get(myKey, null, true);
assert value != null : myKey;
return defaultValue;
}
+ @NotNull
public String getDescription() {
return get(myKey + ".description", "", false);
}
return !asString().equals(getBundleValue(myKey, false));
}
- private String get(String key, String defaultValue, boolean isValue) {
+ private String get(@NotNull String key, String defaultValue, boolean isValue) throws MissingResourceException {
if (isValue) {
if (myStringCachedValue == null) {
myStringCachedValue = _get(key, defaultValue, isValue);
- }
- if (isBoolean()) {
- myStringCachedValue = Boolean.valueOf(myStringCachedValue).toString();
+ if (isBoolean()) {
+ myStringCachedValue = Boolean.valueOf(myStringCachedValue).toString();
+ }
}
return myStringCachedValue;
}
- else {
- return _get(key, defaultValue, isValue);
- }
+ return _get(key, defaultValue, isValue);
}
- private String _get(String key, String defaultValue, boolean mustExistInBundle) {
+ private String _get(@NotNull String key, String defaultValue, boolean mustExistInBundle) throws MissingResourceException {
final String userValue = myRegistry.getUserProperties().get(key);
- if (userValue == null) {
- String systemProperty = System.getProperty(key);
- if (systemProperty != null) {
- return systemProperty;
- }
- final String bundleValue = getBundleValue(key, mustExistInBundle);
- if (bundleValue != null) {
- return bundleValue;
- }
- else {
- return defaultValue;
- }
- }
- else {
+ if (userValue != null) {
return userValue;
}
+ String systemProperty = System.getProperty(key);
+ if (systemProperty != null) {
+ return systemProperty;
+ }
+ final String bundleValue = getBundleValue(key, mustExistInBundle);
+ if (bundleValue != null) {
+ return bundleValue;
+ }
+ return defaultValue;
}
- private String getBundleValue(String key, boolean mustExist) {
+ private static String getBundleValue(@NotNull String key, boolean mustExist) throws MissingResourceException {
try {
return Registry.getBundle().getString(key);
}
+ " loaded by " + ((Class)anInterface).getClassLoader();
}
+ @NotNull
public static Class<?> getRawType(@NotNull Type type) {
if (type instanceof Class) {
return (Class)type;
});
}
+ @NotNull
public static List<Method> getClassPublicMethods(@NotNull Class aClass) {
return getClassPublicMethods(aClass, false);
}
-
+
+ @NotNull
public static List<Method> getClassPublicMethods(@NotNull Class aClass, boolean includeSynthetic) {
Method[] methods = aClass.getMethods();
return includeSynthetic ? Arrays.asList(methods) : filterRealMethods(methods);
}
+ @NotNull
public static List<Method> getClassDeclaredMethods(@NotNull Class aClass) {
return getClassDeclaredMethods(aClass, false);
}
Method[] methods = aClass.getDeclaredMethods();
return includeSynthetic ? Arrays.asList(methods) : filterRealMethods(methods);
}
+
@NotNull
public static List<Field> getClassDeclaredFields(@NotNull Class aClass) {
Field[] fields = aClass.getDeclaredFields();
return Arrays.asList(fields);
}
- private static List<Method> filterRealMethods(Method[] methods) {
+ @NotNull
+ private static List<Method> filterRealMethods(@NotNull Method[] methods) {
List<Method> result = ContainerUtil.newArrayList();
for (Method method : methods) {
if (!method.isSynthetic()) {
}
@Nullable
- public static Class getMethodDeclaringClass(@NotNull Class<?> instanceClass, @NonNls @NotNull String name, @NotNull Class... parameters) {
- Method method = getMethod(instanceClass, name, parameters);
+ public static Class getMethodDeclaringClass(@NotNull Class<?> instanceClass, @NonNls @NotNull String methodName, @NotNull Class... parameters) {
+ Method method = getMethod(instanceClass, methodName, parameters);
return method == null ? null : method.getDeclaringClass();
}
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
}
+ public int size() {
+ synchronized (myQueue) {
+ return myQueue.size();
+ }
+ }
+
// process all queue in current thread
public void drain() {
int processed = 0;
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Date: 7/12/11
* Time: 1:34 PM
*/
-class IntToIntBtree {
+public class IntToIntBtree {
public static int version() {
return 4 + (IOUtil.ourByteBuffersUseNativeByteOrder ? 0xFF : 0);
}
private boolean hasZeroKey;
private int zeroKeyValue;
- private boolean isLarge = true;
+ private final boolean isLarge = true;
private final ResizeableMappedFile storage;
private final boolean offloadToSiblingsBeforeSplit = false;
- private boolean indexNodeIsHashTable = true;
+ private final boolean indexNodeIsHashTable = true;
final int metaDataLeafPageLength;
final int hashPageCapacity;
private TIntIntHashMap myCachedMappings;
private final int myCachedMappingsSize;
- public IntToIntBtree(int _pageSize, File file, PagedFileStorage.StorageLockContext storageLockContext, boolean initial) throws IOException {
- pageSize = _pageSize;
+ public IntToIntBtree(int pageSize, @NotNull File file, @NotNull PagedFileStorage.StorageLockContext storageLockContext, boolean initial) throws IOException {
+ this.pageSize = pageSize;
if (initial) {
FileUtil.delete(file);
root.setIndexLeaf(true);
}
- int i = (pageSize - BtreePage.RESERVED_META_PAGE_LEN) / BtreeIndexNodeView.INTERIOR_SIZE - 1;
+ int i = (this.pageSize - BtreePage.RESERVED_META_PAGE_LEN) / BtreeIndexNodeView.INTERIOR_SIZE - 1;
assert i < Short.MAX_VALUE && i % 2 == 0;
maxInteriorNodes = (short)i;
maxLeafNodes = (short)i;
- int metaPageLen = BtreePage.RESERVED_META_PAGE_LEN;
-
+ int metaPageLen;
if (indexNodeIsHashTable) {
++i;
while(!isPrime(i)) i -= 2;
metaPageLen = BtreePage.RESERVED_META_PAGE_LEN;
i = (int)(hashPageCapacity * 0.9);
if ((i & 1) == 1) ++i;
- } else {
+ }
+ else {
hashPageCapacity = -1;
+ metaPageLen = BtreePage.RESERVED_META_PAGE_LEN;
}
metaDataLeafPageLength = metaPageLen;
if (hasCachedMappings) {
myCachedMappings = new TIntIntHashMap(myCachedMappingsSize = 4 * maxLeafNodes);
- } else {
+ }
+ else {
myCachedMappings = null;
myCachedMappingsSize = -1;
}
}
- public void persistVars(BtreeDataStorage storage, boolean toDisk) {
- if (toDisk) {
- storage.persistInt(0, height | (hasZeroKey ? HAS_ZERO_KEY_MASK :0), true);
- } else {
- int i = storage.persistInt(0, 0, false);
- hasZeroKey = (i & HAS_ZERO_KEY_MASK) != 0;
- height = i & ~HAS_ZERO_KEY_MASK;
- }
+ // return total number of bytes needed for storing information
+ public int persistVars(@NotNull BtreeDataStorage storage, boolean toDisk) {
+ int i = storage.persistInt(0, height | (hasZeroKey ? HAS_ZERO_KEY_MASK :0), toDisk);
+ hasZeroKey = (i & HAS_ZERO_KEY_MASK) != 0;
+ height = i & ~HAS_ZERO_KEY_MASK;
pagesCount = storage.persistInt(4, pagesCount, toDisk);
movedMembersCount = storage.persistInt(8, movedMembersCount, toDisk);
hashedPagesCount = storage.persistInt(28, hashedPagesCount, toDisk);
root.setAddress(storage.persistInt(32, root.address, toDisk));
zeroKeyValue = storage.persistInt(36, zeroKeyValue, toDisk);
+ return 40;
}
- interface BtreeDataStorage {
+ public interface BtreeDataStorage {
int persistInt(int offset, int value, boolean toDisk);
}
}
private BtreeIndexNodeView myAccessNodeView;
- private int myLastGetKey, myOptimizedInserts;
+ private int myLastGetKey;
+ private int myOptimizedInserts;
private boolean myCanUseLastKey;
- public boolean get(int key, int[] result) {
+ public boolean get(int key, @NotNull int[] result) {
if (key == 0) {
if (hasZeroKey) {
result[0] = zeroKeyValue;
if (hasCachedMappings) {
myCachedMappings.put(key, value);
if (myCachedMappings.size() == myCachedMappingsSize) flushCachedMappings();
- } else {
+ }
+ else {
boolean canUseLastKey = myCanUseLastKey;
if (canUseLastKey) {
myCanUseLastKey = false;
}
}
- void doClose() throws IOException {
+ public void doClose() throws IOException {
myCachedMappings = null;
storage.close();
}
- void doFlush() {
+ public void doFlush() {
flushCachedMappings();
storage.force();
}
putInt(offset, value);
}
- private final int indexToOffset(int i) {
+ private int indexToOffset(int i) {
return i * INTERIOR_SIZE + (isHashedLeaf() ? btree.metaDataLeafPageLength:RESERVED_META_PAGE_LEN);
}
- private final int keyAt(int i) {
+ private int keyAt(int i) {
if (doSanityCheck) {
if (isHashedLeaf()) myAssert(i < btree.hashPageCapacity);
else myAssert(i < getChildrenCount());
setFlag(INDEX_LEAF_MASK, value);
}
- private final boolean isHashedLeaf() {
+ private boolean isHashedLeaf() {
return isHashedLeaf;
}
if (hashedLeaf) {
hashLeafData = new HashLeafData(this, recordCount);
if (doOffloadToSiblingsWhenHashed(parent, hashLeafData)) return parentAddress;
- } else {
+ }
+ else {
if (doOffloadToSiblingsSorted(parent)) return parentAddress;
}
}
private static final boolean useDoubleHash = true;
private int hashIndex(int value) {
- int hash, index;
-
final int length = btree.hashPageCapacity;
- hash = value & 0x7fffffff;
- index = hash % length;
+ int hash = value & 0x7fffffff;
+ int index = hash % length;
int keyAtIndex = keyAt(index);
- int total = 0;
btree.hashSearchRequests++;
+ int total = 0;
if (useDoubleHash) {
if (keyAtIndex != value && keyAtIndex != HASH_FREE) {
// see Knuth, p. 529
if (childrenAddresses.length > 0) {
BtreeIndexNodeView child = new BtreeIndexNodeView(this);
- for(int i = 0; i < childrenAddresses.length; ++i) {
- child.setAddress(childrenAddresses[i]);
- if (!processLeafPages(child, processor)) return false;
+ for (int childrenAddress : childrenAddresses) {
+ child.setAddress(childrenAddress);
+ if (!processLeafPages(child, processor)) return false;
}
}
return true;
}
+
+ public void withStorageLock(@NotNull Runnable runnable) {
+ storage.getPagedFileStorage().lock();
+ try {
+ runnable.run();
+ }
+ finally {
+ storage.getPagedFileStorage().unlock();
+ }
+ }
}
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private static final ByteOrder ourNativeByteOrder = ByteOrder.nativeOrder();
public void lock() {
- myStorageLockContext.myLock.lock();
+ myStorageLockContext.lock();
}
public void unlock() {
- myStorageLockContext.myLock.unlock();
+ myStorageLockContext.unlock();
}
public StorageLockContext getStorageLockContext() {
}
public void lock() {
- myDefaultStorageLockContext.myLock.lock();
+ myDefaultStorageLockContext.lock();
}
public void unlock() {
- myDefaultStorageLockContext.myLock.unlock();
+ myDefaultStorageLockContext.unlock();
}
private int registerPagedFileStorage(@NotNull PagedFileStorage storage) {
LOG.info("Max memory:"+maxMemory.get(null) + ", reserved memory:" + reservedMemory.get(null));
}
}
- catch (Throwable t) {}
+ catch (Throwable t) {
+
+ }
throw new MappingFailedException(
"Cannot recover from OOME in memory mapping: -Xmx=" + Runtime.getRuntime().maxMemory() / MB + "MB " +
"new size limit: " + mySizeLimit / MB + "MB " +
}
}
- private void checkThreadAccess(StorageLockContext storageLockContext) {
+ private static void checkThreadAccess(StorageLockContext storageLockContext) {
if (storageLockContext.myCheckThreadAccess && !storageLockContext.myLock.isHeldByCurrentThread()) {
throw new IllegalStateException("Must hold StorageLock lock to access PagedFileStorage");
}
public StorageLockContext(boolean checkAccess) {
this(ourLock, checkAccess);
}
+
+ public void lock() {
+ myLock.lock();
+ }
+ public void unlock() {
+ myLock.unlock();
+ }
}
}
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private static final boolean DEBUG = false;
- public RandomAccessDataFile(final File file) throws IOException {
+ public RandomAccessDataFile(@NotNull File file) throws IOException {
this(file, PagePool.SHARED);
}
- public RandomAccessDataFile(final File file, final PagePool pool) throws IOException {
+ public RandomAccessDataFile(@NotNull File file, @NotNull PagePool pool) throws IOException {
myPool = pool;
myFile = file;
if (!file.exists()) {
dispose();
}
+ /**
+ * Flushes dirty pages to underlying buffers
+ */
@Override
public void force() {
assertNotDisposed();
}
}
+ /**
+ * Flushes dirty pages to buffers and saves them to disk
+ */
+ public void sync() {
+ force();
+ try {
+ RandomAccessFile file = getRandomAccessFile();
+ file.getChannel().force(true);
+ }
+ catch (IOException ignored) {
+
+ }
+ finally {
+ releaseFile();
+ }
+ }
+
public void flushSomePages(int maxPagesToFlush) {
assertNotDisposed();
if (isDirty()) {
private void assertNotDisposed() {
if (myIsDisposed) {
- LOG.assertTrue(false, "storage file is disposed: " + myFile);
+ LOG.error("storage file is disposed: " + myFile);
}
}
file.seek(fileOffset);
}
+ @Override
public int hashCode() {
return myCount;
}
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
}
- int step = 0 <= lastChar && lastChar < 128 ? mySearchTable[lastChar] : 1;
+ int step = lastChar < 128 ? mySearchTable[lastChar] : 1;
if (step <= 0) {
int index;
if (i < 0) return end - start - myPatternLength + 1;
}
- int step = 0 <= lastChar && lastChar < 128 ? mySearchTable[lastChar] : 1;
+ int step = lastChar < 128 ? mySearchTable[lastChar] : 1;
if (step <= 0) {
int index;
}
private static final int[] ourMarks = {1,2,4,8,-1};
- public static final Hashtable<Integer,JLabel> LABELS = new Hashtable<Integer, JLabel>();
+ public static final Hashtable<Integer, JComponent> LABELS = new Hashtable<Integer, JComponent>();
public static final int ALL_VALUE = 5;
static {
private final @Nullable ExecutionEnvironment myEnvironment;
private boolean myStopped;
private boolean myPauseActionSupported;
- private boolean myShowTabOnSuspend;
+ private final AtomicBoolean myShowTabOnSuspend;
private final List<AnAction> myRestartActions = new SmartList<AnAction>();
private final List<AnAction> myExtraStopActions = new SmartList<AnAction>();
private final List<AnAction> myExtraActions = new SmartList<AnAction>();
myEnvironment = environment;
mySessionName = sessionName;
myDebuggerManager = debuggerManager;
- myShowTabOnSuspend = showTabOnSuspend;
+ myShowTabOnSuspend = new AtomicBoolean(showTabOnSuspend);
myProject = debuggerManager.getProject();
ValueLookupManager.getInstance(myProject).startListening();
myIcon = icon;
}
private void assertSessionTabInitialized() {
- if (myShowTabOnSuspend) {
+ if (myShowTabOnSuspend.get()) {
LOG.error("Debug tool window isn't shown yet because debug process isn't suspended");
}
else {
@Override
public void rebuildViews() {
- if (!myShowTabOnSuspend && mySessionTab != null) {
+ if (!myShowTabOnSuspend.get() && mySessionTab != null) {
mySessionTab.rebuildViews();
}
}
});
//todo[nik] make 'createConsole()' method return ConsoleView
myConsoleView = (ConsoleView)myDebugProcess.createConsole();
- if (!myShowTabOnSuspend) {
+ if (!myShowTabOnSuspend.get()) {
initSessionTab(contentToReuse);
}
@Override
public RunnerLayoutUi getUI() {
assertSessionTabInitialized();
+ assert mySessionTab != null;
return mySessionTab.getUi();
}
}
adjustMouseTrackingCounter(myCurrentPosition, 1);
- if (myShowTabOnSuspend) {
+ if (myShowTabOnSuspend.compareAndSet(true, false)) {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
- if (myShowTabOnSuspend) {
- myShowTabOnSuspend = false;
- initSessionTab(null);
- showSessionTab();
- }
+ initSessionTab(null);
+ showSessionTab();
}
});
}
import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.execution.runners.ExecutionEnvironment;
-import com.intellij.execution.runners.RestartAction;
import com.intellij.execution.runners.RunContentBuilder;
import com.intellij.execution.ui.ExecutionConsole;
import com.intellij.execution.ui.RunContentDescriptor;
else if (TAB_KEY.is(dataId)) {
return this;
}
- else if (SESSION_KEY.is(dataId)) {
- return session;
+ else if (LangDataKeys.RUN_PROFILE.is(dataId)) {
+ ExecutionEnvironment environment = getEnvironment();
+ return environment == null ? null : environment.getRunProfile();
+ }
+ else if (LangDataKeys.EXECUTION_ENVIRONMENT.is(dataId)) {
+ return getEnvironment();
}
if (session != null) {
- if (LangDataKeys.CONSOLE_VIEW.is(dataId)) {
+ if (SESSION_KEY.is(dataId)) {
+ return session;
+ }
+ else if (LangDataKeys.CONSOLE_VIEW.is(dataId)) {
return session.getConsoleView();
}
else if (XDebugSessionData.DATA_KEY.is(dataId)) {
DefaultActionGroup leftToolbar = new DefaultActionGroup();
final Executor debugExecutor = DefaultDebugExecutor.getDebugExecutorInstance();
ExecutionEnvironment environment = getEnvironment();
- final Executor executor = environment != null ? environment.getExecutor() : debugExecutor;
if (environment != null) {
- RestartAction restartAction = new RestartAction(executor, myRunContentDescriptor, environment);
- leftToolbar.add(restartAction);
- restartAction.registerShortcut(myUi.getComponent());
-
List<AnAction> additionalRestartActions = session.getRestartActions();
- leftToolbar.addAll(additionalRestartActions);
- if (!additionalRestartActions.isEmpty()) leftToolbar.addSeparator();
+ if (!additionalRestartActions.isEmpty()) {
+ leftToolbar.addAll(additionalRestartActions);
+ leftToolbar.addSeparator();
+ }
leftToolbar.addAll(session.getExtraActions());
}
-
leftToolbar.addAll(getCustomizedActionGroup(XDebuggerActions.TOOL_WINDOW_LEFT_TOOLBAR_GROUP));
for (AnAction action : session.getExtraStopActions()) {
leftToolbar.addSeparator();
leftToolbar.add(PinToolwindowTabAction.getPinAction());
- leftToolbar.add(new CloseAction(executor, myRunContentDescriptor, getProject()));
+ leftToolbar.add(new CloseAction(environment != null ? environment.getExecutor() : debugExecutor, myRunContentDescriptor, getProject()));
leftToolbar.add(new ContextHelpAction(debugExecutor.getHelpId()));
DefaultActionGroup topToolbar = new DefaultActionGroup();
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.intellij.execution.process.ProcessOutput;
import com.intellij.ide.startup.impl.StartupManagerImpl;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.Presentation;
+import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.application.PluginPathManager;
}
return null;
}
- }, "test", new Presentation(), null, 0));
+ }, "test", new Presentation(), ActionManager.getInstance(), 0));
final ChangeListManager clManager = ChangeListManager.getInstance(project);
clManager.ensureUpToDate(false);
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
package org.jetbrains.idea.svn;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.Presentation;
+import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.VcsConfiguration;
import com.intellij.openapi.vcs.VcsException;
}
return null;
}
- }, "test", new Presentation(), null, 0));
+ }, "test", new Presentation(), ActionManager.getInstance(), 0));
myChangeListManager.ensureUpToDate(false);
myChangeListManager.ensureUpToDate(false); // wait for after-events like annotations recalculation
}
return null;
}
- }, "test", new Presentation(), null, 0));
+ }, "test", new Presentation(), ActionManager.getInstance(), 0));
myChangeListManager.ensureUpToDate(false);
myChangeListManager.ensureUpToDate(false); // wait for after-events like annotations recalculation
@Nullable
public static PsiElement getLocalInsertPosition(@NotNull PyElement anchor) {
- final PyStatement enclosingStatement = PsiTreeUtil.getParentOfType(anchor, PyStatement.class, false);
- return enclosingStatement != null ? enclosingStatement.getFirstChild() : null;
+ return PsiTreeUtil.getParentOfType(anchor, PyStatement.class, false);
}
public enum ImportPriority {
* Creates new instance.
*
* @param importable an element that could be imported either from import element or from file.
- * @param file the file which is the source of the importable
+ * @param file the file which is the source of the importable (module for symbols, containing directory for modules and packages)
* @param importElement an existing import element that can be a source for the importable.
* @param path import path for the file, as a qualified name (a.b.c)
* For top-level imported symbols it's <em>qualified name of containing module</em> (or package for __init__.py).
def func():
for _ range(10):
from package.module import foo
+
foo
# <ref>
\ No newline at end of file
def func():
try:
import module
+
module
# <ref>
except:
--- /dev/null
+def func():
+ if True:
+ import module
+
+ module
+# <ref>
\ No newline at end of file
--- /dev/null
+def func():
+ if True: module
+# <ref>
\ No newline at end of file
--- /dev/null
+def func():
+ import module
+
+ module
+# <ref>
\ No newline at end of file
--- /dev/null
+def func(): module
+# <ref>
\ No newline at end of file
doAddLocalImport("module", null);
}
+ // PY-13668
+ public void testLocalImportInlineFunctionBody() {
+ testLocalImport();
+ }
+
+ // PY-13668
+ public void testLocalImportInlineBranch() {
+ testLocalImport();
+ }
+
/**
* Add local import statement
* @param name reference name in corresponding import element