mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
@@ -2,6 +2,7 @@ package com.intellij.openapi.util;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@@ -125,7 +126,7 @@ public abstract class AsyncValueLoader<T> {
|
||||
|
||||
protected abstract void load(@NotNull AsyncResult<T> result) throws IOException;
|
||||
|
||||
protected boolean isUpToDate(@NotNull T result) {
|
||||
protected boolean isUpToDate(@Nullable T result) {
|
||||
return loadedModificationCount == modificationCount;
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ public final class VariableView extends XNamedValue implements VariableContext {
|
||||
if (!node.isObsolete()) {
|
||||
value = getViewSupport().transformErrorOnGetUsedReferenceValue(value, error);
|
||||
if (value == null) {
|
||||
node.setPresentation(getIcon(), null, error, false);
|
||||
node.setPresentation(AllIcons.Debugger.Db_primitive, null, error, false);
|
||||
}
|
||||
else {
|
||||
VariableView.this.value = value;
|
||||
|
||||
+4
-3
@@ -1,5 +1,6 @@
|
||||
package com.intellij.structuralsearch;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.structuralsearch.plugin.replace.ReplaceOptions;
|
||||
import com.intellij.structuralsearch.plugin.replace.ReplacementInfo;
|
||||
|
||||
@@ -9,7 +10,7 @@ import com.intellij.structuralsearch.plugin.replace.ReplacementInfo;
|
||||
public abstract class StructuralReplaceHandler {
|
||||
public abstract void replace(final ReplacementInfo info, ReplaceOptions options);
|
||||
|
||||
public void prepare
|
||||
(ReplacementInfo info) {
|
||||
}
|
||||
public void prepare(ReplacementInfo info) {}
|
||||
|
||||
public void postprocess(PsiElement affectedElement, ReplaceOptions options) {}
|
||||
}
|
||||
|
||||
+10
-8
@@ -158,12 +158,12 @@ public class Replacer {
|
||||
currentAffectedElement = doReplace(aResultPtrList);
|
||||
|
||||
if (currentAffectedElement != lastAffectedElement) {
|
||||
if (lastAffectedElement != null) reformatAndShortenRefs(lastAffectedElement);
|
||||
if (lastAffectedElement != null) reformatAndPostProcess(lastAffectedElement);
|
||||
lastAffectedElement = currentAffectedElement;
|
||||
}
|
||||
}
|
||||
|
||||
reformatAndShortenRefs(lastAffectedElement);
|
||||
reformatAndPostProcess(lastAffectedElement);
|
||||
}
|
||||
|
||||
public void replace(ReplacementInfo info) {
|
||||
@@ -173,7 +173,7 @@ public class Replacer {
|
||||
if (replaceHandler != null) {
|
||||
replaceHandler.prepare(info);
|
||||
}
|
||||
reformatAndShortenRefs(doReplace(info));
|
||||
reformatAndPostProcess(doReplace(info));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -211,11 +211,10 @@ public class Replacer {
|
||||
return elementParent;
|
||||
}
|
||||
|
||||
private void reformatAndShortenRefs(final PsiElement elementParent) {
|
||||
private void reformatAndPostProcess(final PsiElement elementParent) {
|
||||
if (elementParent == null) return;
|
||||
final Runnable action = new Runnable() {
|
||||
public void run() {
|
||||
CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(PsiManager.getInstance(project).getProject());
|
||||
final PsiFile containingFile = elementParent.getContainingFile();
|
||||
|
||||
if (containingFile != null && options.isToReformatAccordingToStyle()) {
|
||||
@@ -224,9 +223,12 @@ public class Replacer {
|
||||
.commitDocument(FileDocumentManager.getInstance().getDocument(containingFile.getVirtualFile()));
|
||||
}
|
||||
|
||||
final int parentOffset = elementParent.getTextRange().getStartOffset();
|
||||
|
||||
codeStyleManager.reformatRange(containingFile, parentOffset, parentOffset + elementParent.getTextLength(), true);
|
||||
final int parentOffset = elementParent.getTextOffset();
|
||||
CodeStyleManager.getInstance(project)
|
||||
.reformatRange(containingFile, parentOffset, parentOffset + elementParent.getTextLength(), true);
|
||||
}
|
||||
if (replaceHandler != null) {
|
||||
replaceHandler.postprocess(elementParent, options);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
-17
@@ -33,23 +33,6 @@ public class ReplaceDialog extends SearchDialog {
|
||||
return SSRBundle.message("structural.replace.title");
|
||||
}
|
||||
|
||||
protected boolean isChanged(Configuration configuration) {
|
||||
if (super.isChanged(configuration)) return true;
|
||||
|
||||
String replacement;
|
||||
|
||||
if (configuration instanceof ReplaceConfiguration) {
|
||||
replacement = ((ReplaceConfiguration)configuration).getOptions().getReplacement();
|
||||
}
|
||||
else {
|
||||
replacement = configuration.getMatchOptions().getSearchPattern();
|
||||
}
|
||||
|
||||
if (replacement == null) return false;
|
||||
|
||||
return !replaceCriteriaEdit.getDocument().getText().equals(replacement);
|
||||
}
|
||||
|
||||
protected JComponent createEditorContent() {
|
||||
JPanel result = new JPanel(new BorderLayout());
|
||||
Splitter p;
|
||||
|
||||
+65
-68
@@ -14,7 +14,6 @@ import com.intellij.psi.PsiNameIdentifierOwner;
|
||||
import com.intellij.structuralsearch.*;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchResultImpl;
|
||||
import com.intellij.structuralsearch.plugin.StructuralSearchPlugin;
|
||||
import com.intellij.structuralsearch.plugin.ui.actions.DoSearchAction;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usages.Usage;
|
||||
import com.intellij.usages.UsageInfo2UsageAdapter;
|
||||
@@ -42,74 +41,72 @@ public class SearchCommand {
|
||||
public void findUsages(final Processor<Usage> processor) {
|
||||
final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
|
||||
|
||||
final MatchResultSink sink = new MatchResultSink() {
|
||||
int count;
|
||||
|
||||
public void setMatchingProcess(MatchingProcess _process) {
|
||||
process = _process;
|
||||
findStarted();
|
||||
}
|
||||
|
||||
public void processFile(PsiFile element) {
|
||||
final VirtualFile virtualFile = element.getVirtualFile();
|
||||
if (virtualFile != null)
|
||||
progress.setText(SSRBundle.message("looking.in.progress.message", virtualFile.getPresentableName()));
|
||||
}
|
||||
|
||||
public void matchingFinished() {
|
||||
findEnded();
|
||||
progress.setText(SSRBundle.message("found.progress.message", count));
|
||||
}
|
||||
|
||||
public ProgressIndicator getProgressIndicator() {
|
||||
return progress;
|
||||
}
|
||||
|
||||
public void newMatch(MatchResult result) {
|
||||
UsageInfo info;
|
||||
|
||||
if (MatchResult.MULTI_LINE_MATCH.equals(result.getName())) {
|
||||
int start = -1;
|
||||
int end = -1;
|
||||
PsiElement parent = result.getMatchRef().getElement().getParent();
|
||||
|
||||
for (final MatchResult matchResult : ((MatchResultImpl)result).getMatches()) {
|
||||
PsiElement el = matchResult.getMatchRef().getElement();
|
||||
final int elementStart = el.getTextRange().getStartOffset();
|
||||
|
||||
if (start == -1 || start > elementStart) {
|
||||
start = elementStart;
|
||||
}
|
||||
final int newend = elementStart + el.getTextLength();
|
||||
|
||||
if (newend > end) {
|
||||
end = newend;
|
||||
}
|
||||
}
|
||||
|
||||
final int parentStart = parent.getTextRange().getStartOffset();
|
||||
int startOffset = start - parentStart;
|
||||
info = new UsageInfo(parent, startOffset, end - parentStart);
|
||||
}
|
||||
else {
|
||||
PsiElement element = result.getMatch();
|
||||
if (element instanceof PsiNameIdentifierOwner) {
|
||||
element = ObjectUtils.notNull(((PsiNameIdentifierOwner)element).getNameIdentifier(), element);
|
||||
}
|
||||
info = new UsageInfo(element, result.getStart(), result.getEnd() == -1 ? element.getTextLength() : result.getEnd());
|
||||
}
|
||||
|
||||
Usage usage = new UsageInfo2UsageAdapter(info);
|
||||
processor.process(usage);
|
||||
foundUsage(result, usage);
|
||||
++count;
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
DoSearchAction.execute(
|
||||
project,
|
||||
new MatchResultSink() {
|
||||
int count;
|
||||
|
||||
public void setMatchingProcess(MatchingProcess _process) {
|
||||
process = _process;
|
||||
findStarted();
|
||||
}
|
||||
|
||||
public void processFile(PsiFile element) {
|
||||
final VirtualFile virtualFile = element.getVirtualFile();
|
||||
if (virtualFile != null)
|
||||
progress.setText(SSRBundle.message("looking.in.progress.message", virtualFile.getPresentableName()));
|
||||
}
|
||||
|
||||
public void matchingFinished() {
|
||||
findEnded();
|
||||
progress.setText(SSRBundle.message("found.progress.message", count));
|
||||
}
|
||||
|
||||
public ProgressIndicator getProgressIndicator() {
|
||||
return progress;
|
||||
}
|
||||
|
||||
public void newMatch(MatchResult result) {
|
||||
UsageInfo info;
|
||||
|
||||
if (MatchResult.MULTI_LINE_MATCH.equals(result.getName())) {
|
||||
int start = -1;
|
||||
int end = -1;
|
||||
PsiElement parent = result.getMatchRef().getElement().getParent();
|
||||
|
||||
for (final MatchResult matchResult : ((MatchResultImpl)result).getMatches()) {
|
||||
PsiElement el = matchResult.getMatchRef().getElement();
|
||||
final int elementStart = el.getTextRange().getStartOffset();
|
||||
|
||||
if (start == -1 || start > elementStart) {
|
||||
start = elementStart;
|
||||
}
|
||||
final int newend = elementStart + el.getTextLength();
|
||||
|
||||
if (newend > end) {
|
||||
end = newend;
|
||||
}
|
||||
}
|
||||
|
||||
final int parentStart = parent.getTextRange().getStartOffset();
|
||||
int startOffset = start - parentStart;
|
||||
info = new UsageInfo(parent, startOffset, end - parentStart);
|
||||
}
|
||||
else {
|
||||
PsiElement element = result.getMatch();
|
||||
if (element instanceof PsiNameIdentifierOwner) {
|
||||
element = ObjectUtils.notNull(((PsiNameIdentifierOwner)element).getNameIdentifier(), element);
|
||||
}
|
||||
info = new UsageInfo(element, result.getStart(), result.getEnd() == -1 ? element.getTextLength() : result.getEnd());
|
||||
}
|
||||
|
||||
Usage usage = new UsageInfo2UsageAdapter(info);
|
||||
processor.process(usage);
|
||||
foundUsage(result, usage);
|
||||
++count;
|
||||
}
|
||||
},
|
||||
context.getConfiguration()
|
||||
);
|
||||
new Matcher(project).findMatches(sink, context.getConfiguration().getMatchOptions());
|
||||
}
|
||||
catch (final StructuralSearchException e) {
|
||||
final Alarm alarm = new Alarm();
|
||||
|
||||
-5
@@ -135,11 +135,6 @@ public class SearchDialog extends DialogWrapper implements ConfigurationCreator
|
||||
this.useLastConfiguration = useLastConfiguration;
|
||||
}
|
||||
|
||||
protected boolean isChanged(Configuration configuration) {
|
||||
return configuration.getMatchOptions().getSearchPattern() != null &&
|
||||
!searchCriteriaEdit.getDocument().getText().equals(configuration.getMatchOptions().getSearchPattern());
|
||||
}
|
||||
|
||||
public void setSearchPattern(final Configuration config) {
|
||||
model.setShadowConfig(config);
|
||||
setValuesFromConfig(config);
|
||||
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
package com.intellij.structuralsearch.plugin.ui.actions;
|
||||
|
||||
import com.intellij.structuralsearch.plugin.ui.Configuration;
|
||||
import com.intellij.structuralsearch.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
/**
|
||||
* Does the search action
|
||||
*/
|
||||
public class DoSearchAction {
|
||||
public static void execute(final Project project, MatchResultSink sink,
|
||||
final Configuration configuration) {
|
||||
final MatchOptions options = configuration.getMatchOptions();
|
||||
|
||||
final Matcher matcher = new Matcher(project);
|
||||
try {
|
||||
matcher.findMatches(sink, options);
|
||||
}
|
||||
finally {
|
||||
sink.matchingFinished();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+7
-3
@@ -449,9 +449,13 @@ public class JavaReplaceHandler extends StructuralReplaceHandler {
|
||||
element.getParent().deleteChildRange(firstToDelete, lastToDelete);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.isToShortenFQN() && elementParent.isValid()) {
|
||||
JavaCodeStyleManager.getInstance(project).shortenClassReferences(elementParent, 0, elementParent.getTextLength());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postprocess(PsiElement affectedElement, ReplaceOptions options) {
|
||||
if (options.isToShortenFQN() && affectedElement.isValid()) {
|
||||
final JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(affectedElement.getProject());
|
||||
codeStyleManager.shortenClassReferences(affectedElement, 0, affectedElement.getTextLength());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,8 +84,14 @@ public class XMLColorsPage implements ColorSettingsPage {
|
||||
" <indexitem text=\"rename\" target=\"refactoring.rename\"/>\n" +
|
||||
" <indexitem text=\"move\" target=\"refactoring.move\"/>\n" +
|
||||
" <indexitem text=\"migrate\" target=\"refactoring.migrate\"/>\n" +
|
||||
" <indexitem text=\"usage search\" target=\"find.findUsages\"/>\n& ·" +
|
||||
" <indexitem text=\"project\" target=\"project.management\"/>" +
|
||||
" <indexitem text=\"usage search\" target=\"find.findUsages\"/>\n" +
|
||||
" <someTextWithEntityRefs>& ·</someTextWithEntityRefs>\n" +
|
||||
" <withCData><![CDATA[\n" +
|
||||
" <object class=\"MyClass\" key=\"constant\">\n" +
|
||||
" </object>\n" +
|
||||
" ]]>\n" +
|
||||
" </withCData>\n" +
|
||||
" <indexitem text=\"project\" target=\"project.management\"/>\n" +
|
||||
" <<bg><np>pf</np></bg>:foo <bg><np>pf</np></bg>:bar=\"bar\"/>\n" +
|
||||
"</index>";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user