mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
+9
-11
@@ -24,7 +24,6 @@ import com.intellij.psi.search.searches.MethodReferencesSearch;
|
||||
import com.intellij.psi.search.searches.OverridingMethodsSearch;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.refactoring.BaseRefactoringProcessor;
|
||||
import com.intellij.refactoring.listeners.RefactoringElementListener;
|
||||
import com.intellij.refactoring.rename.RenameProcessor;
|
||||
import com.intellij.refactoring.rename.RenameUtil;
|
||||
import com.intellij.refactoring.util.MoveRenameUsageInfo;
|
||||
@@ -62,11 +61,13 @@ public class InvertBooleanProcessor extends BaseRefactoringProcessor {
|
||||
mySmartPointerManager = SmartPointerManager.getInstance(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
protected UsageViewDescriptor createUsageViewDescriptor(UsageInfo[] usages) {
|
||||
return new InvertBooleanUsageViewDescriptor(myElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean preprocessUsages(Ref<UsageInfo[]> refUsages) {
|
||||
if (myRenameProcessor.preprocessUsages(refUsages)) {
|
||||
prepareSuccessful();
|
||||
@@ -75,6 +76,7 @@ public class InvertBooleanProcessor extends BaseRefactoringProcessor {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
protected UsageInfo[] findUsages() {
|
||||
final List<SmartPsiElementPointer> toInvert = new ArrayList<SmartPsiElementPointer>();
|
||||
@@ -175,7 +177,7 @@ public class InvertBooleanProcessor extends BaseRefactoringProcessor {
|
||||
for (PsiReference ref : refs) {
|
||||
final PsiElement element = ref.getElement();
|
||||
if (element instanceof PsiReferenceExpression) {
|
||||
final PsiReferenceExpression refExpr = ((PsiReferenceExpression)element);
|
||||
final PsiReferenceExpression refExpr = (PsiReferenceExpression)element;
|
||||
PsiElement parent = refExpr.getParent();
|
||||
if (parent instanceof PsiAssignmentExpression && refExpr.equals(((PsiAssignmentExpression)parent).getLExpression())) {
|
||||
toInvert.add(mySmartPointerManager.createSmartPsiElementPointer(((PsiAssignmentExpression)parent).getRExpression()));
|
||||
@@ -203,9 +205,10 @@ public class InvertBooleanProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void refreshElements(PsiElement[] elements) {
|
||||
LOG.assertTrue(elements.length == 1 && elements[0] instanceof PsiMethod);
|
||||
myElement = ((PsiMethod)elements[0]);
|
||||
myElement = (PsiMethod)elements[0];
|
||||
}
|
||||
|
||||
private static UsageInfo[] extractUsagesForElement(PsiElement element, UsageInfo[] usages) {
|
||||
@@ -222,17 +225,11 @@ public class InvertBooleanProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void performRefactoring(UsageInfo[] usages) {
|
||||
|
||||
for (final PsiElement element : myRenameProcessor.getElements()) {
|
||||
try {
|
||||
RenameUtil.doRename(element, myRenameProcessor.getNewName(element), extractUsagesForElement(element, usages), myProject, new RefactoringElementListener() {
|
||||
public void elementMoved(@NotNull PsiElement newElement) {
|
||||
}
|
||||
|
||||
public void elementRenamed(@NotNull PsiElement newElement) {
|
||||
}
|
||||
});
|
||||
RenameUtil.doRename(element, myRenameProcessor.getNewName(element), extractUsagesForElement(element, usages), myProject, null);
|
||||
}
|
||||
catch (final IncorrectOperationException e) {
|
||||
RenameUtil.showErrorMessage(e, element, myProject);
|
||||
@@ -263,6 +260,7 @@ public class InvertBooleanProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCommandName() {
|
||||
return InvertBooleanHandler.REFACTORING_NAME;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,8 @@ public class RenameJavaClassProcessor extends RenamePsiElementProcessor {
|
||||
|
||||
public void renameElement(final PsiElement element,
|
||||
final String newName,
|
||||
final UsageInfo[] usages, final RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
final UsageInfo[] usages,
|
||||
@Nullable RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
PsiClass aClass = (PsiClass) element;
|
||||
ArrayList<UsageInfo> postponedCollisions = new ArrayList<UsageInfo>();
|
||||
List<MemberHidesOuterMemberUsageInfo> hidesOut = new ArrayList<MemberHidesOuterMemberUsageInfo>();
|
||||
@@ -111,7 +112,9 @@ public class RenameJavaClassProcessor extends RenamePsiElementProcessor {
|
||||
}*/
|
||||
|
||||
|
||||
listener.elementRenamed(aClass);
|
||||
if (listener != null) {
|
||||
listener.elementRenamed(aClass);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -59,7 +59,8 @@ public class RenameJavaMethodProcessor extends RenameJavaMemberProcessor {
|
||||
|
||||
public void renameElement(final PsiElement psiElement,
|
||||
final String newName,
|
||||
final UsageInfo[] usages, final RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
final UsageInfo[] usages,
|
||||
@Nullable RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
PsiMethod method = (PsiMethod) psiElement;
|
||||
Set<PsiMethod> methodAndOverriders = new HashSet<PsiMethod>();
|
||||
Set<PsiClass> containingClasses = new HashSet<PsiClass>();
|
||||
@@ -115,7 +116,9 @@ public class RenameJavaMethodProcessor extends RenameJavaMemberProcessor {
|
||||
((PsiMethod)element).setName(newName);
|
||||
}
|
||||
}
|
||||
listener.elementRenamed(method);
|
||||
if (listener != null) {
|
||||
listener.elementRenamed(method);
|
||||
}
|
||||
|
||||
for (PsiElement element: renamedReferences) {
|
||||
fixNameCollisionsWithInnerClassMethod(element, newName, methodAndOverriders, containingClasses,
|
||||
|
||||
@@ -57,7 +57,8 @@ public class RenameJavaVariableProcessor extends RenameJavaMemberProcessor {
|
||||
|
||||
public void renameElement(final PsiElement psiElement,
|
||||
final String newName,
|
||||
final UsageInfo[] usages, final RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
final UsageInfo[] usages,
|
||||
@Nullable RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
PsiVariable variable = (PsiVariable) psiElement;
|
||||
List<MemberHidesOuterMemberUsageInfo> outerHides = new ArrayList<MemberHidesOuterMemberUsageInfo>();
|
||||
List<MemberHidesStaticImportUsageInfo> staticImportHides = new ArrayList<MemberHidesStaticImportUsageInfo>();
|
||||
@@ -104,7 +105,9 @@ public class RenameJavaVariableProcessor extends RenameJavaMemberProcessor {
|
||||
}
|
||||
// do actual rename
|
||||
variable.setName(newName);
|
||||
listener.elementRenamed(variable);
|
||||
if (listener != null) {
|
||||
listener.elementRenamed(variable);
|
||||
}
|
||||
|
||||
if (variable instanceof PsiField) {
|
||||
for (PsiElement occurrence : occurrencesToCheckForConflict) {
|
||||
|
||||
@@ -56,7 +56,8 @@ public class RenamePsiDirectoryProcessor extends RenamePsiElementProcessor {
|
||||
|
||||
public void renameElement(final PsiElement element,
|
||||
final String newName,
|
||||
final UsageInfo[] usages, final RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
final UsageInfo[] usages,
|
||||
@Nullable RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
PsiDirectory aDirectory = (PsiDirectory) element;
|
||||
// rename all non-package statement references
|
||||
for (UsageInfo usage : usages) {
|
||||
@@ -71,7 +72,9 @@ public class RenamePsiDirectoryProcessor extends RenamePsiElementProcessor {
|
||||
}
|
||||
|
||||
aDirectory.setName(newName);
|
||||
listener.elementRenamed(aDirectory);
|
||||
if (listener != null) {
|
||||
listener.elementRenamed(aDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
public String getQualifiedNameAfterRename(final PsiElement element, final String newName, final boolean nonJava) {
|
||||
|
||||
@@ -44,7 +44,8 @@ public class RenamePsiPackageProcessor extends RenamePsiElementProcessor {
|
||||
|
||||
public void renameElement(final PsiElement element,
|
||||
final String newName,
|
||||
final UsageInfo[] usages, final RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
final UsageInfo[] usages,
|
||||
@Nullable RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
final PsiPackage psiPackage = (PsiPackage)element;
|
||||
psiPackage.handleQualifiedNameChange(PsiUtilCore.getQualifiedNameAfterRename(psiPackage.getQualifiedName(), newName));
|
||||
RenameUtil.doRenameGenericNamedElement(element, newName, usages, listener);
|
||||
|
||||
+1
-2
@@ -34,7 +34,6 @@ import com.intellij.util.StringBuilderSpinAllocator;
|
||||
import com.intellij.util.ThreeState;
|
||||
import com.intellij.util.containers.ConcurrentSoftHashMap;
|
||||
import com.intellij.util.containers.ConcurrentSoftValueHashMap;
|
||||
import com.intellij.util.containers.ConcurrentWeakHashMap;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jdom.Document;
|
||||
@@ -139,7 +138,7 @@ public class BaseExternalAnnotationsManager extends ExternalAnnotationsManager {
|
||||
return result.isEmpty() ? null : result.values().toArray(new PsiAnnotation[result.size()]);
|
||||
}
|
||||
|
||||
private final ConcurrentMap<PsiModifierListOwner, Map<String, PsiAnnotation>> cache = new ConcurrentWeakHashMap<PsiModifierListOwner, Map<String, PsiAnnotation>>();
|
||||
private final ConcurrentMap<PsiModifierListOwner, Map<String, PsiAnnotation>> cache = new ConcurrentSoftHashMap<PsiModifierListOwner, Map<String, PsiAnnotation>>();
|
||||
@NotNull
|
||||
private Map<String, PsiAnnotation> collectExternalAnnotations(@NotNull final PsiModifierListOwner listOwner) {
|
||||
if (!hasAnyAnnotationsRoots()) return Collections.emptyMap();
|
||||
|
||||
@@ -6,11 +6,12 @@ package com.intellij.psi;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.psi.impl.DebugUtil;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
public class TreeIsCorrectAfterDiffReparseTest extends LightCodeInsightTestCase {
|
||||
|
||||
public void testIDEADEV41862() throws Exception {
|
||||
String part1 = "package com.test;\n" +
|
||||
@NonNls String part1 = "package com.test;\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"//------------------------------------------------------------------\n" +
|
||||
@@ -952,7 +953,7 @@ public class TreeIsCorrectAfterDiffReparseTest extends LightCodeInsightTestCase
|
||||
"\n" +
|
||||
" ";
|
||||
|
||||
String part2 = "\n" +
|
||||
@NonNls String part2 = "\n" +
|
||||
" private TransactionStatus getHighestPriorityError(TransactionStatus existingStatus, Message newError) {\n" +
|
||||
" if(existingStatus == null) {\n" +
|
||||
" return newError;\n" +
|
||||
|
||||
+8
-7
@@ -55,6 +55,14 @@ public abstract class JavaCodeInsightFixtureTestCase extends UsefulTestCase{
|
||||
myModule = moduleFixtureBuilder.getFixture().getModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
myModule = null;
|
||||
myFixture.tearDown();
|
||||
myFixture = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return relative path to the test data. Path is relative to the
|
||||
* {@link com.intellij.openapi.application.PathManager#getHomePath()}
|
||||
@@ -78,13 +86,6 @@ public abstract class JavaCodeInsightFixtureTestCase extends UsefulTestCase{
|
||||
|
||||
protected void tuneFixture(final JavaModuleFixtureBuilder moduleBuilder) throws Exception {}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
myModule = null;
|
||||
myFixture.tearDown();
|
||||
myFixture = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected Project getProject() {
|
||||
return myFixture.getProject();
|
||||
|
||||
@@ -12,8 +12,6 @@ import java.io.File;
|
||||
public abstract class CompileScope {
|
||||
public abstract boolean isAffected(BuildTarget<?> target, @NotNull File file);
|
||||
|
||||
public abstract void expandScope(BuildTarget<?> target, @NotNull File file);
|
||||
|
||||
public abstract boolean isAffected(@NotNull BuildTarget<?> target);
|
||||
|
||||
public abstract boolean isRecompilationForced(@NotNull BuildTarget<?> target);
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package org.jetbrains.jps.incremental;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.builders.BuildTarget;
|
||||
import org.jetbrains.jps.builders.BuildTargetType;
|
||||
@@ -12,7 +9,6 @@ import org.jetbrains.jps.model.module.JpsModule;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -24,7 +20,6 @@ public class CompileScopeImpl extends CompileScope {
|
||||
private final Collection<? extends BuildTargetType<?>> myTypes;
|
||||
private final Collection<BuildTarget<?>> myTargets;
|
||||
private final Map<BuildTarget<?>, Set<File>> myFiles;
|
||||
private final Map<BuildTarget<?>, Set<File>> myAppendedFiles = Collections.synchronizedMap(new THashMap<BuildTarget<?>, Set<File>>());
|
||||
|
||||
public CompileScopeImpl(boolean forcedCompilation, Collection<? extends BuildTargetType<?>> types, Collection<BuildTarget<?>> targets,
|
||||
Map<BuildTarget<?>, Set<File>> files) {
|
||||
@@ -46,32 +41,14 @@ public class CompileScopeImpl extends CompileScope {
|
||||
|
||||
@Override
|
||||
public boolean isAffected(BuildTarget<?> target, @NotNull File file) {
|
||||
if (myFiles.isEmpty() && myAppendedFiles.isEmpty()) {//optimization
|
||||
if (myFiles.isEmpty()) {//optimization
|
||||
return true;
|
||||
}
|
||||
if (myTypes.contains(target.getTargetType()) || myTargets.contains(target) || isAffectedByAssociatedModule(target)) {
|
||||
return true;
|
||||
}
|
||||
final Set<File> files = myFiles.get(target);
|
||||
if (files != null && files.contains(file)) {
|
||||
return true;
|
||||
}
|
||||
synchronized (myAppendedFiles) {
|
||||
final Set<File> appended = myAppendedFiles.get(target);
|
||||
return appended != null && appended.contains(file);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expandScope(BuildTarget<?> target, @NotNull File file) {
|
||||
synchronized (myAppendedFiles) {
|
||||
Set<File> files = myAppendedFiles.get(target);
|
||||
if (files == null) {
|
||||
files = new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY);
|
||||
myAppendedFiles.put(target, files);
|
||||
}
|
||||
files.add(file);
|
||||
}
|
||||
return files != null && files.contains(file);
|
||||
}
|
||||
|
||||
private boolean isAffectedByAssociatedModule(BuildTarget<?> target) {
|
||||
|
||||
@@ -112,7 +112,7 @@ public class ResourcesBuilder extends TargetBuilder<ResourceRootDescriptor, Reso
|
||||
}
|
||||
}
|
||||
|
||||
context.processMessage(new ProgressMessage("Finished copying resources [" + target.getModule().getName() + "]"));
|
||||
context.processMessage(new ProgressMessage(""));
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ProjectBuildException(e.getMessage(), e);
|
||||
|
||||
@@ -764,8 +764,10 @@ public abstract class IntervalTreeImpl<T extends MutableInterval> extends RedBla
|
||||
|
||||
// returns true if all markers are valid
|
||||
public boolean checkMax(boolean assertInvalid) {
|
||||
if (!VERIFY) return false;
|
||||
return VERIFY && doCheckMax(assertInvalid);
|
||||
}
|
||||
|
||||
protected boolean doCheckMax(boolean assertInvalid) {
|
||||
try {
|
||||
l.readLock().lock();
|
||||
|
||||
|
||||
@@ -77,6 +77,10 @@ public abstract class ConfigurationFactory {
|
||||
public void configureBeforeRunTaskDefaults(Key<? extends BeforeRunTask> providerID, BeforeRunTask task) {
|
||||
}
|
||||
|
||||
public boolean isConfigurationSingletonByDefault() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canConfigurationBeSingleton() {
|
||||
return true; // Configuration may be marked as singleton by default
|
||||
}
|
||||
|
||||
@@ -59,15 +59,20 @@ public class CommonRefactoringUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void showErrorHint(Project project, @Nullable Editor editor, String message, String title, @Nullable @NonNls String helpId) {
|
||||
public static void showErrorHint(final Project project, @Nullable final Editor editor, final String message, final String title, @Nullable @NonNls final String helpId) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) throw new RefactoringErrorHintException(message);
|
||||
|
||||
if (editor == null) {
|
||||
showErrorMessage(title, message, helpId, project);
|
||||
}
|
||||
else {
|
||||
HintManager.getInstance().showErrorHint(editor, message);
|
||||
}
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (editor == null) {
|
||||
showErrorMessage(title, message, helpId, project);
|
||||
}
|
||||
else {
|
||||
HintManager.getInstance().showErrorHint(editor, message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NonNls
|
||||
|
||||
@@ -167,7 +167,7 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L
|
||||
if (myActions != null) return myActions;
|
||||
DefaultActionGroup group = new DefaultActionGroup();
|
||||
|
||||
final AnAction[] actions = getConsole().createConsoleActions();
|
||||
final AnAction[] actions = getConsoleNotNull().createConsoleActions();
|
||||
for (AnAction action : actions) {
|
||||
group.add(action);
|
||||
}
|
||||
@@ -203,7 +203,7 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L
|
||||
public JComponent getComponent() {
|
||||
if (!myWasInitialized) {
|
||||
myWasInitialized = true;
|
||||
add(getConsole().getComponent(), BorderLayout.CENTER);
|
||||
add(getConsoleNotNull().getComponent(), BorderLayout.CENTER);
|
||||
add(createToolbar(), BorderLayout.NORTH);
|
||||
}
|
||||
return this;
|
||||
@@ -285,7 +285,7 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L
|
||||
protected synchronized void addMessage(final String text) {
|
||||
if (text == null) return;
|
||||
if (myContentPreprocessor != null) {
|
||||
final java.util.List<LogFragment> fragments = myContentPreprocessor.parseLogLine(text + "\n");
|
||||
final List<LogFragment> fragments = myContentPreprocessor.parseLogLine(text + "\n");
|
||||
myOriginalDocument = getOriginalDocument();
|
||||
for (LogFragment fragment : fragments) {
|
||||
myProcessHandler.notifyTextAvailable(fragment.getText(), fragment.getOutputType());
|
||||
@@ -391,7 +391,7 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L
|
||||
}
|
||||
|
||||
private synchronized void doFilter() {
|
||||
final ConsoleView console = getConsole();
|
||||
final ConsoleView console = getConsoleNotNull();
|
||||
console.clear();
|
||||
myModel.processingStarted();
|
||||
|
||||
@@ -424,7 +424,7 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L
|
||||
}
|
||||
|
||||
private int printMessageToConsole(String line) {
|
||||
final ConsoleView console = getConsole();
|
||||
final ConsoleView console = getConsoleNotNull();
|
||||
if (myContentPreprocessor != null) {
|
||||
List<LogFragment> fragments = myContentPreprocessor.parseLogLine(line + '\n');
|
||||
for (LogFragment fragment : fragments) {
|
||||
@@ -455,11 +455,24 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
public synchronized ConsoleView getConsole() {
|
||||
return myConsole;
|
||||
}
|
||||
|
||||
/**
|
||||
* A shortcut for "getConsole()+assert console != null"
|
||||
* Use this method when you are sure that console must not be null.
|
||||
* If we get the assertion then it is a time to revisit logic of caller ;)
|
||||
*/
|
||||
|
||||
@NotNull
|
||||
private synchronized ConsoleView getConsoleNotNull() {
|
||||
final ConsoleView console = getConsole();
|
||||
assert console != null: "it looks like console has been disposed";
|
||||
return console;
|
||||
}
|
||||
|
||||
public ActionGroup getToolbarActions() {
|
||||
return getOrCreateActions();
|
||||
}
|
||||
@@ -468,12 +481,14 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L
|
||||
return ActionPlaces.UNKNOWN;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JComponent getToolbarContextComponent() {
|
||||
return getConsole().getComponent();
|
||||
final ConsoleView console = getConsole();
|
||||
return console == null ? null : console.getComponent();
|
||||
}
|
||||
|
||||
public JComponent getPreferredFocusableComponent() {
|
||||
return getConsole().getPreferredFocusableComponent();
|
||||
return getConsoleNotNull().getPreferredFocusableComponent();
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
@@ -481,7 +496,7 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L
|
||||
}
|
||||
|
||||
public synchronized void clear() {
|
||||
getConsole().clear();
|
||||
getConsoleNotNull().clear();
|
||||
myOriginalDocument = null;
|
||||
}
|
||||
|
||||
@@ -508,8 +523,10 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L
|
||||
private void resetLogFilter() {
|
||||
for (LogFilter filter : myFilters) {
|
||||
if (myModel.isFilterSelected(filter)) {
|
||||
myLogFilterCombo.setSelectedItem(filter);
|
||||
break;
|
||||
if (myLogFilterCombo.getSelectedItem() != filter) {
|
||||
myLogFilterCombo.setSelectedItem(filter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ public abstract class RunManagerEx extends RunManager {
|
||||
public abstract Icon getConfigurationIcon(@NotNull RunnerAndConfigurationSettings settings);
|
||||
public abstract void invalidateConfigurationIcon(@NotNull RunnerAndConfigurationSettings settings);
|
||||
|
||||
@NotNull
|
||||
public abstract Collection<RunnerAndConfigurationSettings> getSortedConfigurations();
|
||||
|
||||
public abstract void removeConfiguration(@Nullable RunnerAndConfigurationSettings settings);
|
||||
|
||||
@@ -183,7 +183,7 @@ class RunConfigurable extends BaseConfigurable {
|
||||
snapshot = settings.getSettings();
|
||||
configuration = settings.getConfiguration();
|
||||
name = settings.getNameText();
|
||||
shared = runManager.isConfigurationShared(snapshot);
|
||||
shared = settings.isStoreProjectConfiguration();
|
||||
setIcon(ProgramRunnerUtil.getConfigurationIcon(snapshot, !settings.isValid(), runManager.isTemporary(configuration)));
|
||||
}
|
||||
else if (userObject instanceof RunnerAndConfigurationSettingsImpl) {
|
||||
@@ -459,6 +459,14 @@ class RunConfigurable extends BaseConfigurable {
|
||||
update();
|
||||
}
|
||||
});
|
||||
|
||||
info.addSharedListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
changed[0] = true;
|
||||
update();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void drawPressAddButtonMessage(final ConfigurationType configurationType) {
|
||||
@@ -669,7 +677,7 @@ class RunConfigurable extends BaseConfigurable {
|
||||
RunnerAndConfigurationSettings settings = null;
|
||||
if (userObject instanceof SingleConfigurationConfigurable) {
|
||||
final SingleConfigurationConfigurable configurable = (SingleConfigurationConfigurable)userObject;
|
||||
settings = (RunnerAndConfigurationSettings)configurable.getSettings();
|
||||
settings = (RunnerAndConfigurationSettings)configurable.getSettings();
|
||||
if (manager.isTemporary(settings)) {
|
||||
applyConfiguration(typeNode, configurable);
|
||||
}
|
||||
@@ -925,6 +933,11 @@ class RunConfigurable extends BaseConfigurable {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private DefaultMutableTreeNode getNode(int row) {
|
||||
return (DefaultMutableTreeNode)myTree.getPathForRow(row).getLastPathComponent();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
Trinity<Integer, Integer, RowsDnDSupport.RefinedDropSupport.Position> getAvailableDropPosition(int direction) {
|
||||
int[] rows = myTree.getSelectionRows();
|
||||
@@ -944,6 +957,20 @@ class RunConfigurable extends BaseConfigurable {
|
||||
INTO :
|
||||
direction > 0 ? BELOW : ABOVE;
|
||||
if (myTreeModel.canDrop(oldIndex, newIndex, position)) {
|
||||
DefaultMutableTreeNode oldNode = getNode(oldIndex);
|
||||
DefaultMutableTreeNode newNode = getNode(newIndex);
|
||||
if (oldNode.getParent() != newNode.getParent() && getKind(newNode) != FOLDER) {
|
||||
RowsDnDSupport.RefinedDropSupport.Position copy = position;
|
||||
if (position == BELOW) {
|
||||
copy = ABOVE;
|
||||
}
|
||||
else if (position == ABOVE) {
|
||||
copy = BELOW;
|
||||
}
|
||||
if (myTreeModel.canDrop(oldIndex, newIndex, copy)) {
|
||||
return Trinity.create(oldIndex, newIndex, copy);
|
||||
}
|
||||
}
|
||||
return Trinity.create(oldIndex, newIndex, position);
|
||||
}
|
||||
if (position == BELOW && newIndex < myTree.getRowCount() - 1 && myTreeModel.canDrop(oldIndex, newIndex + 1, ABOVE)) {
|
||||
@@ -996,7 +1023,7 @@ class RunConfigurable extends BaseConfigurable {
|
||||
|
||||
private SingleConfigurationConfigurable<RunConfiguration> createNewConfiguration(final RunnerAndConfigurationSettings settings, final DefaultMutableTreeNode node) {
|
||||
final SingleConfigurationConfigurable<RunConfiguration> configurationConfigurable =
|
||||
SingleConfigurationConfigurable.editSettings(settings, null);
|
||||
SingleConfigurationConfigurable.editSettings(settings, null);
|
||||
installUpdateListeners(configurationConfigurable);
|
||||
DefaultMutableTreeNode nodeToAdd = new DefaultMutableTreeNode(configurationConfigurable);
|
||||
myTreeModel.insertNodeInto(nodeToAdd, node, node.getChildCount());
|
||||
@@ -1057,76 +1084,76 @@ class RunConfigurable extends BaseConfigurable {
|
||||
}
|
||||
});
|
||||
final ListPopup popup =
|
||||
popupFactory.createListPopup(new BaseListPopupStep<ConfigurationType>(
|
||||
ExecutionBundle.message("add.new.run.configuration.acrtion.name"), configurationTypes) {
|
||||
popupFactory.createListPopup(new BaseListPopupStep<ConfigurationType>(
|
||||
ExecutionBundle.message("add.new.run.configuration.acrtion.name"), configurationTypes) {
|
||||
|
||||
@NotNull
|
||||
public String getTextFor(final ConfigurationType type) {
|
||||
return type.getDisplayName();
|
||||
@NotNull
|
||||
public String getTextFor(final ConfigurationType type) {
|
||||
return type.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpeedSearchEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(ConfigurationType value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Icon getIconFor(final ConfigurationType type) {
|
||||
return type.getIcon();
|
||||
}
|
||||
|
||||
public PopupStep onChosen(final ConfigurationType type, final boolean finalChoice) {
|
||||
if (hasSubstep(type)) {
|
||||
return getSupStep(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpeedSearchEnabled() {
|
||||
return true;
|
||||
final ConfigurationFactory[] factories = type.getConfigurationFactories();
|
||||
if (factories.length > 0) {
|
||||
createNewConfiguration(factories[0]);
|
||||
}
|
||||
return FINAL_CHOICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(ConfigurationType value) {
|
||||
return true;
|
||||
}
|
||||
public int getDefaultOptionIndex() {
|
||||
ConfigurationType type = getSelectedConfigurationType();
|
||||
return type != null ? ArrayUtilRt.find(configurationTypes, type) : super.getDefaultOptionIndex();
|
||||
}
|
||||
|
||||
public Icon getIconFor(final ConfigurationType type) {
|
||||
return type.getIcon();
|
||||
}
|
||||
|
||||
public PopupStep onChosen(final ConfigurationType type, final boolean finalChoice) {
|
||||
if (hasSubstep(type)) {
|
||||
return getSupStep(type);
|
||||
private ListPopupStep getSupStep(final ConfigurationType type) {
|
||||
final ConfigurationFactory[] factories = type.getConfigurationFactories();
|
||||
Arrays.sort(factories, new Comparator<ConfigurationFactory>() {
|
||||
public int compare(final ConfigurationFactory factory1, final ConfigurationFactory factory2) {
|
||||
return factory1.getName().compareTo(factory2.getName());
|
||||
}
|
||||
final ConfigurationFactory[] factories = type.getConfigurationFactories();
|
||||
if (factories.length > 0) {
|
||||
createNewConfiguration(factories[0]);
|
||||
});
|
||||
return new BaseListPopupStep<ConfigurationFactory>(
|
||||
ExecutionBundle.message("add.new.run.configuration.action.name", type.getDisplayName()), factories) {
|
||||
|
||||
@NotNull
|
||||
public String getTextFor(final ConfigurationFactory value) {
|
||||
return value.getName();
|
||||
}
|
||||
return FINAL_CHOICE;
|
||||
}
|
||||
|
||||
public int getDefaultOptionIndex() {
|
||||
ConfigurationType type = getSelectedConfigurationType();
|
||||
return type != null ? ArrayUtilRt.find(configurationTypes, type) : super.getDefaultOptionIndex();
|
||||
}
|
||||
public Icon getIconFor(final ConfigurationFactory factory) {
|
||||
return factory.getIcon();
|
||||
}
|
||||
|
||||
private ListPopupStep getSupStep(final ConfigurationType type) {
|
||||
final ConfigurationFactory[] factories = type.getConfigurationFactories();
|
||||
Arrays.sort(factories, new Comparator<ConfigurationFactory>() {
|
||||
public int compare(final ConfigurationFactory factory1, final ConfigurationFactory factory2) {
|
||||
return factory1.getName().compareTo(factory2.getName());
|
||||
}
|
||||
});
|
||||
return new BaseListPopupStep<ConfigurationFactory>(
|
||||
ExecutionBundle.message("add.new.run.configuration.action.name", type.getDisplayName()), factories) {
|
||||
public PopupStep onChosen(final ConfigurationFactory factory, final boolean finalChoice) {
|
||||
createNewConfiguration(factory);
|
||||
return FINAL_CHOICE;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getTextFor(final ConfigurationFactory value) {
|
||||
return value.getName();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public Icon getIconFor(final ConfigurationFactory factory) {
|
||||
return factory.getIcon();
|
||||
}
|
||||
public boolean hasSubstep(final ConfigurationType type) {
|
||||
return type.getConfigurationFactories().length > 1;
|
||||
}
|
||||
|
||||
public PopupStep onChosen(final ConfigurationFactory factory, final boolean finalChoice) {
|
||||
createNewConfiguration(factory);
|
||||
return FINAL_CHOICE;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
public boolean hasSubstep(final ConfigurationType type) {
|
||||
return type.getConfigurationFactories().length > 1;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
//new TreeSpeedSearch(myTree);
|
||||
popup.showUnderneathOf(myToolbarDecorator.getActionsPanel());
|
||||
}
|
||||
@@ -1800,7 +1827,7 @@ class RunConfigurable extends BaseConfigurable {
|
||||
} else {
|
||||
index = newParent.getIndex(newNode);
|
||||
if (position == BELOW)
|
||||
index++;
|
||||
index++;
|
||||
}
|
||||
insertNodeInto(oldNode, newParent, index);
|
||||
}
|
||||
|
||||
+10
-1
@@ -104,8 +104,17 @@ extends BeforeRunTaskProvider<RunConfigurationBeforeRunProvider.RunConfigurableB
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public RunConfigurableBeforeRunTask createTask(RunConfiguration runConfiguration) {
|
||||
return getAvailableConfigurations(runConfiguration).isEmpty() ? null : new RunConfigurableBeforeRunTask();
|
||||
if (runConfiguration.getProject().isInitialized()) {
|
||||
Collection<RunnerAndConfigurationSettings> configurations =
|
||||
RunManagerImpl.getInstanceImpl(runConfiguration.getProject()).getSortedConfigurations();
|
||||
if (configurations.isEmpty()
|
||||
|| (configurations.size() == 1 && configurations.iterator().next().getConfiguration() == runConfiguration)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return new RunConfigurableBeforeRunTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -273,6 +273,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
RunnerAndConfigurationSettings template = myTemplateConfigurationsMap.get(factory.getType().getId() + "." + factory.getName());
|
||||
if (template == null) {
|
||||
template = new RunnerAndConfigurationSettingsImpl(this, factory.createTemplateConfiguration(myProject, this), true);
|
||||
template.setSingleton(factory.isConfigurationSingletonByDefault());
|
||||
if (template.getConfiguration() instanceof UnknownRunConfiguration) {
|
||||
((UnknownRunConfiguration)template.getConfiguration()).setDoNotStore(true);
|
||||
}
|
||||
@@ -410,6 +411,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Collection<RunnerAndConfigurationSettings> getSortedConfigurations() {
|
||||
if (!myOrdered) { //compatibility
|
||||
List<Pair<String, RunnerAndConfigurationSettings>> order
|
||||
|
||||
+6
-2
@@ -172,17 +172,21 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C
|
||||
myIsTemplate = Boolean.valueOf(element.getAttributeValue(TEMPLATE_FLAG_ATTRIBUTE)).booleanValue();
|
||||
myTemporary = Boolean.valueOf(element.getAttributeValue(TEMPORARY_ATTRIBUTE)).booleanValue() || TEMP_CONFIGURATION.equals(element.getName());
|
||||
myEditBeforeRun = Boolean.valueOf(element.getAttributeValue(EDIT_BEFORE_RUN)).booleanValue();
|
||||
mySingleton = Boolean.valueOf(element.getAttributeValue(SINGLETON)).booleanValue();
|
||||
myFolderName = element.getAttributeValue(FOLDER_NAME);
|
||||
// singleton is not configurable by user for template
|
||||
if (!myIsTemplate) {
|
||||
mySingleton = Boolean.valueOf(element.getAttributeValue(SINGLETON)).booleanValue();
|
||||
}
|
||||
|
||||
final ConfigurationFactory factory = getFactory(element);
|
||||
if (factory == null) return;
|
||||
|
||||
if (myIsTemplate) {
|
||||
mySingleton = factory.isConfigurationSingletonByDefault();
|
||||
myConfiguration = myManager.getConfigurationTemplate(factory).getConfiguration();
|
||||
} else {
|
||||
final String name = element.getAttributeValue(NAME_ATTR);
|
||||
// souldn't call createConfiguration since it calls StepBeforeRunProviders that
|
||||
// shouldn't call createConfiguration since it calls StepBeforeRunProviders that
|
||||
// may not be loaded yet. This creates initialization order issue.
|
||||
myConfiguration = myManager.doCreateConfiguration(name, factory, false);
|
||||
}
|
||||
|
||||
+5
@@ -32,6 +32,7 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.text.BadLocationException;
|
||||
@@ -187,6 +188,10 @@ public final class SingleConfigurationConfigurable<Config extends RunConfigurati
|
||||
myNameDocument.addDocumentListener(listener);
|
||||
}
|
||||
|
||||
public final void addSharedListener(ChangeListener changeListener) {
|
||||
myComponent.myCbStoreProjectConfiguration.addChangeListener(changeListener);
|
||||
}
|
||||
|
||||
public final void setNameText(final String name) {
|
||||
try {
|
||||
myNameDocument.replace(0, myNameDocument.getLength(), name, null);
|
||||
|
||||
@@ -124,8 +124,8 @@ public abstract class ChooseByNameBase {
|
||||
private final String[][] myNames = new String[2][];
|
||||
private volatile CalcElementsThread myCalcElementsThread;
|
||||
private static int VISIBLE_LIST_SIZE_LIMIT = 10;
|
||||
public static final int MAXIMUM_LIST_SIZE_LIMIT = 30;
|
||||
private int myMaximumListSizeLimit = MAXIMUM_LIST_SIZE_LIMIT;
|
||||
private int myListSizeIncreasing = 30;
|
||||
private int myMaximumListSizeLimit = 30;
|
||||
@NonNls private static final String NOT_FOUND_IN_PROJECT_CARD = "syslib";
|
||||
@NonNls private static final String NOT_FOUND_CARD = "nfound";
|
||||
@NonNls private static final String CHECK_BOX_CARD = "chkbox";
|
||||
@@ -582,7 +582,7 @@ public abstract class ChooseByNameBase {
|
||||
break;
|
||||
case KeyEvent.VK_ENTER:
|
||||
if (myList.getSelectedValue() == EXTRA_ELEM) {
|
||||
myMaximumListSizeLimit += MAXIMUM_LIST_SIZE_LIMIT;
|
||||
myMaximumListSizeLimit += myListSizeIncreasing;
|
||||
rebuildList(myList.getSelectedIndex(), REBUILD_DELAY, null, ModalityState.current());
|
||||
e.consume();
|
||||
}
|
||||
@@ -625,7 +625,7 @@ public abstract class ChooseByNameBase {
|
||||
|
||||
if (selectedCellBounds != null && selectedCellBounds.contains(e.getPoint())) { // Otherwise it was reselected in the selection listener
|
||||
if (myList.getSelectedValue() == EXTRA_ELEM) {
|
||||
myMaximumListSizeLimit += MAXIMUM_LIST_SIZE_LIMIT;
|
||||
myMaximumListSizeLimit += myListSizeIncreasing;
|
||||
rebuildList(selectedIndex, REBUILD_DELAY, null, ModalityState.current());
|
||||
}
|
||||
else {
|
||||
@@ -1547,6 +1547,10 @@ public abstract class ChooseByNameBase {
|
||||
myMaximumListSizeLimit = maximumListSizeLimit;
|
||||
}
|
||||
|
||||
public void setListSizeIncreasing(final int listSizeIncreasing) {
|
||||
myListSizeIncreasing = listSizeIncreasing;
|
||||
}
|
||||
|
||||
private static final String ACTION_NAME = "Show All in View";
|
||||
|
||||
private abstract class ShowFindUsagesAction extends AnAction {
|
||||
|
||||
@@ -327,7 +327,7 @@ public abstract class PsiAnchor {
|
||||
@Nullable
|
||||
public static PsiElement restoreFromStubIndex(PsiFileWithStubSupport fileImpl,
|
||||
int index,
|
||||
IStubElementType elementType) {
|
||||
@NotNull IStubElementType elementType) {
|
||||
if (fileImpl == null) return null;
|
||||
StubTree tree = fileImpl.getStubTree();
|
||||
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public abstract class RenamePsiElementProcessor {
|
||||
}
|
||||
|
||||
public void renameElement(final PsiElement element, String newName, UsageInfo[] usages,
|
||||
RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
@Nullable RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
RenameUtil.doRenameGenericNamedElement(element, newName, usages, listener);
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ public class RenameUtil {
|
||||
}
|
||||
|
||||
public static void doRename(final PsiElement element, String newName, UsageInfo[] usages, final Project project,
|
||||
final RefactoringElementListener listener) throws IncorrectOperationException{
|
||||
@Nullable final RefactoringElementListener listener) throws IncorrectOperationException{
|
||||
final RenamePsiElementProcessor processor = RenamePsiElementProcessor.forElement(element);
|
||||
final String fqn = element instanceof PsiFile ? ((PsiFile)element).getVirtualFile().getPath() : CopyReferenceAction.elementToFqn(element);
|
||||
if (fqn != null) {
|
||||
|
||||
+24
-11
@@ -39,7 +39,7 @@ import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.openapi.wm.ex.WindowManagerEx;
|
||||
import com.intellij.util.PlatformUtils;
|
||||
@@ -58,10 +58,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -330,7 +327,7 @@ public final class UpdateChecker {
|
||||
if (pluginFile == null) continue;
|
||||
|
||||
if (collectToUpdate) {
|
||||
final String finalPluginUrl = pluginFile.getUrl();
|
||||
final String finalPluginUrl = getPluginUrl(pluginFile);
|
||||
final Runnable updatePluginRunnable = new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
@@ -338,9 +335,9 @@ public final class UpdateChecker {
|
||||
if (progressIndicator != null) {
|
||||
progressIndicator.setText(finalPluginUrl);
|
||||
}
|
||||
final PluginDownloader uploader = new PluginDownloader(pluginId, finalPluginUrl, pluginVersion);
|
||||
if (uploader.prepareToInstall()) {
|
||||
downloaded.add(uploader);
|
||||
final PluginDownloader downloader = new PluginDownloader(pluginId, finalPluginUrl, pluginVersion);
|
||||
if (downloader.prepareToInstall()) {
|
||||
downloaded.add(downloader);
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
@@ -364,6 +361,19 @@ public final class UpdateChecker {
|
||||
return success;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getPluginUrl(@NotNull VirtualFile pluginFile) {
|
||||
String protocol = pluginFile.getFileSystem().getProtocol();
|
||||
if (StandardFileSystems.FILE_PROTOCOL.equals(protocol) && SystemInfo.isWindows) {
|
||||
String path = pluginFile.getPath();
|
||||
if (path.length() != 0 && path.charAt(0) != '/') {
|
||||
return protocol + ":///" + path; // fix file URI on Windows
|
||||
}
|
||||
}
|
||||
|
||||
return pluginFile.getUrl();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static CheckForUpdateResult doCheckForUpdates(final UpdateSettings settings) {
|
||||
ApplicationInfo appInfo = ApplicationInfo.getInstance();
|
||||
@@ -514,8 +524,11 @@ public final class UpdateChecker {
|
||||
Future<?> downloadThreadFuture = ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
HttpConfigurable.getInstance().prepareURL(url);
|
||||
final URL requestUrl = new URL(url + "?build=" + ApplicationInfo.getInstance().getBuild().asString());
|
||||
URL requestUrl = new URL(url);
|
||||
if (!StandardFileSystems.FILE_PROTOCOL.equals(requestUrl.getProtocol())) {
|
||||
HttpConfigurable.getInstance().prepareURL(url);
|
||||
requestUrl = new URL(url + "?build=" + ApplicationInfo.getInstance().getBuild().asString());
|
||||
}
|
||||
inputStreams[0] = requestUrl.openStream();
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
+1
-1
@@ -139,7 +139,7 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public void cleanupForNextTest(Set<VirtualFile> survivors) throws IOException {
|
||||
public void cleanupForNextTest(@NotNull Set<VirtualFile> survivors) throws IOException {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -154,6 +154,7 @@ public class MacMainFrameDecorator implements UISettingsListener, Disposable {
|
||||
@Override
|
||||
public void windowEnteredFullScreen(AppEvent.FullScreenEvent event) {
|
||||
myInFullScreen = true;
|
||||
frame.storeFullScreenStateIfNeeded(true);
|
||||
|
||||
JRootPane rootPane = frame.getRootPane();
|
||||
if (rootPane != null) rootPane.putClientProperty(FULL_SCREEN, Boolean.TRUE);
|
||||
|
||||
@@ -14,8 +14,8 @@ import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.channel.*;
|
||||
import org.jboss.netty.channel.group.ChannelGroup;
|
||||
import org.jboss.netty.channel.group.DefaultChannelGroup;
|
||||
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
|
||||
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
|
||||
import org.jboss.netty.channel.socket.oio.OioClientSocketChannelFactory;
|
||||
import org.jboss.netty.handler.codec.http.*;
|
||||
import org.jboss.netty.util.CharsetUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -52,7 +52,7 @@ public class WebServer {
|
||||
application.executeOnPooledThread(command);
|
||||
}
|
||||
};
|
||||
private final NioServerSocketChannelFactory channelFactory = new NioServerSocketChannelFactory(pooledThreadExecutor, pooledThreadExecutor, 2);
|
||||
private final NioServerSocketChannelFactory channelFactory = new NioServerSocketChannelFactory(pooledThreadExecutor, pooledThreadExecutor, 1);
|
||||
|
||||
public boolean isRunning() {
|
||||
return !openChannels.isEmpty();
|
||||
@@ -82,11 +82,12 @@ public class WebServer {
|
||||
}
|
||||
|
||||
private boolean checkPort(final InetSocketAddress remoteAddress) {
|
||||
ClientBootstrap bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(pooledThreadExecutor, pooledThreadExecutor, 1));
|
||||
final ClientBootstrap bootstrap = new ClientBootstrap(new OioClientSocketChannelFactory(pooledThreadExecutor));
|
||||
bootstrap.setOption("child.tcpNoDelay", true);
|
||||
|
||||
final AtomicBoolean result = new AtomicBoolean();
|
||||
final AtomicBoolean result = new AtomicBoolean(false);
|
||||
final Semaphore semaphore = new Semaphore();
|
||||
semaphore.down(); // must call to down() here to ensure that down was called _before_ up()
|
||||
bootstrap.setPipeline(
|
||||
pipeline(new HttpResponseDecoder(), new HttpChunkAggregator(1048576), new HttpRequestEncoder(), new SimpleChannelUpstreamHandler() {
|
||||
@Override
|
||||
@@ -117,13 +118,12 @@ public class WebServer {
|
||||
}
|
||||
}));
|
||||
|
||||
ChannelFuture connectFuture = bootstrap.connect(remoteAddress);
|
||||
ChannelFuture connectFuture = null;
|
||||
try {
|
||||
connectFuture = bootstrap.connect(remoteAddress);
|
||||
if (!waitComplete(connectFuture, "connect")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
semaphore.down();
|
||||
ChannelFuture writeFuture = connectFuture.getChannel().write(new DefaultHttpRequest(HTTP_1_1, HttpMethod.GET, START_TIME_PATH));
|
||||
if (!waitComplete(writeFuture, "write")) {
|
||||
return false;
|
||||
@@ -141,7 +141,9 @@ public class WebServer {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
connectFuture.getChannel().close();
|
||||
if (connectFuture != null) {
|
||||
connectFuture.getChannel().close().awaitUninterruptibly();
|
||||
}
|
||||
bootstrap.releaseExternalResources();
|
||||
}
|
||||
return result.get();
|
||||
|
||||
+9
-11
@@ -25,6 +25,7 @@ import com.intellij.openapi.util.Trinity;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
|
||||
import com.intellij.testFramework.TestFileType;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -44,7 +45,7 @@ import java.util.regex.Pattern;
|
||||
* @since 11/18/10 7:43 PM
|
||||
*/
|
||||
public abstract class AbstractEditorProcessingOnDocumentModificationTest extends LightPlatformCodeInsightTestCase {
|
||||
protected void init(@NotNull String fileText, @NotNull TestFileType type) throws IOException {
|
||||
protected void init(@NotNull @NonNls String fileText, @NotNull TestFileType type) throws IOException {
|
||||
configureFromFileText(getFileName(type), fileText);
|
||||
}
|
||||
|
||||
@@ -52,18 +53,21 @@ public abstract class AbstractEditorProcessingOnDocumentModificationTest extends
|
||||
return getTestName(false) + type.getExtension();
|
||||
}
|
||||
|
||||
protected static void addFoldRegion(final int startOffset, final int endOffset, final String placeholder) {
|
||||
protected static FoldRegion addFoldRegion(final int startOffset, final int endOffset, final String placeholder) {
|
||||
final FoldRegion[] result = new FoldRegion[1];
|
||||
myEditor.getFoldingModel().runBatchFoldingOperation(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myEditor.getFoldingModel().addFoldRegion(startOffset, endOffset, placeholder);
|
||||
result[0] = myEditor.getFoldingModel().addFoldRegion(startOffset, endOffset, placeholder);
|
||||
}
|
||||
});
|
||||
return result[0];
|
||||
}
|
||||
|
||||
protected static void addCollapsedFoldRegion(final int startOffset, final int endOffset, final String placeholder) {
|
||||
addFoldRegion(startOffset, endOffset, placeholder);
|
||||
protected static FoldRegion addCollapsedFoldRegion(final int startOffset, final int endOffset, final String placeholder) {
|
||||
FoldRegion region = addFoldRegion(startOffset, endOffset, placeholder);
|
||||
toggleFoldRegionState(getFoldRegion(startOffset), false);
|
||||
return region;
|
||||
}
|
||||
|
||||
protected static void toggleFoldRegionState(final FoldRegion foldRegion, final boolean expanded) {
|
||||
@@ -200,10 +204,4 @@ public abstract class AbstractEditorProcessingOnDocumentModificationTest extends
|
||||
mapper.rawAdd(visualLine, startOffset, endOffset, startLogicalLine, startLogicalColumn, endLogicalLine, endLogicalColumn, endVisualColumn, foldRegions, tabData);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
setupFolding(
|
||||
"FoldRegion +(0:600), FoldRegion +(640:1573), FoldRegion +(8130:8233), FoldRegion +(10189:10257), FoldRegion +(13582:13686), FoldRegion +(22805:22829), FoldRegion +(24069:24147), FoldRegion +(25024:25214), FoldRegion +(28313:28362), FoldRegion -(-1:-1)(invalid), FoldRegion -(-1:-1)(invalid), FoldRegion -(-1:-1)(invalid), FoldRegion -(-1:-1)(invalid)"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.vfs;
|
||||
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.testFramework.PlatformLangTestCase;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class VirtualFileListenerTest extends PlatformLangTestCase {
|
||||
public void testFireEvent() throws IOException {
|
||||
final VirtualFile dir = getVirtualFile(createTempDir("vDir"));
|
||||
assertNotNull(dir);
|
||||
dir.getChildren();
|
||||
final Ref<Boolean> eventFired = Ref.create(false);
|
||||
VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() {
|
||||
@Override
|
||||
public void fileCreated(VirtualFileEvent event) {
|
||||
eventFired.set(true);
|
||||
}
|
||||
}, myTestRootDisposable);
|
||||
new WriteAction() {
|
||||
protected void run(final Result result) {
|
||||
try {
|
||||
dir.createChildData(this, "x.txt");
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
|
||||
assertTrue(eventFired.get());
|
||||
}
|
||||
}
|
||||
@@ -157,8 +157,9 @@ public class MockRunManager extends RunManagerEx {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Collection<RunnerAndConfigurationSettings> getSortedConfigurations() {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -595,7 +595,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
|
||||
new CommentByLineCommentHandler().invoke(getProject(), getEditor(), getFile());
|
||||
}
|
||||
|
||||
protected static void executeAction(@NotNull final String actionId) {
|
||||
protected static void executeAction(@NonNls @NotNull final String actionId) {
|
||||
CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -86,7 +86,7 @@ public class ContainerUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> LinkedList<T> newLinkedList(T... elements) {
|
||||
public static <T> LinkedList<T> newLinkedList(@NotNull T... elements) {
|
||||
final LinkedList<T> list = newLinkedList();
|
||||
Collections.addAll(list, elements);
|
||||
return list;
|
||||
@@ -103,7 +103,7 @@ public class ContainerUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> ArrayList<T> newArrayList(T... elements) {
|
||||
public static <T> ArrayList<T> newArrayList(@NotNull T... elements) {
|
||||
ArrayList<T> list = newArrayListWithCapacity(elements.length);
|
||||
Collections.addAll(list, elements);
|
||||
return list;
|
||||
@@ -132,7 +132,8 @@ public class ContainerUtilRt {
|
||||
return 5 + size + size / 5;
|
||||
}
|
||||
|
||||
private static <T, C extends Collection<T>> C copy(C collection, @NotNull Iterable<? extends T> elements) {
|
||||
@NotNull
|
||||
private static <T, C extends Collection<T>> C copy(@NotNull C collection, @NotNull Iterable<? extends T> elements) {
|
||||
for (T element : elements) {
|
||||
collection.add(element);
|
||||
}
|
||||
@@ -145,7 +146,7 @@ public class ContainerUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> HashSet<T> newHashSet(T... elements) {
|
||||
public static <T> HashSet<T> newHashSet(@NotNull T... elements) {
|
||||
return new com.intellij.util.containers.HashSet<T>(Arrays.asList(elements));
|
||||
}
|
||||
|
||||
@@ -171,7 +172,7 @@ public class ContainerUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> LinkedHashSet<T> newLinkedHashSet(T... elements) {
|
||||
public static <T> LinkedHashSet<T> newLinkedHashSet(@NotNull T... elements) {
|
||||
return newLinkedHashSet(Arrays.asList(elements));
|
||||
}
|
||||
|
||||
@@ -190,7 +191,7 @@ public class ContainerUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> TreeSet<T> newTreeSet(T... elements) {
|
||||
public static <T> TreeSet<T> newTreeSet(@NotNull T... elements) {
|
||||
TreeSet<T> set = newTreeSet();
|
||||
Collections.addAll(set, elements);
|
||||
return set;
|
||||
@@ -212,48 +213,62 @@ public class ContainerUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> Stack<T> newStack(Collection<T> elements) {
|
||||
public static <T> Stack<T> newStack(@NotNull Collection<T> elements) {
|
||||
return new Stack<T>(elements);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> Stack<T> newStack(T... initial) {
|
||||
public static <T> Stack<T> newStack(@NotNull T... initial) {
|
||||
return new Stack<T>(Arrays.asList(initial));
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimized toArray() as opposed to the {@link java.util.Collections#emptyList()}.
|
||||
*/
|
||||
private static class EmptyList extends AbstractList<Object> implements RandomAccess {
|
||||
private static class EmptyList<T> extends AbstractList<T> implements RandomAccess {
|
||||
private static final EmptyList INSTANCE = new EmptyList();
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Object get(int index) {
|
||||
@Override
|
||||
public T get(int index) {
|
||||
throw new IndexOutOfBoundsException("Index: " + index);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return ArrayUtilRt.EMPTY_OBJECT_ARRAY;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T> T[] toArray(T[] a) {
|
||||
public <T> T[] toArray(@NotNull T[] a) {
|
||||
if (a.length != 0) {
|
||||
a[0] = null;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return EmptyIterator.getInstance();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> List<T> emptyList() {
|
||||
@SuppressWarnings({"unchecked"}) final List<T> list = (List<T>)EmptyList.INSTANCE;
|
||||
return list;
|
||||
//noinspection unchecked
|
||||
return (List<T>)EmptyList.INSTANCE;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
private static final int INSERTION_SORT_THRESHOLD = 10;
|
||||
|
||||
@NotNull
|
||||
public static <T> T[] ar(T... elements) {
|
||||
public static <T> T[] ar(@NotNull T... elements) {
|
||||
return elements;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> LinkedList<T> newLinkedList(T... elements) {
|
||||
public static <T> LinkedList<T> newLinkedList(@NotNull T... elements) {
|
||||
return ContainerUtilRt.newLinkedList(elements);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <E> ArrayList<E> newArrayList(E... array) {
|
||||
public static <E> ArrayList<E> newArrayList(@NotNull E... array) {
|
||||
return ContainerUtilRt.newArrayList(array);
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> HashSet<T> newHashSet(T... elements) {
|
||||
public static <T> HashSet<T> newHashSet(@NotNull T... elements) {
|
||||
return ContainerUtilRt.newHashSet(elements);
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> LinkedHashSet<T> newLinkedHashSet(T... elements) {
|
||||
public static <T> LinkedHashSet<T> newLinkedHashSet(@NotNull T... elements) {
|
||||
return ContainerUtilRt.newLinkedHashSet(elements);
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> THashSet<T> newTroveSet(T... elements) {
|
||||
public static <T> THashSet<T> newTroveSet(@NotNull T... elements) {
|
||||
return newTroveSet(Arrays.asList(elements));
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> TreeSet<T> newTreeSet(T... elements) {
|
||||
public static <T> TreeSet<T> newTreeSet(@NotNull T... elements) {
|
||||
return ContainerUtilRt.newTreeSet(elements);
|
||||
}
|
||||
|
||||
@@ -250,7 +250,8 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
return new ConcurrentHashMap<K, V>();
|
||||
}
|
||||
|
||||
public static <E> List<E> reverse(final List<E> elements) {
|
||||
@NotNull
|
||||
public static <E> List<E> reverse(@NotNull final List<E> elements) {
|
||||
return new AbstractList<E>() {
|
||||
@Override
|
||||
public E get(int index) {
|
||||
@@ -264,6 +265,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <K, V> Map<K, V> union(@NotNull Map<? extends K, ? extends V> map, @NotNull Map<? extends K, ? extends V> map2) {
|
||||
THashMap<K, V> result = new THashMap<K, V>(map.size() + map2.size());
|
||||
result.putAll(map);
|
||||
@@ -271,6 +273,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> Set<T> union(@NotNull Set<T> set, @NotNull Set<T> set2) {
|
||||
THashSet<T> result = new THashSet<T>(set.size() + set2.size());
|
||||
result.addAll(set);
|
||||
@@ -278,24 +281,28 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <E> Set<E> immutableSet(final E ... elements) {
|
||||
@NotNull
|
||||
public static <E> Set<E> immutableSet(@NotNull E ... elements) {
|
||||
return Collections.unmodifiableSet(new THashSet<E>(Arrays.asList(elements)));
|
||||
}
|
||||
|
||||
public static <E> ImmutableList<E> immutableList(E ... array) {
|
||||
@NotNull
|
||||
public static <E> ImmutableList<E> immutableList(@NotNull E ... array) {
|
||||
return new ImmutableListBackedByArray<E>(array);
|
||||
}
|
||||
|
||||
public static <E> ImmutableList<E> immutableList(List<E> list) {
|
||||
@NotNull
|
||||
public static <E> ImmutableList<E> immutableList(@NotNull List<E> list) {
|
||||
return new ImmutableListBackedByList<E>(list);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <K, V> ImmutableMapBuilder<K, V> immutableMapBuilder() {
|
||||
return new ImmutableMapBuilder<K, V>();
|
||||
}
|
||||
|
||||
public static class ImmutableMapBuilder<K, V> {
|
||||
private THashMap<K, V> myMap = new THashMap<K, V>();
|
||||
private final Map<K, V> myMap = new THashMap<K, V>();
|
||||
|
||||
public ImmutableMapBuilder<K, V> put(K key, V value) {
|
||||
myMap.put(key, value);
|
||||
@@ -310,7 +317,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
private static class ImmutableListBackedByList<E> extends ImmutableList<E> {
|
||||
private final List<E> myStore;
|
||||
|
||||
private ImmutableListBackedByList(List<E> list) {
|
||||
private ImmutableListBackedByList(@NotNull List<E> list) {
|
||||
myStore = list;
|
||||
}
|
||||
|
||||
@@ -328,7 +335,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
private static class ImmutableListBackedByArray<E> extends ImmutableList<E> {
|
||||
private final E[] myStore;
|
||||
|
||||
private ImmutableListBackedByArray(E[] array) {
|
||||
private ImmutableListBackedByArray(@NotNull E[] array) {
|
||||
myStore = array;
|
||||
}
|
||||
|
||||
@@ -343,7 +350,8 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
}
|
||||
}
|
||||
|
||||
public static <K, V> Map<K, V> intersection(Map<K, V> map1, Map<K, V> map2) {
|
||||
@NotNull
|
||||
public static <K, V> Map<K, V> intersection(@NotNull Map<K, V> map1, @NotNull Map<K, V> map2) {
|
||||
final Map<K, V> res = newHashMap();
|
||||
final Set<K> keys = newHashSet();
|
||||
keys.addAll(map1.keySet());
|
||||
@@ -351,14 +359,15 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
for (K k : keys) {
|
||||
V v1 = map1.get(k);
|
||||
V v2 = map2.get(k);
|
||||
if (v1 == v2 || (v1 != null && v1.equals(v2))) {
|
||||
if (v1 == v2 || v1 != null && v1.equals(v2)) {
|
||||
res.put(k, v1);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static <K, V> Map<K,Pair<V,V>> diff(Map<K, V> map1, Map<K, V> map2) {
|
||||
@NotNull
|
||||
public static <K, V> Map<K,Pair<V,V>> diff(@NotNull Map<K, V> map1, @NotNull Map<K, V> map2) {
|
||||
final Map<K, Pair<V,V>> res = newHashMap();
|
||||
final Set<K> keys = newHashSet();
|
||||
keys.addAll(map1.keySet());
|
||||
@@ -366,53 +375,70 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
for (K k : keys) {
|
||||
V v1 = map1.get(k);
|
||||
V v2 = map2.get(k);
|
||||
if (!(v1 == v2 || (v1 != null && v1.equals(v2)))) {
|
||||
if (!(v1 == v2 || v1 != null && v1.equals(v2))) {
|
||||
res.put(k, Pair.create(v1, v2));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> List<T> mergeSortedLists(@NotNull List<T> list1, @NotNull List<T> list2, @NotNull Comparator<? super T> comparator, boolean mergeEqualItems){
|
||||
List<T> result = new ArrayList<T>(list1.size() + list2.size());
|
||||
|
||||
public static <T> boolean processSortedListsInOrder(@NotNull List<T> list1,
|
||||
@NotNull List<T> list2,
|
||||
@NotNull Comparator<? super T> comparator,
|
||||
boolean mergeEqualItems,
|
||||
@NotNull Processor<T> processor) {
|
||||
int index1 = 0;
|
||||
int index2 = 0;
|
||||
while (index1 < list1.size() || index2 < list2.size()) {
|
||||
T e;
|
||||
if (index1 >= list1.size()) {
|
||||
result.add(list2.get(index2++));
|
||||
e = list2.get(index2++);
|
||||
}
|
||||
else if (index2 >= list2.size()) {
|
||||
result.add(list1.get(index1++));
|
||||
e = list1.get(index1++);
|
||||
}
|
||||
else {
|
||||
T element1 = list1.get(index1);
|
||||
T element2 = list2.get(index2);
|
||||
int c = comparator.compare(element1, element2);
|
||||
if (c < 0) {
|
||||
result.add(element1);
|
||||
if (c <= 0) {
|
||||
e = element1;
|
||||
index1++;
|
||||
}
|
||||
else if (c > 0) {
|
||||
result.add(element2);
|
||||
index2++;
|
||||
}
|
||||
else {
|
||||
result.add(element1);
|
||||
if (!mergeEqualItems) {
|
||||
result.add(element2);
|
||||
}
|
||||
index1++;
|
||||
e = element2;
|
||||
index2++;
|
||||
}
|
||||
if (c == 0 && !mergeEqualItems) {
|
||||
if (!processor.process(e)) return false;
|
||||
index2++;
|
||||
e = element2;
|
||||
}
|
||||
}
|
||||
if (!processor.process(e)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> List<T> mergeSortedLists(@NotNull List<T> list1,
|
||||
@NotNull List<T> list2,
|
||||
@NotNull Comparator<? super T> comparator,
|
||||
boolean mergeEqualItems) {
|
||||
final List<T> result = new ArrayList<T>(list1.size() + list2.size());
|
||||
processSortedListsInOrder(list1, list2, comparator, mergeEqualItems, new Processor<T>() {
|
||||
@Override
|
||||
public boolean process(T t) {
|
||||
result.add(t);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> List<T> mergeSortedArrays(@NotNull T[] list1, @NotNull T[] list2, @NotNull Comparator<? super T> comparator, boolean mergeEqualItems, @Nullable Processor<? super T> filter){
|
||||
public static <T> List<T> mergeSortedArrays(@NotNull T[] list1, @NotNull T[] list2, @NotNull Comparator<? super T> comparator, boolean mergeEqualItems, @Nullable Processor<? super T> filter) {
|
||||
int index1 = 0;
|
||||
int index2 = 0;
|
||||
List<T> result = new ArrayList<T>(list1.length + list2.length);
|
||||
@@ -462,7 +488,8 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> List<T> subList(List<T> list, int from) {
|
||||
@NotNull
|
||||
public static <T> List<T> subList(@NotNull List<T> list, int from) {
|
||||
return list.subList(from, list.size());
|
||||
}
|
||||
|
||||
@@ -624,6 +651,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
@Nullable
|
||||
public static <T> T find(@NotNull Iterable<? extends T> iterable, final T equalTo) {
|
||||
return find(iterable, new Condition<T>() {
|
||||
@Override
|
||||
public boolean value(final T object) {
|
||||
return equalTo == object || equalTo.equals(object);
|
||||
}
|
||||
@@ -764,6 +792,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Map<String, String> stringMap(@NotNull final String... keyValues) {
|
||||
final Map<String, String> result = newHashMap();
|
||||
for (int i = 0; i < keyValues.length - 1; i+=2) {
|
||||
@@ -781,14 +810,17 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
@NotNull
|
||||
public static <T> Iterator<T> iterate(@NotNull final Enumeration<T> enumeration) {
|
||||
return new Iterator<T>() {
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return enumeration.hasMoreElements();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T next() {
|
||||
return enumeration.nextElement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@@ -804,15 +836,18 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
public static <T> Iterable<T> iterate(@NotNull final Collection<? extends T> collection, @NotNull final Condition<? super T> condition) {
|
||||
if (collection.isEmpty()) return emptyIterable();
|
||||
return new Iterable<T>() {
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return new Iterator<T>() {
|
||||
Iterator<? extends T> impl = collection.iterator();
|
||||
T next = findNext();
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return next != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T next() {
|
||||
T result = next;
|
||||
next = findNext();
|
||||
@@ -830,6 +865,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@@ -841,18 +877,22 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
@NotNull
|
||||
public static <T> Iterable<T> iterateBackward(@NotNull final List<? extends T> list) {
|
||||
return new Iterable<T>() {
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return new Iterator<T>() {
|
||||
ListIterator<? extends T> it = list.listIterator(list.size());
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return it.hasPrevious();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T next() {
|
||||
return it.previous();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
it.remove();
|
||||
}
|
||||
@@ -880,6 +920,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T, A extends T, C extends Collection<T>> C addAll(@NotNull C collection, @NotNull A... elements) {
|
||||
//noinspection ManualArrayToCollectionCopy
|
||||
for (T element : elements) {
|
||||
@@ -891,6 +932,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
/**
|
||||
* Adds all not-null elements from the {@code elements}, ignoring nulls
|
||||
*/
|
||||
@NotNull
|
||||
public static <T, A extends T, C extends Collection<T>> C addAllNotNull(@NotNull C collection, @NotNull A... elements) {
|
||||
//noinspection ManualArrayToCollectionCopy
|
||||
for (T element : elements) {
|
||||
@@ -936,6 +978,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
final int size = size1 + list2.size();
|
||||
|
||||
return new AbstractList<T>() {
|
||||
@Override
|
||||
public T get(int index) {
|
||||
if (index < size1) {
|
||||
return list1.get(index);
|
||||
@@ -944,6 +987,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
return list2.get(index - size1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
@@ -953,6 +997,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
@NotNull
|
||||
public static <T> Iterable<T> concat(@NotNull final Iterable<? extends T>... iterables) {
|
||||
return new Iterable<T>() {
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
Iterator[] iterators = new Iterator[iterables.length];
|
||||
for (int i = 0, iterablesLength = iterables.length; i < iterablesLength; i++) {
|
||||
@@ -966,6 +1011,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
@NotNull
|
||||
public static <T> Iterable<T> concat(@NotNull final T[]... iterables) {
|
||||
return new Iterable<T>() {
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
Iterator[] iterators = new Iterator[iterables.length];
|
||||
for (int i = 0, iterablesLength = iterables.length; i < iterablesLength; i++) {
|
||||
@@ -985,6 +1031,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
}
|
||||
final int finalSize = size;
|
||||
return new AbstractList<T>() {
|
||||
@Override
|
||||
public T get(final int index) {
|
||||
if (index >= 0 && index < finalSize) {
|
||||
int from = 0;
|
||||
@@ -996,6 +1043,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
throw new IndexOutOfBoundsException("index: " + index + "size: " + size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return finalSize;
|
||||
}
|
||||
@@ -1039,7 +1087,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <T> T getFirstItem(final Collection<T> items) {
|
||||
public static <T> T getFirstItem(@Nullable Collection<T> items) {
|
||||
return getFirstItem(items, null);
|
||||
}
|
||||
|
||||
@@ -1065,14 +1113,17 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
return set;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> T[] toArray(@Nullable Collection<T> c, @NotNull ArrayFactory<T> factory) {
|
||||
return c != null ? c.toArray(factory.create(c.size())) : factory.create(0);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> T[] toArray(@NotNull Collection<? extends T> c1, @NotNull Collection<? extends T> c2, @NotNull ArrayFactory<T> factory) {
|
||||
return ArrayUtil.mergeCollections(c1, c2, factory);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> T[] mergeCollectionsToArray(@NotNull Collection<? extends T> c1, @NotNull Collection<? extends T> c2, @NotNull ArrayFactory<T> factory) {
|
||||
return ArrayUtil.mergeCollections(c1, c2, factory);
|
||||
}
|
||||
@@ -1219,9 +1270,11 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T, V> List<V> mapNotNull(@NotNull T[] array, Function<T, V> mapping) {
|
||||
public static <T, V> List<V> mapNotNull(@NotNull T[] array, @NotNull Function<T, V> mapping) {
|
||||
return mapNotNull(Arrays.asList(array), mapping);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T, V> V[] mapNotNull(@NotNull T[] arr, @NotNull Function<T, V> mapping, @NotNull V[] emptyArray) {
|
||||
List<V> result = new ArrayList<V>(arr.length);
|
||||
for (T t : arr) {
|
||||
@@ -1234,7 +1287,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T, V> List<V> mapNotNull(Iterable<? extends T> iterable, Function<T, V> mapping) {
|
||||
public static <T, V> List<V> mapNotNull(@NotNull Iterable<? extends T> iterable, @NotNull Function<T, V> mapping) {
|
||||
List<V> result = new ArrayList<V>();
|
||||
for (T t : iterable) {
|
||||
final V o = mapping.fun(t);
|
||||
@@ -1244,8 +1297,9 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T, V> List<V> mapNotNull(Collection<? extends T> iterable, Function<T, V> mapping) {
|
||||
public static <T, V> List<V> mapNotNull(@NotNull Collection<? extends T> iterable, @NotNull Function<T, V> mapping) {
|
||||
List<V> result = new ArrayList<V>(iterable.size());
|
||||
for (T t : iterable) {
|
||||
final V o = mapping.fun(t);
|
||||
@@ -1284,7 +1338,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> Set<T> set(T ... items) {
|
||||
public static <T> Set<T> set(@NotNull T ... items) {
|
||||
return addAll(newHashSet(items));
|
||||
}
|
||||
|
||||
@@ -1297,6 +1351,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
public static <T> void add(final T element, @NotNull final Collection<T> result, @NotNull final Disposable parentDisposable) {
|
||||
if (result.add(element)) {
|
||||
Disposer.register(parentDisposable, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
result.remove(element);
|
||||
}
|
||||
@@ -1361,6 +1416,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> List<T> unfold(@Nullable T t, @NotNull NullableFunction<T, T> next) {
|
||||
if (t == null) return Collections.emptyList();
|
||||
|
||||
@@ -1473,10 +1529,10 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
* Merge sorted points, which are sorted by x and with equal x by y.
|
||||
* Result is put to x1 y1.
|
||||
*/
|
||||
public static void mergeSortedArrays(TIntArrayList x1,
|
||||
TIntArrayList y1,
|
||||
TIntArrayList x2,
|
||||
TIntArrayList y2) {
|
||||
public static void mergeSortedArrays(@NotNull TIntArrayList x1,
|
||||
@NotNull TIntArrayList y1,
|
||||
@NotNull TIntArrayList x2,
|
||||
@NotNull TIntArrayList y2) {
|
||||
TIntArrayList newX = new TIntArrayList();
|
||||
TIntArrayList newY = new TIntArrayList();
|
||||
|
||||
@@ -1484,12 +1540,12 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
int j = 0;
|
||||
|
||||
while (i < x1.size() && j < x2.size()) {
|
||||
if (x1.get(i) < x2.get(j) || (x1.get(i) == x2.get(j) && y1.get(i) < y2.get(j))) {
|
||||
if (x1.get(i) < x2.get(j) || x1.get(i) == x2.get(j) && y1.get(i) < y2.get(j)) {
|
||||
newX.add(x1.get(i));
|
||||
newY.add(y1.get(i));
|
||||
i++;
|
||||
}
|
||||
else if (x1.get(i) > x2.get(j) || (x1.get(i) == x2.get(j) && y1.get(i) > y2.get(j))) {
|
||||
else if (x1.get(i) > x2.get(j) || x1.get(i) == x2.get(j) && y1.get(i) > y2.get(j)) {
|
||||
newX.add(x2.get(j));
|
||||
newY.add(y2.get(j));
|
||||
j++;
|
||||
@@ -1523,72 +1579,91 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
@NotNull
|
||||
public static <T> Set<T> singleton(final T o, @NotNull final TObjectHashingStrategy<T> strategy) {
|
||||
return new Set<T>() {
|
||||
@Override
|
||||
public int size() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object elem) {
|
||||
return strategy.equals(o, (T)elem);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return new Iterator<T>() {
|
||||
boolean atEnd;
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return !atEnd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T next() {
|
||||
if (atEnd) throw new NoSuchElementException();
|
||||
atEnd = true;
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new IncorrectOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return new Object[]{o};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T> T[] toArray(T[] a) {
|
||||
assert a.length == 1;
|
||||
a[0] = (T)o;
|
||||
return a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(T t) {
|
||||
throw new IncorrectOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
throw new IncorrectOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends T> c) {
|
||||
throw new IncorrectOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> c) {
|
||||
throw new IncorrectOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> c) {
|
||||
throw new IncorrectOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new IncorrectOperationException();
|
||||
}
|
||||
@@ -1599,6 +1674,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
public static <E> List<E> flatten(@NotNull Collection<E>[] collections) {
|
||||
return flatten(Arrays.asList(collections));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <E> List<E> flatten(@NotNull Iterable<? extends Collection<E>> collections) {
|
||||
List<E> result = new ArrayList<E>();
|
||||
@@ -1609,7 +1685,8 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <K,V> V[] convert(K[] from, V[] to, Function<K,V> fun) {
|
||||
@NotNull
|
||||
public static <K,V> V[] convert(@NotNull K[] from, @NotNull V[] to, @NotNull Function<K,V> fun) {
|
||||
if (to.length < from.length) {
|
||||
to = (V[])Array.newInstance(to.getClass().getComponentType(), from.length);
|
||||
}
|
||||
@@ -1619,7 +1696,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
return to;
|
||||
}
|
||||
|
||||
public static <T> boolean containsIdentity(Iterable<T> list, T element) {
|
||||
public static <T> boolean containsIdentity(@NotNull Iterable<T> list, T element) {
|
||||
for (T t : list) {
|
||||
if (t == element) {
|
||||
return true;
|
||||
@@ -1628,7 +1705,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static <T> int indexOfIdentity(List<T> list, T element) {
|
||||
public static <T> int indexOfIdentity(@NotNull List<T> list, T element) {
|
||||
for (int i = 0, listSize = list.size(); i < listSize; i++) {
|
||||
if (list.get(i) == element) {
|
||||
return i;
|
||||
@@ -1638,7 +1715,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
|
||||
}
|
||||
|
||||
public static <T> boolean equalsIdentity(List<T> list1, List<T> list2) {
|
||||
public static <T> boolean equalsIdentity(@NotNull List<T> list1, @NotNull List<T> list2) {
|
||||
int listSize = list1.size();
|
||||
if (list2.size() != listSize) {
|
||||
return false;
|
||||
@@ -1653,7 +1730,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
|
||||
}
|
||||
|
||||
public static <T> int indexOf(List<T> list, Condition<T> condition) {
|
||||
public static <T> int indexOf(@NotNull List<T> list, @NotNull Condition<T> condition) {
|
||||
for (int i = 0, listSize = list.size(); i < listSize; i++) {
|
||||
T t = list.get(i);
|
||||
if (condition.value(t)) {
|
||||
@@ -1663,7 +1740,8 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static <A,B> Map<B,A> reverseMap(Map<A,B> map) {
|
||||
@NotNull
|
||||
public static <A,B> Map<B,A> reverseMap(@NotNull Map<A,B> map) {
|
||||
final Map<B,A> result = newHashMap();
|
||||
for (A a : map.keySet()) {
|
||||
result.put(map.get(a), a);
|
||||
@@ -1671,7 +1749,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> boolean processRecursively(final T root, final PairProcessor<T, List<T>> processor) {
|
||||
public static <T> boolean processRecursively(final T root, @NotNull PairProcessor<T, List<T>> processor) {
|
||||
final LinkedList<T> list = new LinkedList<T>();
|
||||
list.add(root);
|
||||
while (!list.isEmpty()) {
|
||||
@@ -1699,12 +1777,12 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> Stack<T> newStack(Collection<T> initial) {
|
||||
public static <T> Stack<T> newStack(@NotNull Collection<T> initial) {
|
||||
return ContainerUtilRt.newStack(initial);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> Stack<T> newStack(T... initial) {
|
||||
public static <T> Stack<T> newStack(@NotNull T... initial) {
|
||||
return ContainerUtilRt.newStack(initial);
|
||||
}
|
||||
|
||||
@@ -1718,6 +1796,10 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
return ContainerUtilRt.createEmptyCOWList();
|
||||
}
|
||||
|
||||
public static <T> List<T> createLockFreeCopyOnWriteList(@NotNull Collection<? extends T> c) {
|
||||
return new CopyOnWriteArrayList<T>(c);
|
||||
}
|
||||
|
||||
public static <T> void addIfNotNull(@Nullable T element, @NotNull Collection<T> result) {
|
||||
ContainerUtilRt.addIfNotNull(element, result);
|
||||
}
|
||||
|
||||
@@ -41,10 +41,12 @@ public class UnsafeWeakList<T> extends AbstractList<T> {
|
||||
myArray = array;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(int index) {
|
||||
return myArray.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(T element) {
|
||||
tryReduceCapacity(-1);
|
||||
myArray.add(element);
|
||||
@@ -63,24 +65,33 @@ public class UnsafeWeakList<T> extends AbstractList<T> {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int index, T element) {
|
||||
tryReduceCapacity(-1);
|
||||
myArray.add(index, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T remove(int index) {
|
||||
tryReduceCapacity(-1);
|
||||
return myArray.remove(index);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return new MyIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return myArray.size();
|
||||
}
|
||||
|
||||
public void clear(int index) {
|
||||
myArray.removeReference(index);
|
||||
}
|
||||
|
||||
public List<T> toStrongList() {
|
||||
List<T> result = new ArrayList<T>(myArray.size());
|
||||
myArray.toStrongCollection(result);
|
||||
@@ -134,10 +145,12 @@ public class UnsafeWeakList<T> extends AbstractList<T> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return myNextElement != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T next() {
|
||||
if (modCount != myModCount) throw new ConcurrentModificationException();
|
||||
if (myNextElement == null) throw new NoSuchElementException();
|
||||
@@ -147,6 +160,7 @@ public class UnsafeWeakList<T> extends AbstractList<T> {
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
if (myCurrentIndex == -1) throw new IllegalStateException();
|
||||
myArray.remove(myCurrentIndex);
|
||||
|
||||
@@ -64,6 +64,7 @@ public class ReadWriteDirectBufferWrapper extends DirectBufferWrapper {
|
||||
channel.position(myPosition);
|
||||
buffer.rewind();
|
||||
channel.write(buffer);
|
||||
myDirty = false;
|
||||
}
|
||||
finally {
|
||||
channel.close();
|
||||
|
||||
+73
-112
@@ -35,6 +35,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
|
||||
@Override
|
||||
@@ -46,15 +49,13 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"try.finally.can.be.try.with.resources.display.name");
|
||||
return InspectionGadgetsBundle.message("try.finally.can.be.try.with.resources.display.name");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String buildErrorString(Object... infos) {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"try.finally.can.be.try.with.resources.problem.descriptor");
|
||||
return InspectionGadgetsBundle.message("try.finally.can.be.try.with.resources.problem.descriptor");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,16 +63,13 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
return new TryFinallyCanBeTryWithResourcesFix();
|
||||
}
|
||||
|
||||
private static class TryFinallyCanBeTryWithResourcesFix
|
||||
extends InspectionGadgetsFix {
|
||||
private static class TryFinallyCanBeTryWithResourcesFix extends InspectionGadgetsFix {
|
||||
|
||||
public TryFinallyCanBeTryWithResourcesFix() {
|
||||
}
|
||||
public TryFinallyCanBeTryWithResourcesFix() {}
|
||||
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"try.finally.can.be.try.with.resources.quickfix");
|
||||
return InspectionGadgetsBundle.message("try.finally.can.be.try.with.resources.quickfix");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,7 +87,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
final PsiElement[] tryBlockChildren = tryBlock.getChildren();
|
||||
final Set<PsiLocalVariable> variables = new HashSet();
|
||||
for (PsiLocalVariable variable : collectVariables(tryStatement)) {
|
||||
if (!isVariableUsedOutsideContext(variable, tryStatement)) {
|
||||
if (!isVariableUsedOutsideContext(variable, tryBlock)) {
|
||||
variables.add(variable);
|
||||
}
|
||||
}
|
||||
@@ -110,10 +108,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
if (separator) {
|
||||
newTryStatementText.append(';');
|
||||
}
|
||||
newTryStatementText.append(variable.getTypeElement().getText());
|
||||
newTryStatementText.append(' ');
|
||||
newTryStatementText.append(variable.getName());
|
||||
newTryStatementText.append('=');
|
||||
newTryStatementText.append(variable.getTypeElement().getText()).append(' ').append(variable.getName()).append('=');
|
||||
if (hasInitializer) {
|
||||
newTryStatementText.append(initializer.getText());
|
||||
}
|
||||
@@ -200,31 +195,24 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
tryStatement.replace(newTryStatement);
|
||||
}
|
||||
|
||||
private static boolean isCloseStatement(
|
||||
PsiElement element, Set<PsiLocalVariable> variables) {
|
||||
private static boolean isCloseStatement(PsiElement element, Set<PsiLocalVariable> variables) {
|
||||
if (element instanceof PsiExpressionStatement) {
|
||||
final PsiExpressionStatement expressionStatement =
|
||||
(PsiExpressionStatement)element;
|
||||
final PsiExpression expression =
|
||||
expressionStatement.getExpression();
|
||||
final PsiExpressionStatement expressionStatement = (PsiExpressionStatement)element;
|
||||
final PsiExpression expression = expressionStatement.getExpression();
|
||||
if (!(expression instanceof PsiMethodCallExpression)) {
|
||||
return false;
|
||||
}
|
||||
final PsiMethodCallExpression methodCallExpression =
|
||||
(PsiMethodCallExpression)expression;
|
||||
final PsiReferenceExpression methodExpression =
|
||||
methodCallExpression.getMethodExpression();
|
||||
final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)expression;
|
||||
final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
|
||||
final String methodName = methodExpression.getReferenceName();
|
||||
if (!HardcodedMethodConstants.CLOSE.equals(methodName)) {
|
||||
return false;
|
||||
}
|
||||
final PsiExpression qualifier =
|
||||
methodExpression.getQualifierExpression();
|
||||
final PsiExpression qualifier = methodExpression.getQualifierExpression();
|
||||
if (!(qualifier instanceof PsiReferenceExpression)) {
|
||||
return false;
|
||||
}
|
||||
final PsiReferenceExpression referenceExpression =
|
||||
(PsiReferenceExpression)qualifier;
|
||||
final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)qualifier;
|
||||
final PsiElement target = referenceExpression.resolve();
|
||||
if (!(target instanceof PsiLocalVariable)) {
|
||||
return false;
|
||||
@@ -241,10 +229,8 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
if (!(condition instanceof PsiBinaryExpression)) {
|
||||
return false;
|
||||
}
|
||||
final PsiBinaryExpression binaryExpression =
|
||||
(PsiBinaryExpression)condition;
|
||||
final IElementType tokenType =
|
||||
binaryExpression.getOperationTokenType();
|
||||
final PsiBinaryExpression binaryExpression = (PsiBinaryExpression)condition;
|
||||
final IElementType tokenType = binaryExpression.getOperationTokenType();
|
||||
if (!JavaTokenType.NE.equals(tokenType)) {
|
||||
return false;
|
||||
}
|
||||
@@ -258,8 +244,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
if (!(lhs instanceof PsiReferenceExpression)) {
|
||||
return false;
|
||||
}
|
||||
final PsiReferenceExpression referenceExpression =
|
||||
(PsiReferenceExpression)lhs;
|
||||
final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)lhs;
|
||||
variable = referenceExpression.resolve();
|
||||
if (!(variable instanceof PsiLocalVariable)) {
|
||||
return false;
|
||||
@@ -269,8 +254,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
if (!(rhs instanceof PsiReferenceExpression)) {
|
||||
return false;
|
||||
}
|
||||
final PsiReferenceExpression referenceExpression =
|
||||
(PsiReferenceExpression)rhs;
|
||||
final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)rhs;
|
||||
variable = referenceExpression.resolve();
|
||||
if (!(variable instanceof PsiLocalVariable)) {
|
||||
return false;
|
||||
@@ -284,13 +268,10 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
return isCloseStatement(thenBranch, variables);
|
||||
}
|
||||
else if (thenBranch instanceof PsiBlockStatement) {
|
||||
final PsiBlockStatement blockStatement =
|
||||
(PsiBlockStatement)thenBranch;
|
||||
final PsiCodeBlock codeBlock =
|
||||
blockStatement.getCodeBlock();
|
||||
final PsiBlockStatement blockStatement = (PsiBlockStatement)thenBranch;
|
||||
final PsiCodeBlock codeBlock = blockStatement.getCodeBlock();
|
||||
final PsiStatement[] statements = codeBlock.getStatements();
|
||||
return statements.length == 1 &&
|
||||
isCloseStatement(statements[0], variables);
|
||||
return statements.length == 1 && isCloseStatement(statements[0], variables);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
@@ -307,8 +288,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
return new TryFinallyCanBeTryWithResourcesVisitor();
|
||||
}
|
||||
|
||||
private static class TryFinallyCanBeTryWithResourcesVisitor
|
||||
extends BaseInspectionVisitor {
|
||||
private static class TryFinallyCanBeTryWithResourcesVisitor extends BaseInspectionVisitor {
|
||||
|
||||
@Override
|
||||
public void visitTryStatement(PsiTryStatement tryStatement) {
|
||||
@@ -320,15 +300,14 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
if (resourceList != null) {
|
||||
return;
|
||||
}
|
||||
final List<PsiLocalVariable> variables =
|
||||
collectVariables(tryStatement);
|
||||
if (variables.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final PsiCodeBlock tryBlock = tryStatement.getTryBlock();
|
||||
if (tryBlock == null) {
|
||||
return;
|
||||
}
|
||||
final List<PsiLocalVariable> variables = collectVariables(tryStatement);
|
||||
if (variables.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final PsiStatement[] tryBlockStatements = tryBlock.getStatements();
|
||||
boolean found = false;
|
||||
for (PsiVariable variable : variables) {
|
||||
@@ -341,10 +320,9 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
final PsiType type = initializer.getType();
|
||||
hasInitializer = !PsiType.NULL.equals(type);
|
||||
}
|
||||
final int index = findInitialization(tryBlockStatements,
|
||||
variable, hasInitializer);
|
||||
final int index = findInitialization(tryBlockStatements, variable, hasInitializer);
|
||||
if (index >= 0 ^ hasInitializer) {
|
||||
if (isVariableUsedOutsideContext(variable, tryStatement)) {
|
||||
if (isVariableUsedOutsideContext(variable, tryBlock)) {
|
||||
continue;
|
||||
}
|
||||
found = true;
|
||||
@@ -358,14 +336,9 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isVariableUsedOutsideContext(
|
||||
PsiVariable variable, PsiElement context) {
|
||||
final VariableUsedOutsideContextVisitor visitor =
|
||||
new VariableUsedOutsideContextVisitor(variable,
|
||||
context);
|
||||
final PsiElement declarationScope =
|
||||
PsiTreeUtil.getParentOfType(variable,
|
||||
PsiCodeBlock.class);
|
||||
static boolean isVariableUsedOutsideContext(PsiVariable variable, PsiElement context) {
|
||||
final VariableUsedOutsideContextVisitor visitor = new VariableUsedOutsideContextVisitor(variable, context);
|
||||
final PsiElement declarationScope = PsiTreeUtil.getParentOfType(variable, PsiCodeBlock.class);
|
||||
if (declarationScope == null) {
|
||||
return true;
|
||||
}
|
||||
@@ -373,8 +346,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
return visitor.variableIsUsed();
|
||||
}
|
||||
|
||||
static List<PsiLocalVariable> collectVariables(
|
||||
PsiTryStatement tryStatement) {
|
||||
static List<PsiLocalVariable> collectVariables(PsiTryStatement tryStatement) {
|
||||
final PsiCodeBlock finallyBlock = tryStatement.getFinallyBlock();
|
||||
if (finallyBlock == null) {
|
||||
return Collections.EMPTY_LIST;
|
||||
@@ -385,8 +357,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
}
|
||||
final List<PsiLocalVariable> variables = new ArrayList();
|
||||
for (PsiStatement statement : statements) {
|
||||
final PsiLocalVariable variable =
|
||||
findAutoCloseableVariable(statement);
|
||||
final PsiLocalVariable variable = findAutoCloseableVariable(statement);
|
||||
if (variable != null) {
|
||||
variables.add(variable);
|
||||
}
|
||||
@@ -395,8 +366,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static PsiLocalVariable findAutoCloseableVariable(
|
||||
PsiStatement statement) {
|
||||
static PsiLocalVariable findAutoCloseableVariable(PsiStatement statement) {
|
||||
if (statement instanceof PsiIfStatement) {
|
||||
final PsiIfStatement ifStatement = (PsiIfStatement)statement;
|
||||
if (ifStatement.getElseBranch() != null) {
|
||||
@@ -406,10 +376,8 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
if (!(condition instanceof PsiBinaryExpression)) {
|
||||
return null;
|
||||
}
|
||||
final PsiBinaryExpression binaryExpression =
|
||||
(PsiBinaryExpression)condition;
|
||||
final IElementType tokenType =
|
||||
binaryExpression.getOperationTokenType();
|
||||
final PsiBinaryExpression binaryExpression = (PsiBinaryExpression)condition;
|
||||
final IElementType tokenType = binaryExpression.getOperationTokenType();
|
||||
if (!JavaTokenType.NE.equals(tokenType)) {
|
||||
return null;
|
||||
}
|
||||
@@ -423,8 +391,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
if (!(lhs instanceof PsiReferenceExpression)) {
|
||||
return null;
|
||||
}
|
||||
final PsiReferenceExpression referenceExpression =
|
||||
(PsiReferenceExpression)lhs;
|
||||
final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)lhs;
|
||||
variable = referenceExpression.resolve();
|
||||
if (!(variable instanceof PsiLocalVariable)) {
|
||||
return null;
|
||||
@@ -434,8 +401,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
if (!(rhs instanceof PsiReferenceExpression)) {
|
||||
return null;
|
||||
}
|
||||
final PsiReferenceExpression referenceExpression =
|
||||
(PsiReferenceExpression)rhs;
|
||||
final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)rhs;
|
||||
variable = referenceExpression.resolve();
|
||||
if (!(variable instanceof PsiLocalVariable)) {
|
||||
return null;
|
||||
@@ -450,10 +416,8 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
resourceVariable = findAutoCloseableVariable(thenBranch);
|
||||
}
|
||||
else if (thenBranch instanceof PsiBlockStatement) {
|
||||
final PsiBlockStatement blockStatement =
|
||||
(PsiBlockStatement)thenBranch;
|
||||
final PsiCodeBlock codeBlock =
|
||||
blockStatement.getCodeBlock();
|
||||
final PsiBlockStatement blockStatement = (PsiBlockStatement)thenBranch;
|
||||
final PsiCodeBlock codeBlock = blockStatement.getCodeBlock();
|
||||
final PsiStatement[] statements = codeBlock.getStatements();
|
||||
if (statements.length != 1) {
|
||||
return null;
|
||||
@@ -468,33 +432,24 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
}
|
||||
}
|
||||
else if (statement instanceof PsiExpressionStatement) {
|
||||
final PsiExpressionStatement expressionStatement =
|
||||
(PsiExpressionStatement)statement;
|
||||
final PsiExpression expression =
|
||||
expressionStatement.getExpression();
|
||||
final PsiExpressionStatement expressionStatement = (PsiExpressionStatement)statement;
|
||||
final PsiExpression expression = expressionStatement.getExpression();
|
||||
if (!(expression instanceof PsiMethodCallExpression)) {
|
||||
return null;
|
||||
}
|
||||
final PsiMethodCallExpression methodCallExpression =
|
||||
(PsiMethodCallExpression)expression;
|
||||
final PsiReferenceExpression methodExpression =
|
||||
methodCallExpression.getMethodExpression();
|
||||
final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)expression;
|
||||
final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
|
||||
final String methodName = methodExpression.getReferenceName();
|
||||
if (!HardcodedMethodConstants.CLOSE.equals(methodName)) {
|
||||
return null;
|
||||
}
|
||||
final PsiExpression qualifier =
|
||||
methodExpression.getQualifierExpression();
|
||||
final PsiExpression qualifier = methodExpression.getQualifierExpression();
|
||||
if (!(qualifier instanceof PsiReferenceExpression)) {
|
||||
return null;
|
||||
}
|
||||
final PsiReferenceExpression referenceExpression =
|
||||
(PsiReferenceExpression)qualifier;
|
||||
final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)qualifier;
|
||||
final PsiElement target = referenceExpression.resolve();
|
||||
if (!(target instanceof PsiLocalVariable)) {
|
||||
return null;
|
||||
}
|
||||
if (target instanceof PsiResourceVariable) {
|
||||
if (!(target instanceof PsiLocalVariable) || target instanceof PsiResourceVariable) {
|
||||
return null;
|
||||
}
|
||||
final PsiLocalVariable variable = (PsiLocalVariable)target;
|
||||
@@ -516,8 +471,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
return aClass != null && InheritanceUtil.isInheritor(aClass, CommonClassNames.JAVA_LANG_AUTO_CLOSEABLE);
|
||||
}
|
||||
|
||||
static int findInitialization(
|
||||
PsiElement[] elements, PsiVariable variable,
|
||||
static int findInitialization(PsiElement[] elements, PsiVariable variable,
|
||||
boolean hasInitializer) {
|
||||
int result = -1;
|
||||
final int statementsLength = elements.length;
|
||||
@@ -526,21 +480,17 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
if (!(element instanceof PsiExpressionStatement)) {
|
||||
continue;
|
||||
}
|
||||
final PsiExpressionStatement expressionStatement =
|
||||
(PsiExpressionStatement)element;
|
||||
final PsiExpression expression =
|
||||
expressionStatement.getExpression();
|
||||
final PsiExpressionStatement expressionStatement = (PsiExpressionStatement)element;
|
||||
final PsiExpression expression = expressionStatement.getExpression();
|
||||
if (!(expression instanceof PsiAssignmentExpression)) {
|
||||
continue;
|
||||
}
|
||||
final PsiAssignmentExpression assignmentExpression =
|
||||
(PsiAssignmentExpression)expression;
|
||||
final PsiAssignmentExpression assignmentExpression = (PsiAssignmentExpression)expression;
|
||||
final PsiExpression lhs = assignmentExpression.getLExpression();
|
||||
if (!(lhs instanceof PsiReferenceExpression)) {
|
||||
continue;
|
||||
}
|
||||
final PsiReferenceExpression referenceExpression =
|
||||
(PsiReferenceExpression)lhs;
|
||||
final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)lhs;
|
||||
final PsiElement target = referenceExpression.resolve();
|
||||
if (variable.equals(target)) {
|
||||
if (result >= 0 && !hasInitializer) {
|
||||
@@ -552,15 +502,13 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
return result;
|
||||
}
|
||||
|
||||
static class VariableUsedOutsideContextVisitor
|
||||
extends JavaRecursiveElementVisitor {
|
||||
static class VariableUsedOutsideContextVisitor extends JavaRecursiveElementVisitor {
|
||||
|
||||
private boolean used = false;
|
||||
@NotNull private final PsiVariable variable;
|
||||
private final PsiElement skipContext;
|
||||
|
||||
public VariableUsedOutsideContextVisitor(@NotNull PsiVariable variable,
|
||||
PsiElement skipContext) {
|
||||
public VariableUsedOutsideContextVisitor(@NotNull PsiVariable variable, PsiElement skipContext) {
|
||||
this.variable = variable;
|
||||
this.skipContext = skipContext;
|
||||
}
|
||||
@@ -577,8 +525,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitReferenceExpression(
|
||||
@NotNull PsiReferenceExpression referenceExpression) {
|
||||
public void visitReferenceExpression(@NotNull PsiReferenceExpression referenceExpression) {
|
||||
if (used) {
|
||||
return;
|
||||
}
|
||||
@@ -587,11 +534,25 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
if (target == null) {
|
||||
return;
|
||||
}
|
||||
if (target.equals(variable)) {
|
||||
if (target.equals(variable) && !isCloseMethodCalled(referenceExpression)) {
|
||||
used = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isCloseMethodCalled(PsiReferenceExpression referenceExpression) {
|
||||
final PsiMethodCallExpression methodCallExpression = PsiTreeUtil.getParentOfType(referenceExpression, PsiMethodCallExpression.class);
|
||||
if (methodCallExpression == null) {
|
||||
return false;
|
||||
}
|
||||
final PsiExpressionList argumentList = methodCallExpression.getArgumentList();
|
||||
if (argumentList.getExpressions().length != 0) {
|
||||
return false;
|
||||
}
|
||||
final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
|
||||
final String name = methodExpression.getReferenceName();
|
||||
return HardcodedMethodConstants.CLOSE.equals(name);
|
||||
}
|
||||
|
||||
public boolean variableIsUsed() {
|
||||
return used;
|
||||
}
|
||||
|
||||
@@ -446,7 +446,8 @@ public class ParenthesesUtils {
|
||||
|
||||
public static boolean areParenthesesNeeded(PsiExpression expression, PsiExpression parentExpression,
|
||||
boolean ignoreClarifyingParentheses) {
|
||||
if (parentExpression instanceof PsiParenthesizedExpression) {
|
||||
if (parentExpression instanceof PsiParenthesizedExpression || parentExpression instanceof PsiArrayAccessExpression ||
|
||||
parentExpression instanceof PsiArrayInitializerExpression) {
|
||||
return false;
|
||||
}
|
||||
final int parentPrecedence = getPrecedence(parentExpression);
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.siyeh.igtest.migration.try_finally_can_be_try_with_resources;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
class TryFinallyCanBeTryWithResources {
|
||||
|
||||
public void read1() throws IOException {
|
||||
final InputStream stream = new InputStream() {
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
try {
|
||||
stream.read();
|
||||
} finally {
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void write2() throws IOException {
|
||||
final InputStream stream = new InputStream() {
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
try {
|
||||
stream.read();
|
||||
} finally {
|
||||
System.out.println(stream);
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>TryFinallyCanBeTryWithResources.java</file>
|
||||
<line>16</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'try finally' replaceable with 'try' with resources</problem_class>
|
||||
<description><code>try</code> can use automatic resource management #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.siyeh.ig.migration;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
|
||||
public class TryFinallyCanBeTryWithResourcesInspectionTest extends IGInspectionTestCase {
|
||||
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
|
||||
return JavaSdkImpl.getMockJdk17();
|
||||
}
|
||||
|
||||
public void test() throws Exception {
|
||||
doTest("com/siyeh/igtest/migration/try_finally_can_be_try_with_resources", new TryFinallyCanBeTryWithResourcesInspection());
|
||||
}
|
||||
}
|
||||
@@ -36,16 +36,21 @@ import java.util.List;
|
||||
*/
|
||||
public class RadFragment extends RadViewComponent implements IConfigurableComponent {
|
||||
private static final Property NAME_PROPERTY =
|
||||
new FragmentProperty("name", new ResourceEditor(null, Collections.<AttributeFormat>emptySet(), null) {
|
||||
@Override
|
||||
protected void showDialog() {
|
||||
String fragment = chooseFragment(myRootComponent);
|
||||
new FragmentProperty("name",
|
||||
new MyResourceEditor(),
|
||||
JavadocParser.build("name", "Supply the name of the fragment class to instantiate."));
|
||||
|
||||
private static final Property CLASS_PROPERTY = new FragmentProperty("class",
|
||||
new MyResourceEditor(),
|
||||
JavadocParser.build("class",
|
||||
"Supply the name of the fragment class to instantiate.")) {
|
||||
@Nullable
|
||||
@Override
|
||||
protected String getNamespace() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
if (fragment != null) {
|
||||
setValue(fragment);
|
||||
}
|
||||
}
|
||||
}, JavadocParser.build("name", "Supply the name of the fragment class to instantiate."));
|
||||
private static final Property TAG_PROPERTY = new FragmentProperty("tag", new TextEditorWrapper(),
|
||||
JavadocParser.build(
|
||||
"tag",
|
||||
@@ -56,6 +61,7 @@ public class RadFragment extends RadViewComponent implements IConfigurableCompon
|
||||
" {@link android.app.admin.DeviceAdminReceiver#DEVICE_ADMIN_META_DATA}\n" +
|
||||
" meta-data entry. Described here are the attributes that can be\n" +
|
||||
" included in that tag."));
|
||||
|
||||
private static final String NAME_KEY = "fragment.name";
|
||||
|
||||
@Override
|
||||
@@ -97,9 +103,25 @@ public class RadFragment extends RadViewComponent implements IConfigurableCompon
|
||||
if (!properties.isEmpty()) {
|
||||
properties = new ArrayList<Property>(properties);
|
||||
properties.add(NAME_PROPERTY);
|
||||
properties.add(CLASS_PROPERTY);
|
||||
properties.add(IdProperty.INSTANCE);
|
||||
properties.add(TAG_PROPERTY);
|
||||
}
|
||||
super.setProperties(properties);
|
||||
}
|
||||
|
||||
private static final class MyResourceEditor extends ResourceEditor {
|
||||
public MyResourceEditor() {
|
||||
super(null, Collections.<AttributeFormat>emptySet(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showDialog() {
|
||||
String fragment = chooseFragment(myRootComponent);
|
||||
|
||||
if (fragment != null) {
|
||||
setValue(fragment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -520,6 +520,8 @@
|
||||
class="android.widget.ImageView"
|
||||
tag="ImageView">
|
||||
|
||||
<presentation title=" - "%src%""/>
|
||||
|
||||
<palette title="ImageView" icon="AndroidDesignerIcons.ImageView"
|
||||
tooltip="Displays an arbitrary image, such as an icon."/>
|
||||
|
||||
@@ -542,6 +544,8 @@
|
||||
class="android.widget.ImageButton"
|
||||
tag="ImageButton">
|
||||
|
||||
<presentation title=" - "%src%""/>
|
||||
|
||||
<palette title="ImageButton" icon="AndroidDesignerIcons.ImageButton"
|
||||
tooltip="Displays a button with an image (instead of text) that can be pressed or clicked by the user."/>
|
||||
|
||||
|
||||
+14
-7
@@ -16,7 +16,6 @@
|
||||
package com.intellij.android.designer.propertyTable;
|
||||
|
||||
import com.android.SdkConstants;
|
||||
import com.intellij.android.designer.model.ModelParser;
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.designer.model.PropertiesContainer;
|
||||
import com.intellij.designer.model.Property;
|
||||
@@ -55,7 +54,7 @@ public class FragmentProperty extends Property<RadViewComponent> implements IXml
|
||||
|
||||
@Override
|
||||
public Object getValue(@NotNull RadViewComponent component) throws Exception {
|
||||
String value = component.getTag().getAttributeValue(myAttribute, SdkConstants.NS_RESOURCES);
|
||||
String value = component.getTag().getAttributeValue(myAttribute, getNamespace());
|
||||
return value == null ? "" : value;
|
||||
}
|
||||
|
||||
@@ -65,10 +64,13 @@ public class FragmentProperty extends Property<RadViewComponent> implements IXml
|
||||
@Override
|
||||
public void run() {
|
||||
if (StringUtil.isEmpty((String)value)) {
|
||||
ModelParser.deleteAttribute(component, myAttribute);
|
||||
XmlAttribute attribute = component.getTag().getAttribute(myAttribute, getNamespace());
|
||||
if (attribute != null) {
|
||||
attribute.delete();
|
||||
}
|
||||
}
|
||||
else {
|
||||
component.getTag().setAttribute(myAttribute, SdkConstants.NS_RESOURCES, (String)value);
|
||||
component.getTag().setAttribute(myAttribute, getNamespace(), (String)value);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -76,12 +78,12 @@ public class FragmentProperty extends Property<RadViewComponent> implements IXml
|
||||
|
||||
@Override
|
||||
public boolean isDefaultValue(@NotNull RadViewComponent component) throws Exception {
|
||||
return component.getTag().getAttribute(myAttribute, SdkConstants.NS_RESOURCES) == null;
|
||||
return component.getTag().getAttribute(myAttribute, getNamespace()) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultValue(@NotNull RadViewComponent component) throws Exception {
|
||||
if (component.getTag().getAttribute(myAttribute, SdkConstants.NS_RESOURCES) != null) {
|
||||
if (component.getTag().getAttribute(myAttribute, getNamespace()) != null) {
|
||||
setValue(component, null);
|
||||
}
|
||||
}
|
||||
@@ -109,6 +111,11 @@ public class FragmentProperty extends Property<RadViewComponent> implements IXml
|
||||
|
||||
@Override
|
||||
public boolean checkAttribute(RadViewComponent component, XmlAttribute attribute) {
|
||||
return component.getTag().getAttribute(myAttribute, SdkConstants.NS_RESOURCES) == attribute;
|
||||
return component.getTag().getAttribute(myAttribute, getNamespace()) == attribute;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getNamespace() {
|
||||
return SdkConstants.NS_RESOURCES;
|
||||
}
|
||||
}
|
||||
@@ -251,7 +251,7 @@ public class AndroidRenameResourceProcessor extends RenamePsiElementProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renameElement(PsiElement element, final String newName, UsageInfo[] usages, RefactoringElementListener listener)
|
||||
public void renameElement(PsiElement element, final String newName, UsageInfo[] usages, @Nullable RefactoringElementListener listener)
|
||||
throws IncorrectOperationException {
|
||||
if (element instanceof PsiField) {
|
||||
new RenameJavaVariableProcessor().renameElement(element, newName, usages, listener);
|
||||
|
||||
@@ -178,6 +178,7 @@ public class AndroidLogcatToolWindowFactory implements ToolWindowFactory {
|
||||
private static void checkFacetAndSdk(Project project, AndroidLogcatView view) {
|
||||
final List<AndroidFacet> facets = ProjectFacetManager.getInstance(project).getFacets(AndroidFacet.ID);
|
||||
final ConsoleView console = view.getLogConsole().getConsole();
|
||||
assert console != null;
|
||||
|
||||
if (facets.size() == 0) {
|
||||
console.clear();
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.android.ddmlib.Log;
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.diagnostic.logging.LogConsoleBase;
|
||||
import com.intellij.diagnostic.logging.LogConsoleListener;
|
||||
import com.intellij.execution.ui.ConsoleView;
|
||||
import com.intellij.facet.ProjectFacetManager;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.Disposable;
|
||||
@@ -392,7 +393,10 @@ public abstract class AndroidLogcatView implements Disposable {
|
||||
}
|
||||
}
|
||||
if (device != null) {
|
||||
myLogConsole.getConsole().clear();
|
||||
final ConsoleView console = myLogConsole.getConsole();
|
||||
if (console != null) {
|
||||
console.clear();
|
||||
}
|
||||
final Pair<Reader, Writer> pair = AndroidLogcatUtil.startLoggingThread(myProject, device, false, myLogConsole);
|
||||
if (pair != null) {
|
||||
myCurrentReader = pair.first;
|
||||
|
||||
@@ -217,6 +217,7 @@ public class GitRevisionNumber implements ShortVcsRevisionNumber {
|
||||
@NotNull
|
||||
public static GitRevisionNumber parseRevlistOutputAsRevisionNumber(@NotNull GitSimpleHandler h, @NotNull String output) {
|
||||
StringTokenizer tokenizer = new StringTokenizer(output, "\n\r \t", false);
|
||||
assert tokenizer.hasMoreTokens() : "No required tokens in the output: \n" + output;
|
||||
Date timestamp = GitUtil.parseTimestampWithNFEReport(tokenizer.nextToken(), h, output);
|
||||
return new GitRevisionNumber(tokenizer.nextToken(), timestamp);
|
||||
}
|
||||
|
||||
@@ -18,13 +18,9 @@ package git4idea.repo;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.components.AbstractProjectComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.DumbAwareRunnable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
|
||||
import com.intellij.openapi.vcs.VcsRoot;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import git4idea.GitPlatformFacade;
|
||||
@@ -39,7 +35,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
/**
|
||||
* @author Kirill Likhodedov
|
||||
*/
|
||||
public class GitRepositoryManagerImpl extends AbstractProjectComponent implements Disposable, GitRepositoryManager {
|
||||
public class GitRepositoryManagerImpl extends AbstractProjectComponent implements Disposable, GitRepositoryManager, VcsListener {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance(GitRepositoryManager.class);
|
||||
|
||||
@@ -61,12 +57,8 @@ public class GitRepositoryManagerImpl extends AbstractProjectComponent implement
|
||||
@Override
|
||||
public void initComponent() {
|
||||
Disposer.register(myProject, this);
|
||||
GitRootScanner rootScanner = new GitRootScanner(myProject, new DumbAwareRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateRepositoriesCollection();
|
||||
}
|
||||
});
|
||||
myProject.getMessageBus().connect().subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, this);
|
||||
GitRootScanner rootScanner = new GitRootScanner(myProject);
|
||||
Disposer.register(this, rootScanner);
|
||||
}
|
||||
|
||||
@@ -81,6 +73,11 @@ public class GitRepositoryManagerImpl extends AbstractProjectComponent implement
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void directoryMappingChanged() {
|
||||
updateRepositoriesCollection();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public GitRepository getRepositoryForRoot(@Nullable VirtualFile root) {
|
||||
|
||||
@@ -40,7 +40,6 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public class GitRootScanner implements BulkFileListener, ModuleRootListener, Disposable, VcsListener {
|
||||
|
||||
@NotNull private final Runnable myExecuteAfterScan;
|
||||
@NotNull private final GitRootProblemNotifier myRootProblemNotifier;
|
||||
|
||||
private volatile boolean myProjectIsInitialized;
|
||||
@@ -49,8 +48,7 @@ public class GitRootScanner implements BulkFileListener, ModuleRootListener, Dis
|
||||
@NotNull private final Alarm myAlarm;
|
||||
private static final long WAIT_BEFORE_SCAN = TimeUnit.SECONDS.toMillis(1);
|
||||
|
||||
public GitRootScanner(@NotNull Project project, @NotNull Runnable executeAfterScan) {
|
||||
myExecuteAfterScan = executeAfterScan;
|
||||
public GitRootScanner(@NotNull Project project) {
|
||||
myRootProblemNotifier = GitRootProblemNotifier.getInstance(project);
|
||||
|
||||
StartupManager.getInstance(project).runWhenProjectIsInitialized(new DumbAwareRunnable() {
|
||||
@@ -118,7 +116,6 @@ public class GitRootScanner implements BulkFileListener, ModuleRootListener, Dis
|
||||
@Override
|
||||
public void run() {
|
||||
myRootProblemNotifier.rescanAndNotifyIfNeeded();
|
||||
myExecuteAfterScan.run();
|
||||
}
|
||||
}, WAIT_BEFORE_SCAN);
|
||||
}
|
||||
|
||||
+42
-10
@@ -12,11 +12,15 @@ import com.intellij.util.Alarm;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.gradle.diff.GradleProjectStructureChange;
|
||||
import org.jetbrains.plugins.gradle.manage.GradleProjectEntityChangeListener;
|
||||
import org.jetbrains.plugins.gradle.model.gradle.GradleProject;
|
||||
import org.jetbrains.plugins.gradle.task.GradleTaskManager;
|
||||
import org.jetbrains.plugins.gradle.task.GradleTaskType;
|
||||
import org.jetbrains.plugins.gradle.util.GradleUtil;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
@@ -26,21 +30,26 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
* @author Denis Zhdanov
|
||||
* @since 11/3/11 3:57 PM
|
||||
*/
|
||||
public class GradleProjectStructureChangesDetector extends AbstractProjectComponent {
|
||||
|
||||
public class GradleProjectStructureChangesDetector extends AbstractProjectComponent implements GradleProjectStructureChangeListener {
|
||||
|
||||
private static final int REFRESH_DELAY_MILLIS = (int)500;
|
||||
|
||||
private final Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD);
|
||||
private final AtomicLong myStartRefreshTime = new AtomicLong();
|
||||
private final RefreshRequest myRequest = new RefreshRequest();
|
||||
private final AtomicInteger myImportCounter = new AtomicInteger();
|
||||
|
||||
public GradleProjectStructureChangesDetector(@NotNull Project project) {
|
||||
private final Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD);
|
||||
private final AtomicLong myStartRefreshTime = new AtomicLong();
|
||||
private final RefreshRequest myRequest = new RefreshRequest();
|
||||
private final AtomicInteger myImportCounter = new AtomicInteger();
|
||||
private final AtomicBoolean myNewChangesDetected = new AtomicBoolean();
|
||||
|
||||
@NotNull private final GradleProjectStructureChangesModel myChangesModel;
|
||||
|
||||
public GradleProjectStructureChangesDetector(@NotNull Project project, @NotNull GradleProjectStructureChangesModel model) {
|
||||
super(project);
|
||||
myChangesModel = model;
|
||||
myChangesModel.addListener(this);
|
||||
subscribeToGradleImport(project);
|
||||
subscribeToRootChanges(project);
|
||||
}
|
||||
|
||||
|
||||
private void subscribeToGradleImport(@NotNull Project project) {
|
||||
MessageBusConnection connection = project.getMessageBus().connect(project);
|
||||
connection.subscribe(GradleProjectEntityChangeListener.TOPIC, new GradleProjectEntityChangeListener() {
|
||||
@@ -77,11 +86,34 @@ public class GradleProjectStructureChangesDetector extends AbstractProjectCompon
|
||||
treeModel.rebuild();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onChanges(@NotNull Collection<GradleProjectStructureChange> oldChanges,
|
||||
@NotNull Collection<GradleProjectStructureChange> currentChanges)
|
||||
{
|
||||
myNewChangesDetected.set(true);
|
||||
}
|
||||
|
||||
private void scheduleUpdate() {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We experienced a situation when project root change event has been fired but no actual project structure change has
|
||||
// occurred (e.g. compile output directory was modified externally). That's why we perform additional check here in order
|
||||
// to ensure that project structure has really been changed.
|
||||
//
|
||||
// The idea is to check are there any new project structure changes comparing to the gradle project structure used last time.
|
||||
// We don't do anything in case no new changes have been detected.
|
||||
GradleProject project = myChangesModel.getGradleProject();
|
||||
if (project != null) {
|
||||
myNewChangesDetected.set(false);
|
||||
myChangesModel.update(project);
|
||||
if (!myNewChangesDetected.get()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
myStartRefreshTime.set(System.currentTimeMillis() + REFRESH_DELAY_MILLIS);
|
||||
myAlarm.cancelAllRequests();
|
||||
myAlarm.addRequest(myRequest, REFRESH_DELAY_MILLIS);
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ public class RenameAliasImportedMethodProcessor extends RenameJavaMethodProcesso
|
||||
public void renameElement(PsiElement psiElement,
|
||||
String newName,
|
||||
UsageInfo[] usages,
|
||||
RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
@Nullable RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
boolean isGetter = isSimplePropertyGetter((PsiMethod)psiElement);
|
||||
boolean isSetter = isSimplePropertySetter((PsiMethod)psiElement);
|
||||
|
||||
|
||||
+2
-1
@@ -24,6 +24,7 @@ import com.intellij.refactoring.rename.RenameJavaMethodProcessor;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils;
|
||||
|
||||
@@ -46,7 +47,7 @@ public class RenameGrAccessorProcessor extends RenameJavaMethodProcessor {
|
||||
public void renameElement(PsiElement psiElement,
|
||||
String newName,
|
||||
UsageInfo[] usages,
|
||||
RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
@Nullable RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -33,6 +33,7 @@ import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.util.containers.hash.HashMap;
|
||||
import com.intellij.util.containers.hash.LinkedHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.GrReferenceAdjuster;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
@@ -84,7 +85,7 @@ public class RenameGrFieldProcessor extends RenameJavaVariableProcessor {
|
||||
public void renameElement(final PsiElement psiElement,
|
||||
String newName,
|
||||
final UsageInfo[] usages,
|
||||
final RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
@Nullable RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
final GrField field = (GrField)psiElement;
|
||||
String fieldName = field.getName();
|
||||
Map<PsiElement, String> renames = new HashMap<PsiElement, String>();
|
||||
@@ -164,7 +165,9 @@ public class RenameGrFieldProcessor extends RenameJavaVariableProcessor {
|
||||
rename(element, info, newName, true, manager);
|
||||
}
|
||||
}
|
||||
listener.elementRenamed(field);
|
||||
if (listener != null) {
|
||||
listener.elementRenamed(field);
|
||||
}
|
||||
}
|
||||
|
||||
private static void rename(PsiNamedElement element,
|
||||
|
||||
+2
-1
@@ -23,6 +23,7 @@ import com.intellij.refactoring.rename.RenamePsiElementProcessor;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils;
|
||||
@@ -57,7 +58,7 @@ public class RenameGroovyPropertyProcessor extends RenamePsiElementProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renameElement(PsiElement element, String newName, UsageInfo[] usages, RefactoringElementListener listener)
|
||||
public void renameElement(PsiElement element, String newName, UsageInfo[] usages, @Nullable RefactoringElementListener listener)
|
||||
throws IncorrectOperationException {
|
||||
|
||||
//do nothing
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
serviceImplementation="org.zmlx.hg4idea.HgProjectSettings"/>
|
||||
<projectService serviceInterface="org.zmlx.hg4idea.HgRootsHandler"
|
||||
serviceImplementation="org.zmlx.hg4idea.HgRootsHandler" />
|
||||
<projectService serviceInterface="org.zmlx.hg4idea.HgRememberedInputs"
|
||||
serviceImplementation="org.zmlx.hg4idea.HgRememberedInputs"/>
|
||||
</extensions>
|
||||
|
||||
<project-components>
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
|
||||
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Consumer;
|
||||
@@ -64,16 +63,16 @@ public class HgPusher {
|
||||
VcsBalloonProblemNotifier.showOverChangesView(myProject, "No Mercurial repositories in the project", MessageType.ERROR);
|
||||
}
|
||||
VirtualFile firstRepo = repositories.get(0);
|
||||
final String defaultPushPath = getDefaultPushPath(myProject, firstRepo);
|
||||
final List<HgTagBranch> branches = getBranches(myProject, firstRepo);
|
||||
|
||||
final AtomicReference<HgPushCommand> pushCommand = new AtomicReference<HgPushCommand>();
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final HgPushDialog dialog = new HgPushDialog(myProject, repositories, defaultPushPath, branches);
|
||||
final HgPushDialog dialog = new HgPushDialog(myProject, repositories, branches);
|
||||
dialog.show();
|
||||
if (dialog.isOK()) {
|
||||
dialog.rememberSettings();
|
||||
pushCommand.set(preparePushCommand(myProject, dialog));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.zmlx.hg4idea;
|
||||
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Nadya Zabrodina
|
||||
*/
|
||||
@State(
|
||||
name = "HgRememberedInputs",
|
||||
storages = @Storage(file = StoragePathMacros.WORKSPACE_FILE)
|
||||
)
|
||||
public class HgRememberedInputs implements PersistentStateComponent<HgRememberedInputs.State> {
|
||||
private State myState = new State();
|
||||
|
||||
public static class State {
|
||||
public List<String> repositoryUrls = new ArrayList<String>();
|
||||
}
|
||||
|
||||
|
||||
public static HgRememberedInputs getInstance(@NotNull Project project) {
|
||||
return ServiceManager.getService(project, HgRememberedInputs.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public State getState() {
|
||||
return myState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(State state) {
|
||||
myState = state;
|
||||
}
|
||||
|
||||
public void addRepositoryUrl(@NotNull String url) {
|
||||
if (!myState.repositoryUrls.contains(url)) { // don't add multiple entries for a single path
|
||||
myState.repositoryUrls.add(url);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<String> getRepositoryUrls() {
|
||||
return myState.repositoryUrls;
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ public class HgPullAction extends HgAbstractGlobalAction {
|
||||
dialog.setRoots(repos);
|
||||
dialog.show();
|
||||
if (dialog.isOK()) {
|
||||
dialog.rememberSettings();
|
||||
return buildCommand(dialog, project);
|
||||
}
|
||||
return null;
|
||||
@@ -42,7 +43,7 @@ public class HgPullAction extends HgAbstractGlobalAction {
|
||||
};
|
||||
}
|
||||
|
||||
private HgGlobalCommand buildCommand(final HgPullDialog dialog, final Project project) {
|
||||
private static HgGlobalCommand buildCommand(final HgPullDialog dialog, final Project project) {
|
||||
return new HgGlobalCommand() {
|
||||
public VirtualFile getRepo() {
|
||||
return dialog.getRepository();
|
||||
|
||||
@@ -39,11 +39,15 @@
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<component id="c2c92" class="javax.swing.JTextField" binding="sourceTxt">
|
||||
<component id="6e2e4" class="com.intellij.ui.EditorComboBox" binding="myRepositoryURL" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<properties>
|
||||
<editable value="true"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
|
||||
@@ -13,16 +13,19 @@
|
||||
package org.zmlx.hg4idea.ui;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.event.DocumentAdapter;
|
||||
import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.EditorComboBox;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.zmlx.hg4idea.HgRememberedInputs;
|
||||
import org.zmlx.hg4idea.command.HgShowConfigCommand;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Collection;
|
||||
@@ -31,8 +34,8 @@ public class HgPullDialog extends DialogWrapper {
|
||||
|
||||
private final Project project;
|
||||
private HgRepositorySelectorComponent hgRepositorySelector;
|
||||
private JTextField sourceTxt;
|
||||
private JPanel mainPanel;
|
||||
private EditorComboBox myRepositoryURL;
|
||||
|
||||
public HgPullDialog(Project project) {
|
||||
super(project, false);
|
||||
@@ -43,31 +46,36 @@ public class HgPullDialog extends DialogWrapper {
|
||||
onChangeRepository();
|
||||
}
|
||||
});
|
||||
DocumentListener documentListener = new DocumentListener() {
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
onChangePullSource();
|
||||
}
|
||||
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
onChangePullSource();
|
||||
}
|
||||
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
onChangePullSource();
|
||||
}
|
||||
};
|
||||
sourceTxt.getDocument().addDocumentListener(documentListener);
|
||||
setTitle("Pull");
|
||||
setOKButtonText("Pull");
|
||||
init();
|
||||
}
|
||||
|
||||
public void createUIComponents() {
|
||||
myRepositoryURL = new EditorComboBox("");
|
||||
final HgRememberedInputs rememberedInputs = HgRememberedInputs.getInstance(project);
|
||||
myRepositoryURL.setHistory(ArrayUtil.toObjectArray(rememberedInputs.getRepositoryUrls(), String.class));
|
||||
myRepositoryURL.addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
public void documentChanged(DocumentEvent e) {
|
||||
onChangePullSource();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void rememberSettings() {
|
||||
final HgRememberedInputs rememberedInputs = HgRememberedInputs.getInstance(project);
|
||||
rememberedInputs.addRepositoryUrl(getSource());
|
||||
}
|
||||
|
||||
|
||||
public VirtualFile getRepository() {
|
||||
return hgRepositorySelector.getRepository();
|
||||
}
|
||||
|
||||
public String getSource() {
|
||||
return sourceTxt.getText();
|
||||
return myRepositoryURL.getText();
|
||||
}
|
||||
|
||||
public void setRoots(Collection<VirtualFile> repos) {
|
||||
@@ -94,7 +102,7 @@ public class HgPullDialog extends DialogWrapper {
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sourceTxt.setText(defaultPath);
|
||||
myRepositoryURL.setText(defaultPath);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -104,7 +112,7 @@ public class HgPullDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
private void onChangePullSource() {
|
||||
setOKActionEnabled(!StringUtil.isEmptyOrSpaces(sourceTxt.getText()));
|
||||
setOKActionEnabled(!StringUtil.isEmptyOrSpaces(myRepositoryURL.getText()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,12 +21,6 @@
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="e003e" class="javax.swing.JTextField" binding="repositoryTxt">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<grid id="3b42" 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>
|
||||
@@ -98,10 +92,19 @@
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="e003e"/>
|
||||
<text value="&Destination Repository URL"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="6389e" class="com.intellij.ui.EditorComboBox" binding="myRepositoryURL" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<editable value="true"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
|
||||
@@ -14,13 +14,17 @@ package org.zmlx.hg4idea.ui;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.editor.event.DocumentAdapter;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.EditorComboBox;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.zmlx.hg4idea.HgPusher;
|
||||
import org.zmlx.hg4idea.HgRememberedInputs;
|
||||
import org.zmlx.hg4idea.HgVcsMessages;
|
||||
import org.zmlx.hg4idea.command.HgTagBranch;
|
||||
|
||||
@@ -39,22 +43,18 @@ public class HgPushDialog extends DialogWrapper {
|
||||
private final Project myProject;
|
||||
|
||||
private JPanel contentPanel;
|
||||
private JTextField repositoryTxt;
|
||||
private JCheckBox revisionCbx;
|
||||
private JTextField revisionTxt;
|
||||
private HgRepositorySelectorComponent hgRepositorySelectorComponent;
|
||||
private JCheckBox forceCheckBox;
|
||||
private JCheckBox branchCheckBox;
|
||||
private JComboBox branchComboBox;
|
||||
private EditorComboBox myRepositoryURL;
|
||||
|
||||
public HgPushDialog(Project project, Collection<VirtualFile> repos, String defaultPushPath, List<HgTagBranch> branches) {
|
||||
public HgPushDialog(Project project, Collection<VirtualFile> repos, List<HgTagBranch> branches) {
|
||||
super(project, false);
|
||||
myProject = project;
|
||||
|
||||
hgRepositorySelectorComponent.setRoots(repos);
|
||||
updateBranchComboBox(branches);
|
||||
updateRepositoryUrlText(defaultPushPath);
|
||||
|
||||
hgRepositorySelectorComponent.setTitle("Select repository to push from");
|
||||
hgRepositorySelectorComponent.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@@ -65,12 +65,27 @@ public class HgPushDialog extends DialogWrapper {
|
||||
final UpdatingListener updatingListener = new UpdatingListener();
|
||||
revisionCbx.addChangeListener(updatingListener);
|
||||
branchCheckBox.addChangeListener(updatingListener);
|
||||
repositoryTxt.getDocument().addDocumentListener(updatingListener);
|
||||
revisionTxt.getDocument().addDocumentListener(updatingListener);
|
||||
|
||||
setTitle(HgVcsMessages.message("hg4idea.push.dialog.title"));
|
||||
setOKButtonText("Push");
|
||||
init();
|
||||
|
||||
hgRepositorySelectorComponent.setRoots(repos);
|
||||
updateBranchComboBox(branches);
|
||||
updateRepository();
|
||||
}
|
||||
|
||||
public void createUIComponents() {
|
||||
myRepositoryURL = new EditorComboBox("");
|
||||
final HgRememberedInputs rememberedInputs = HgRememberedInputs.getInstance(myProject);
|
||||
myRepositoryURL.setHistory(ArrayUtil.toObjectArray(rememberedInputs.getRepositoryUrls(), String.class));
|
||||
myRepositoryURL.addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
public void documentChanged(com.intellij.openapi.editor.event.DocumentEvent e) {
|
||||
setOKActionEnabled(!StringUtil.isEmptyOrSpaces(myRepositoryURL.getText()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public VirtualFile getRepository() {
|
||||
@@ -78,7 +93,7 @@ public class HgPushDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
public String getTarget() {
|
||||
return repositoryTxt.getText();
|
||||
return myRepositoryURL.getText();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -123,7 +138,7 @@ public class HgPushDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
private void updateRepositoryUrlText(String defaultPath) {
|
||||
repositoryTxt.setText(defaultPath);
|
||||
myRepositoryURL.setText(defaultPath);
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -138,7 +153,7 @@ public class HgPushDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
private boolean validateOptions() {
|
||||
return !StringUtil.isEmptyOrSpaces(repositoryTxt.getText())
|
||||
return !StringUtil.isEmptyOrSpaces(myRepositoryURL.getText())
|
||||
&& !(revisionCbx.isSelected() && StringUtil.isEmptyOrSpaces(revisionTxt.getText()))
|
||||
&& !(branchCheckBox.isSelected() && (branchComboBox.getSelectedItem() == null));
|
||||
}
|
||||
@@ -148,6 +163,11 @@ public class HgPushDialog extends DialogWrapper {
|
||||
return HgPushDialog.class.getName();
|
||||
}
|
||||
|
||||
public void rememberSettings() {
|
||||
final HgRememberedInputs rememberedInputs = HgRememberedInputs.getInstance(myProject);
|
||||
rememberedInputs.addRepositoryUrl(myRepositoryURL.getText());
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the form on every change.
|
||||
*/
|
||||
|
||||
+1
-1
@@ -172,7 +172,7 @@ public class MavenResourcesBuilder extends TargetBuilder<MavenResourceRootDescri
|
||||
}
|
||||
}
|
||||
|
||||
context.processMessage(new ProgressMessage("Finished copying resources [" + target.getModule().getName() + "]"));
|
||||
context.processMessage(new ProgressMessage(""));
|
||||
}
|
||||
|
||||
|
||||
|
||||
+33
-29
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.jetbrains.idea.maven.dom;
|
||||
|
||||
import com.intellij.idea.Bombed;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
@@ -24,6 +25,7 @@ import com.intellij.psi.xml.XmlTag;
|
||||
import org.jetbrains.idea.maven.indices.MavenIndicesTestFixture;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
public class MavenPluginCompletionAndResolutionTest extends MavenDomWithIndicesTestCase {
|
||||
@@ -343,36 +345,38 @@ public class MavenPluginCompletionAndResolutionTest extends MavenDomWithIndicesT
|
||||
|
||||
checkHighlighting();
|
||||
}
|
||||
public void testDontHighlightGoalsForUnresolvedPlugin() throws Throwable {
|
||||
createProjectPom("<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
|
||||
"<build>" +
|
||||
" <plugins>" +
|
||||
" <plugin>" +
|
||||
" <artifactId>maven-compiler-plugin</artifactId>" +
|
||||
" <executions>" +
|
||||
" <execution>" +
|
||||
" <goals>" +
|
||||
" <goal>compile</goal>" +
|
||||
" <goal><error>unknownGoal</error></goal>" +
|
||||
" </goals>" +
|
||||
" </execution>" +
|
||||
" </executions>" +
|
||||
" </plugin>" +
|
||||
" <plugin>" +
|
||||
" <artifactId><error>unresolved-plugin</error></artifactId>" +
|
||||
" <executions>" +
|
||||
" <execution>" +
|
||||
" <goals>" +
|
||||
" <goal>compile</goal>" +
|
||||
" <goal>unknownGoal</goal>" +
|
||||
" </goals>" +
|
||||
" </execution>" +
|
||||
" </executions>" +
|
||||
" </plugin>" +
|
||||
" </plugins>" +
|
||||
@Bombed(day = 10, month = Calendar.DECEMBER, year = 2012)
|
||||
public void testDontHighlightGoalsForUnresolvedPlugin() throws Throwable {
|
||||
createProjectPom("<groupId>test</groupId>\n" +
|
||||
"<artifactId>project</artifactId>\n" +
|
||||
"<version>1</version>\n" +
|
||||
|
||||
"<build>\n" +
|
||||
" <plugins>\n" +
|
||||
" <plugin>\n" +
|
||||
" <artifactId>maven-compiler-plugin</artifactId>\n" +
|
||||
" <executions>\n" +
|
||||
" <execution>\n" +
|
||||
" <goals>\n" +
|
||||
" <goal>compile</goal>\n" +
|
||||
" <goal><error>unknownGoal</error></goal>\n" +
|
||||
" </goals>\n" +
|
||||
" </execution>\n" +
|
||||
" </executions>\n" +
|
||||
" </plugin>\n" +
|
||||
" <plugin>\n" +
|
||||
" <artifactId><error>unresolved-plugin</error></artifactId>\n" +
|
||||
" <executions>\n" +
|
||||
" <execution>\n" +
|
||||
" <goals>\n" +
|
||||
" <goal>compile</goal>\n" +
|
||||
" <goal>unknownGoal</goal>\n" +
|
||||
" </goals>\n" +
|
||||
" </execution>\n" +
|
||||
" </executions>\n" +
|
||||
" </plugin>\n" +
|
||||
" </plugins>\n" +
|
||||
"</build>");
|
||||
|
||||
checkHighlighting();
|
||||
|
||||
@@ -75,9 +75,7 @@ public class IgnoredFilesTest extends Svn17TestCase {
|
||||
myVcsManager.registerVcs(myVcs);
|
||||
myVcsManager.setDirectoryMapping(myWorkingCopyDir.getPath(), myVcs.getName());
|
||||
|
||||
((ProjectComponent)myChangeListManager).projectOpened();
|
||||
myVcsDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject);
|
||||
((ProjectComponent)myVcsDirtyScopeManager).projectOpened();
|
||||
myLocalFileSystem = LocalFileSystem.getInstance();
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
@@ -74,9 +74,7 @@ public class IgnoredFilesTest extends Svn16TestCase {
|
||||
myVcsManager.registerVcs(myVcs);
|
||||
myVcsManager.setDirectoryMapping(myWorkingCopyDir.getPath(), myVcs.getName());
|
||||
|
||||
((ProjectComponent)myChangeListManager).projectOpened();
|
||||
myVcsDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject);
|
||||
((ProjectComponent)myVcsDirtyScopeManager).projectOpened();
|
||||
myLocalFileSystem = LocalFileSystem.getInstance();
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
@@ -48,7 +48,6 @@ public class GotoTaskAction extends GotoActionBase {
|
||||
}
|
||||
|
||||
void perform(final Project project) {
|
||||
myInAction = getClass();
|
||||
final Ref<Boolean> shiftPressed = Ref.create(false);
|
||||
|
||||
final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, new GotoTaskPopupModel(project), new ChooseByNameItemProvider() {
|
||||
@@ -134,8 +133,12 @@ public class GotoTaskAction extends GotoActionBase {
|
||||
});
|
||||
final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
|
||||
actionToolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
|
||||
actionToolbar.updateActionsImmediately();
|
||||
actionToolbar.getComponent().setFocusable(false);
|
||||
actionToolbar.getComponent().setBorder(null);
|
||||
popup.setToolArea(actionToolbar.getComponent());
|
||||
popup.setMaximumListSizeLimit(10);
|
||||
popup.setListSizeIncreasing(10);
|
||||
|
||||
showNavigationPopup(new GotoActionCallback<Object>() {
|
||||
@Override
|
||||
@@ -205,8 +208,7 @@ public class GotoTaskAction extends GotoActionBase {
|
||||
|
||||
@Override
|
||||
public String getCheckBoxName() {
|
||||
return null;
|
||||
//return "Include closed tasks";
|
||||
return "Include closed tasks";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -54,16 +55,18 @@ public class SwitchTaskAction extends BaseTaskAction {
|
||||
DataContext dataContext = e.getDataContext();
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
|
||||
assert project != null;
|
||||
final ListPopupImpl popup = createPopup(dataContext, null, true);
|
||||
ListPopupImpl popup = createPopup(dataContext, null, true);
|
||||
popup.showCenteredInCurrentWindow(project);
|
||||
}
|
||||
|
||||
public static ListPopupImpl createPopup(final DataContext dataContext, @Nullable final Runnable onDispose, boolean withTitle) {
|
||||
public static ListPopupImpl createPopup(final DataContext dataContext,
|
||||
@Nullable final Runnable onDispose,
|
||||
boolean withTitle) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
|
||||
final Ref<Boolean> shiftPressed = Ref.create(false);
|
||||
final Ref<JComponent> componentRef = Ref.create();
|
||||
List<TaskListItem> items = project == null ? Collections.<TaskListItem>emptyList() :
|
||||
createPopupActionGroup(project, shiftPressed, dataContext);
|
||||
createPopupActionGroup(project, shiftPressed, PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext));
|
||||
final String title = withTitle ? "Switch to Task" : null;
|
||||
ListPopupStep<TaskListItem> step = new MultiSelectionListPopupStep<TaskListItem>(title, items) {
|
||||
@Override
|
||||
@@ -73,7 +76,8 @@ public class SwitchTaskAction extends BaseTaskAction {
|
||||
return FINAL_CHOICE;
|
||||
}
|
||||
ActionGroup group = createActionsStep(selectedValues, project, shiftPressed);
|
||||
return JBPopupFactory.getInstance().createActionsStep(group, DataManager.getInstance().getDataContext(componentRef.get()), false, false, null, null, true);
|
||||
return JBPopupFactory.getInstance()
|
||||
.createActionsStep(group, DataManager.getInstance().getDataContext(componentRef.get()), false, false, null, null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -165,7 +169,7 @@ public class SwitchTaskAction extends BaseTaskAction {
|
||||
@NotNull
|
||||
private static List<TaskListItem> createPopupActionGroup(@NotNull final Project project,
|
||||
final Ref<Boolean> shiftPressed,
|
||||
final DataContext dataContext) {
|
||||
final Component contextComponent) {
|
||||
List<TaskListItem> group = new ArrayList<TaskListItem>();
|
||||
|
||||
final AnAction action = ActionManager.getInstance().getAction(GotoTaskAction.ID);
|
||||
@@ -176,8 +180,7 @@ public class SwitchTaskAction extends BaseTaskAction {
|
||||
@Override
|
||||
void select() {
|
||||
ActionManager.getInstance().tryToExecute(gotoTaskAction, ActionCommand.getInputEvent(GotoTaskAction.ID),
|
||||
PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext), ActionPlaces.UNKNOWN, true);
|
||||
gotoTaskAction.perform(project);
|
||||
contextComponent, ActionPlaces.UNKNOWN, false);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -232,12 +235,13 @@ public class SwitchTaskAction extends BaseTaskAction {
|
||||
});
|
||||
|
||||
boolean removeIt = true;
|
||||
l: for (LocalChangeList list : lists) {
|
||||
l:
|
||||
for (LocalChangeList list : lists) {
|
||||
if (!list.getChanges().isEmpty()) {
|
||||
int result = Messages.showYesNoCancelDialog(project,
|
||||
"Changelist associated with '" + task.getSummary() + "' is not empty.\n" +
|
||||
"Do you want to remove it and move the changes to the active changelist?",
|
||||
"Changelist Not Empty", Messages.getWarningIcon());
|
||||
"Changelist associated with '" + task.getSummary() + "' is not empty.\n" +
|
||||
"Do you want to remove it and move the changes to the active changelist?",
|
||||
"Changelist Not Empty", Messages.getWarningIcon());
|
||||
switch (result) {
|
||||
case 0:
|
||||
break l;
|
||||
@@ -257,5 +261,4 @@ public class SwitchTaskAction extends BaseTaskAction {
|
||||
manager.removeTask(task);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.intellij.tasks.mantis.model.*;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.text.VersionComparatorUtil;
|
||||
import com.intellij.util.xmlb.annotations.Tag;
|
||||
import org.apache.axis.utils.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -22,6 +23,7 @@ import javax.xml.rpc.ServiceException;
|
||||
import java.math.BigInteger;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -141,7 +143,8 @@ public class MantisRepository extends BaseRepositoryImpl {
|
||||
if (id == null) return null;
|
||||
String summary = data.getSummary();
|
||||
if (summary == null) return null;
|
||||
return new MantisTask(id, summary, myProject, this, data.getLast_updated().getTime()) {
|
||||
final boolean closed = data.getStatus().getId().intValue() >= 90;
|
||||
return new MantisTask(id, summary, myProject, this, data.getLast_updated().getTime(), closed) {
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return data.getDescription();
|
||||
@@ -190,7 +193,8 @@ public class MantisRepository extends BaseRepositoryImpl {
|
||||
if (id == null) return null;
|
||||
String summary = data.getSummary();
|
||||
if (summary == null) return null;
|
||||
return new MantisTask(id, summary, myProject, this, data.getLast_updated().getTime());
|
||||
final boolean closed = data.getStatus().intValue() >= 90;
|
||||
return new MantisTask(id, summary, myProject, this, data.getLast_updated().getTime(), closed);
|
||||
}
|
||||
|
||||
public List<MantisProject> getProjects() throws Exception {
|
||||
@@ -217,14 +221,13 @@ public class MantisRepository extends BaseRepositoryImpl {
|
||||
return new MantisProject(data.getId().intValue(), data.getName());
|
||||
}
|
||||
});
|
||||
projects.add(0, MantisProject.ALL_PROJECTS);
|
||||
String version = soap.mc_version();
|
||||
if (allProjectsAvailable(soap)){
|
||||
projects.add(0, MantisProject.ALL_PROJECTS);
|
||||
}
|
||||
for (MantisProject project : projects) {
|
||||
FilterData[] filterDatas = soap.mc_filter_get(getUsername(), getPassword(), BigInteger.valueOf(project.getId()));
|
||||
List<MantisFilter> filters = new ArrayList<MantisFilter>();
|
||||
if (!MantisProject.ALL_PROJECTS.equals(project) || !version.startsWith("1.1")) {
|
||||
filters.add(MantisFilter.LAST_TASKS);
|
||||
}
|
||||
filters.add(MantisFilter.LAST_TASKS);
|
||||
filters.addAll(ContainerUtil.map(filterDatas, new Function<FilterData, MantisFilter>() {
|
||||
@Override
|
||||
public MantisFilter fun(final FilterData data) {
|
||||
@@ -238,6 +241,11 @@ public class MantisRepository extends BaseRepositoryImpl {
|
||||
|
||||
}
|
||||
|
||||
private static boolean allProjectsAvailable(final MantisConnectPortType soap) throws RemoteException {
|
||||
String version = soap.mc_version();
|
||||
return VersionComparatorUtil.compare(version, "1.2.9") >= 0;
|
||||
}
|
||||
|
||||
private synchronized MantisConnectPortType createSoap() throws ServiceException, MalformedURLException {
|
||||
return new MantisConnectLocator().getMantisConnectPort(new URL(getUrl() + SOAP_API_LOCATION));
|
||||
}
|
||||
|
||||
@@ -14,14 +14,21 @@ import java.util.Date;
|
||||
public class MantisTask extends Task {
|
||||
private final String myId;
|
||||
private final String mySummary;
|
||||
private final Date myTime;
|
||||
private final Date myUpdated;
|
||||
private final boolean myClosed;
|
||||
private String myProjectName;
|
||||
private MantisRepository myRepository;
|
||||
|
||||
public MantisTask(final String id, final String summary, MantisProject project, MantisRepository repository, final Date time) {
|
||||
public MantisTask(final String id,
|
||||
final String summary,
|
||||
MantisProject project,
|
||||
MantisRepository repository,
|
||||
final Date updated,
|
||||
final boolean closed) {
|
||||
myId = id;
|
||||
mySummary = summary;
|
||||
myTime = time;
|
||||
myUpdated = updated;
|
||||
myClosed = closed;
|
||||
myProjectName = !MantisProject.ALL_PROJECTS.equals(project) ? project.getName() : null;
|
||||
myRepository = repository;
|
||||
}
|
||||
@@ -65,7 +72,7 @@ public class MantisTask extends Task {
|
||||
@Nullable
|
||||
@Override
|
||||
public Date getUpdated() {
|
||||
return myTime;
|
||||
return myUpdated;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -76,7 +83,7 @@ public class MantisTask extends Task {
|
||||
|
||||
@Override
|
||||
public boolean isClosed() {
|
||||
return false;
|
||||
return myClosed;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="IDEA jdk" jdkType="JavaSDK" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="tasks-api" />
|
||||
<orderEntry type="module" module-name="tasks-core" />
|
||||
|
||||
-2
@@ -132,7 +132,6 @@ public class FormsBindingManager extends FormsBuilder {
|
||||
addBinding(boundSource, form, srcToForms);
|
||||
FSOperations.markDirty(context, boundSource);
|
||||
filesToCompile.put(boundSource, target);
|
||||
context.getScope().expandScope(target, boundSource);
|
||||
exitCode = ExitCode.OK;
|
||||
}
|
||||
}
|
||||
@@ -150,7 +149,6 @@ public class FormsBindingManager extends FormsBuilder {
|
||||
addBinding(srcFile, formFile, srcToForms);
|
||||
FSOperations.markDirty(context, formFile);
|
||||
formsToCompile.put(formFile, target);
|
||||
context.getScope().expandScope(target, formFile);
|
||||
exitCode = ExitCode.OK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,6 +228,7 @@ public final class InplaceEditingLayer extends JComponent{
|
||||
}
|
||||
|
||||
private void adjustEditorComponentSize(){
|
||||
if (myInplaceEditorComponent == null) return;
|
||||
final Dimension preferredSize = myInplaceEditorComponent.getPreferredSize();
|
||||
int width = Math.max(preferredSize.width, myPreferredBounds.width);
|
||||
// Editor component should not be extended to invisible area
|
||||
|
||||
@@ -353,6 +353,10 @@ public class XPath2Parser extends XPathParser {
|
||||
builder.advanceLexer();
|
||||
}
|
||||
mark.done(XPath2ElementTypes.SINGLE_TYPE);
|
||||
|
||||
if (builder.getTokenType() == XPathTokenTypes.STAR) {
|
||||
builder.remapCurrentToken(XPathTokenTypes.MULT);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean parseSequenceType(PsiBuilder builder) {
|
||||
@@ -369,6 +373,9 @@ public class XPath2Parser extends XPathParser {
|
||||
mark.done(XPath2ElementTypes.SEQUENCE_TYPE);
|
||||
return true;
|
||||
} else if (parseNodeType(builder) || parseQName(builder)) {
|
||||
if (builder.getTokenType() == XPathTokenTypes.MULT) {
|
||||
builder.remapCurrentToken(XPathTokenTypes.STAR);
|
||||
}
|
||||
if (XPath2TokenTypes.OCCURRENCE_OPS.contains(builder.getTokenType())) {
|
||||
makeToken(builder);
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ public class XPathParser implements PsiParser {
|
||||
if (builder.getTokenType() == XPathTokenTypes.MINUS) {
|
||||
final PsiBuilder.Marker expr = builder.mark();
|
||||
builder.advanceLexer();
|
||||
if (!parsePathExpression(builder)) {
|
||||
if (!parseUnionExpression(builder)) {
|
||||
builder.error("Expression expected");
|
||||
}
|
||||
expr.done(XPathElementTypes.PREFIX_EXPRESSION);
|
||||
|
||||
+5
-12
@@ -18,17 +18,15 @@ package org.intellij.lang.xpath.xslt.associations.impl;
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.IconUtil;
|
||||
import org.intellij.lang.xpath.xslt.associations.FileAssociationsManager;
|
||||
|
||||
class AddAssociationAction extends AnAction {
|
||||
private final FileAssociationsManager myManager;
|
||||
private final FileAssociationsManager myManager;
|
||||
|
||||
public AddAssociationAction(FileAssociationsManager manager) {
|
||||
super("Add...", "Add File Association", IconUtil.getAddIcon());
|
||||
@@ -38,16 +36,12 @@ class AddAssociationAction extends AnAction {
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final PsiFile psiFile = AssociationsGroup.getPsiFile(e);
|
||||
if (psiFile == null) return;
|
||||
final Project project = LangDataKeys.PROJECT.getData(e.getDataContext());
|
||||
if (project == null) return;
|
||||
|
||||
addAssociation(e, psiFile);
|
||||
DaemonCodeAnalyzer.getInstance(project).restart();
|
||||
addAssociation(psiFile);
|
||||
DaemonCodeAnalyzer.getInstance(psiFile.getProject()).restart(psiFile);
|
||||
}
|
||||
|
||||
protected void addAssociation(AnActionEvent e, PsiFile psiFile) {
|
||||
final Project project = AssociationsGroup.getEventProject(e);
|
||||
if (project == null) return;
|
||||
protected void addAssociation(final PsiFile psiFile) {
|
||||
|
||||
final VirtualFile virtualFile = psiFile.getVirtualFile();
|
||||
assert virtualFile != null;
|
||||
@@ -58,7 +52,7 @@ class AddAssociationAction extends AnAction {
|
||||
}
|
||||
};
|
||||
|
||||
final VirtualFile[] virtualFiles = FileChooser.chooseFiles(descriptor, project, psiFile.getVirtualFile());
|
||||
final VirtualFile[] virtualFiles = FileChooser.chooseFiles(descriptor, psiFile.getProject(), psiFile.getVirtualFile());
|
||||
if (virtualFiles.length == 0) return; // cancel
|
||||
|
||||
for (VirtualFile file : virtualFiles) {
|
||||
@@ -66,5 +60,4 @@ class AddAssociationAction extends AnAction {
|
||||
myManager.addAssociation(psiFile, file);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -213,7 +213,7 @@ class AssociationsEditor {
|
||||
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final PsiFile selection = (PsiFile)getTreeSelection(myTree);
|
||||
addAssociation(e, selection);
|
||||
addAssociation(selection);
|
||||
myListModel.update(selection);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@ package org.intellij.lang.xpath.xslt.associations.impl;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
|
||||
@@ -27,7 +28,7 @@ class ConfigureAssociationsAction extends AnAction {
|
||||
}
|
||||
|
||||
public void actionPerformed(final AnActionEvent e) {
|
||||
final Project project = LangDataKeys.PROJECT.getData(e.getDataContext());
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
|
||||
if (project == null) return;
|
||||
|
||||
final PsiFile file = LangDataKeys.PSI_FILE.getData(e.getDataContext());
|
||||
|
||||
+11
-2
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.intellij.lang.xpath.xslt.associations.impl;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import org.intellij.lang.xpath.xslt.associations.FileAssociationsManager;
|
||||
|
||||
@@ -40,6 +41,8 @@ import org.jdom.Element;
|
||||
import java.util.*;
|
||||
|
||||
class FileAssociationsManagerImpl extends FileAssociationsManager implements ProjectComponent, JDOMExternalizable, ModificationTracker {
|
||||
private static final Logger LOG = Logger.getInstance(FileAssociationsManagerImpl.class);
|
||||
|
||||
private final Project myProject;
|
||||
private final VirtualFilePointerManager myFilePointerManager;
|
||||
private final Map<VirtualFilePointer, VirtualFilePointerContainer> myAssociations;
|
||||
@@ -178,13 +181,19 @@ class FileAssociationsManagerImpl extends FileAssociationsManager implements Pro
|
||||
|
||||
public void addAssociation(PsiFile file, PsiFile assoc) {
|
||||
final VirtualFile virtualFile = assoc.getVirtualFile();
|
||||
if (virtualFile == null) return;
|
||||
if (virtualFile == null) {
|
||||
LOG.warn("No VirtualFile for " + file.getName());
|
||||
return;
|
||||
}
|
||||
addAssociation(file, virtualFile);
|
||||
}
|
||||
|
||||
public void addAssociation(PsiFile file, VirtualFile assoc) {
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (virtualFile == null) return;
|
||||
if (virtualFile == null) {
|
||||
LOG.warn("No VirtualFile for " + file.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
for (VirtualFilePointer pointer : myAssociations.keySet()) {
|
||||
if (pointer.getUrl().equals(virtualFile.getUrl())) {
|
||||
|
||||
+2
-1
@@ -16,6 +16,7 @@
|
||||
package org.intellij.lang.xpath.xslt.associations.impl;
|
||||
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -69,6 +70,6 @@ class ToggleAssociationAction extends ToggleAction {
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
assert !state;
|
||||
myFileAssociationsManager.removeAssociation(myPsiFile, myAssoc);
|
||||
DaemonCodeAnalyzer.getInstance(AssociationsGroup.getEventProject(e)).restart();
|
||||
DaemonCodeAnalyzer.getInstance(AnAction.getEventProject(e)).restart();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +97,21 @@ public class XPath2ParsingTest extends TestBase {
|
||||
doXPathHighlighting();
|
||||
}
|
||||
|
||||
// IDEA-70681
|
||||
public void testCastWithMultiplication() throws Throwable {
|
||||
doXPathHighlighting();
|
||||
}
|
||||
|
||||
// IDEA-70688
|
||||
public void testKindTestWithStar() throws Throwable {
|
||||
doXPathHighlighting();
|
||||
}
|
||||
|
||||
public void testUnionSubExpression() throws Throwable {
|
||||
doXPathHighlighting();
|
||||
}
|
||||
|
||||
// IDEA-67413
|
||||
private void doXPathHighlighting() throws Throwable {
|
||||
final String name = getTestFileName();
|
||||
myFixture.testHighlighting(false, false, false, name + ".xpath2");
|
||||
|
||||
@@ -85,6 +85,11 @@ public class XPathHighlightingTest extends TestBase {
|
||||
doXPathHighlighting();
|
||||
}
|
||||
|
||||
// IDEA-67413
|
||||
public void testUnionSubExpression() throws Throwable {
|
||||
doXPathHighlighting();
|
||||
}
|
||||
|
||||
private void doXPathHighlighting(String... moreFiles) throws Throwable {
|
||||
final String name = getTestFileName();
|
||||
myFixture.testHighlighting(true, false, false, ArrayUtil.append(moreFiles, name + ".xpath"));
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
-<warning descr="Expression should be of type 'number'">.|.</warning>
|
||||
@@ -0,0 +1 @@
|
||||
4 cast as xs:integer * 5
|
||||
@@ -0,0 +1 @@
|
||||
. treat as document-node()*
|
||||
@@ -0,0 +1 @@
|
||||
-.|.
|
||||
@@ -30,6 +30,7 @@ import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.Queue;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class RenameXmlAttributeProcessor extends RenamePsiElementProcessor {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.rename.RenameXmlAttributeProcessor");
|
||||
@@ -41,7 +42,7 @@ public class RenameXmlAttributeProcessor extends RenamePsiElementProcessor {
|
||||
public void renameElement(final PsiElement element,
|
||||
final String newName,
|
||||
final UsageInfo[] usages,
|
||||
final RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
@Nullable RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
if (element instanceof XmlAttribute) {
|
||||
doRenameXmlAttribute((XmlAttribute)element, newName, listener);
|
||||
}
|
||||
@@ -52,10 +53,12 @@ public class RenameXmlAttributeProcessor extends RenamePsiElementProcessor {
|
||||
|
||||
private static void doRenameXmlAttribute(XmlAttribute attribute,
|
||||
String newName,
|
||||
RefactoringElementListener listener) {
|
||||
@Nullable RefactoringElementListener listener) {
|
||||
try {
|
||||
final PsiElement element = attribute.setName(newName);
|
||||
listener.elementRenamed(element);
|
||||
if (listener != null) {
|
||||
listener.elementRenamed(element);
|
||||
}
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
@@ -65,7 +68,7 @@ public class RenameXmlAttributeProcessor extends RenamePsiElementProcessor {
|
||||
private static void doRenameXmlAttributeValue(@NotNull XmlAttributeValue value,
|
||||
String newName,
|
||||
UsageInfo[] infos,
|
||||
RefactoringElementListener listener)
|
||||
@Nullable RefactoringElementListener listener)
|
||||
throws IncorrectOperationException {
|
||||
LOG.assertTrue(value.isValid());
|
||||
|
||||
@@ -75,7 +78,9 @@ public class RenameXmlAttributeProcessor extends RenamePsiElementProcessor {
|
||||
LOG.assertTrue(psiManager != null);
|
||||
XmlFile file = (XmlFile)PsiFileFactory.getInstance(psiManager.getProject()).createFileFromText("dummy.xml", "<a attr=\"" + newName + "\"/>");
|
||||
final PsiElement element = value.replace(file.getDocument().getRootTag().getAttributes()[0].getValueElement());
|
||||
listener.elementRenamed(element);
|
||||
if (listener != null) {
|
||||
listener.elementRenamed(element);
|
||||
}
|
||||
}
|
||||
|
||||
private static void renameAll(PsiElement originalElement, UsageInfo[] infos, String newName,
|
||||
|
||||
Reference in New Issue
Block a user