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:
+4
@@ -91,6 +91,10 @@ public class PostfixTemplatesConfigurable implements SearchableConfigurable, Edi
|
||||
for (LanguageExtensionPoint extension : extensions) {
|
||||
List<PostfixTemplate> postfixTemplates =
|
||||
ContainerUtil.newArrayList(((PostfixTemplateProvider)extension.getInstance()).getTemplates());
|
||||
if (postfixTemplates.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ContainerUtil.sort(postfixTemplates, TEMPLATE_COMPARATOR);
|
||||
|
||||
templateMultiMap.putValues(extension.getKey(), postfixTemplates);
|
||||
|
||||
@@ -110,7 +110,9 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C
|
||||
|
||||
private void fillConfigurablesNames(Configurable[] configurables) {
|
||||
for (Configurable configurable : configurables) {
|
||||
myConfigurablesNames.put(((SearchableConfigurable)configurable).getId(), configurable.getDisplayName());
|
||||
if (configurable instanceof SearchableConfigurable) {
|
||||
myConfigurablesNames.put(((SearchableConfigurable)configurable).getId(), configurable.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-19
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2011 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2014 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -48,18 +48,7 @@ class CollectionQueryCalledVisitor extends JavaRecursiveElementVisitor {
|
||||
}
|
||||
super.visitForeachStatement(statement);
|
||||
final PsiExpression qualifier = statement.getIteratedValue();
|
||||
if (!(qualifier instanceof PsiReferenceExpression)) {
|
||||
return;
|
||||
}
|
||||
final PsiReference referenceExpression = (PsiReference)qualifier;
|
||||
final PsiElement referent = referenceExpression.resolve();
|
||||
if (referent == null) {
|
||||
return;
|
||||
}
|
||||
if (!referent.equals(variable)) {
|
||||
return;
|
||||
}
|
||||
queried = true;
|
||||
checkExpression(qualifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -93,7 +82,7 @@ class CollectionQueryCalledVisitor extends JavaRecursiveElementVisitor {
|
||||
}
|
||||
final PsiExpression qualifier =
|
||||
methodExpression.getQualifierExpression();
|
||||
checkQualifier(qualifier);
|
||||
checkExpression(qualifier);
|
||||
}
|
||||
|
||||
|
||||
@@ -104,10 +93,10 @@ class CollectionQueryCalledVisitor extends JavaRecursiveElementVisitor {
|
||||
if (methodName == null) {
|
||||
return;
|
||||
}
|
||||
checkQualifier(expression.getQualifierExpression());
|
||||
checkExpression(expression.getQualifierExpression());
|
||||
}
|
||||
|
||||
private void checkQualifier(PsiExpression expression) {
|
||||
private void checkExpression(PsiExpression expression) {
|
||||
if (queried) {
|
||||
return;
|
||||
}
|
||||
@@ -125,17 +114,17 @@ class CollectionQueryCalledVisitor extends JavaRecursiveElementVisitor {
|
||||
else if (expression instanceof PsiParenthesizedExpression) {
|
||||
final PsiParenthesizedExpression parenthesizedExpression =
|
||||
(PsiParenthesizedExpression)expression;
|
||||
checkQualifier(parenthesizedExpression.getExpression());
|
||||
checkExpression(parenthesizedExpression.getExpression());
|
||||
}
|
||||
else if (expression instanceof PsiConditionalExpression) {
|
||||
final PsiConditionalExpression conditionalExpression =
|
||||
(PsiConditionalExpression)expression;
|
||||
final PsiExpression thenExpression =
|
||||
conditionalExpression.getThenExpression();
|
||||
checkQualifier(thenExpression);
|
||||
checkExpression(thenExpression);
|
||||
final PsiExpression elseExpression =
|
||||
conditionalExpression.getElseExpression();
|
||||
checkQualifier(elseExpression);
|
||||
checkExpression(elseExpression);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
@@ -207,4 +207,14 @@ class MethReference<E> {
|
||||
map.put(1, true);
|
||||
I<Integer> mapper = map::get;
|
||||
}
|
||||
|
||||
void foo(int a,Collection b) {
|
||||
final ArrayList x = new ArrayList();
|
||||
x.add("1");
|
||||
|
||||
for (Object o : a>0? b : x)
|
||||
{
|
||||
System.out.println(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.zmlx.hg4idea.HgRevisionNumber;
|
||||
import org.zmlx.hg4idea.execution.HgCommandExecutor;
|
||||
import org.zmlx.hg4idea.execution.HgCommandResult;
|
||||
import org.zmlx.hg4idea.execution.HgRemoteCommandExecutor;
|
||||
import org.zmlx.hg4idea.util.HgChangesetUtil;
|
||||
import org.zmlx.hg4idea.util.HgUtil;
|
||||
|
||||
@@ -137,7 +136,7 @@ public class HgWorkingCopyRevisionsCommand {
|
||||
*/
|
||||
@NotNull
|
||||
public Couple<HgRevisionNumber> identify(@NotNull VirtualFile repo) {
|
||||
HgRemoteCommandExecutor commandExecutor = new HgRemoteCommandExecutor(myProject);
|
||||
HgCommandExecutor commandExecutor = new HgCommandExecutor(myProject);
|
||||
commandExecutor.setSilent(true);
|
||||
HgCommandResult result = commandExecutor.executeInCurrentThread(repo, "identify", Arrays.asList("--num", "--id"));
|
||||
if (result == null) {
|
||||
|
||||
@@ -147,14 +147,15 @@ public class HgCommandExecutor {
|
||||
cmdLine.add(HgEncodingUtil.getNameFor(myCharset));
|
||||
}
|
||||
|
||||
HgCommandResult result;
|
||||
try {
|
||||
String workingDir = repo != null ? repo.getPath() : null;
|
||||
ShellCommand shellCommand = new ShellCommand(cmdLine, workingDir, myCharset);
|
||||
long startTime = System.currentTimeMillis();
|
||||
LOG.debug(String.format("hg %s started", operation));
|
||||
result = shellCommand.execute(myShowOutput);
|
||||
HgCommandResult result = shellCommand.execute(myShowOutput);
|
||||
LOG.debug(String.format("hg %s finished. Took %s ms", operation, System.currentTimeMillis() - startTime));
|
||||
logResult(result);
|
||||
return result;
|
||||
}
|
||||
catch (ShellCommandException e) {
|
||||
if (myVcs.getExecutableValidator().checkExecutableAndNotifyIfNeeded()) {
|
||||
@@ -168,9 +169,6 @@ public class HgCommandExecutor {
|
||||
LOG.info(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
|
||||
logResult(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
// logging to the Version Control console (without extensions and configs)
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.List;
|
||||
|
||||
public final class HgCommandResult {
|
||||
|
||||
public static final HgCommandResult EMPTY = new HgCommandResult(new StringWriter(), new StringWriter(), 0);
|
||||
public static final HgCommandResult CANCELLED = new HgCommandResult(new StringWriter(), new StringWriter(), 1);
|
||||
|
||||
private final StringWriter out;
|
||||
@@ -29,7 +28,6 @@ public final class HgCommandResult {
|
||||
|
||||
private List<String> outLines;
|
||||
private List<String> errLines;
|
||||
private String warnings;
|
||||
|
||||
public HgCommandResult(StringWriter out, StringWriter err, int exitValue) {
|
||||
this.out = out;
|
||||
@@ -54,7 +52,7 @@ public final class HgCommandResult {
|
||||
public String getRawOutput() {
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
|
||||
public String getRawError() {
|
||||
return err.toString();
|
||||
}
|
||||
@@ -62,12 +60,4 @@ public final class HgCommandResult {
|
||||
public int getExitValue() {
|
||||
return exitValue;
|
||||
}
|
||||
|
||||
void setWarnings(String warnings) {
|
||||
this.warnings = warnings;
|
||||
}
|
||||
|
||||
public String getWarnings() {
|
||||
return warnings;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.zmlx.hg4idea.execution;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -27,7 +28,6 @@ import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.Socket;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class HgPromptCommandExecutor extends HgCommandExecutor {
|
||||
@@ -41,61 +41,32 @@ public class HgPromptCommandExecutor extends HgCommandExecutor {
|
||||
public HgCommandResult executeInCurrentThread(@Nullable final VirtualFile repo,
|
||||
@NotNull final String operation,
|
||||
@Nullable final List<String> arguments) {
|
||||
|
||||
final List<String> cmdLine = new LinkedList<String>();
|
||||
WarningReceiver warningReceiver = new WarningReceiver();
|
||||
SocketServer promptServer = new SocketServer(new PromptReceiver(new HgDeleteModifyPromptHandler()));
|
||||
SocketServer warningServer = new SocketServer(warningReceiver);
|
||||
|
||||
|
||||
try {
|
||||
int promptPort = promptServer.start();
|
||||
int warningPort = warningServer.start();
|
||||
cmdLine.add("--config");
|
||||
cmdLine.add("extensions.hg4ideapromptextension=" + myVcs.getPromptHooksExtensionFile().getAbsolutePath());
|
||||
cmdLine.add("--config");
|
||||
cmdLine.add("hg4ideaprompt.port=" + promptPort);
|
||||
cmdLine.add("--config");
|
||||
cmdLine.add("hg4ideawarn.port=" + warningPort);
|
||||
return super.executeInCurrentThread(repo, operation, prepareArguments(arguments, promptPort));
|
||||
}
|
||||
catch (IOException e) {
|
||||
showError(e);
|
||||
LOG.info("IOException during preparing command", e);
|
||||
promptServer.stop();
|
||||
warningServer.stop();
|
||||
return null;
|
||||
}
|
||||
|
||||
if (arguments != null && arguments.size() != 0) {
|
||||
cmdLine.addAll(arguments);
|
||||
finally {
|
||||
promptServer.stop();
|
||||
}
|
||||
|
||||
HgCommandResult result = super.executeInCurrentThread(repo, operation, cmdLine);
|
||||
promptServer.stop();
|
||||
warningServer.stop();
|
||||
String warnings = warningReceiver.getWarnings();
|
||||
result.setWarnings(warnings);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static class WarningReceiver extends SocketServer.Protocol {
|
||||
private StringBuffer warnings = new StringBuffer();
|
||||
private List<String> prepareArguments(List<String> arguments, int port) {
|
||||
List<String> cmdArguments = ContainerUtil.newArrayList();
|
||||
cmdArguments.add("--config");
|
||||
cmdArguments.add("extensions.hg4ideapromptextension=" + myVcs.getPromptHooksExtensionFile().getAbsolutePath());
|
||||
cmdArguments.add("--config");
|
||||
cmdArguments.add("hg4ideaprompt.port=" + port);
|
||||
|
||||
public boolean handleConnection(Socket socket) throws IOException {
|
||||
//noinspection IOResourceOpenedButNotSafelyClosed
|
||||
DataInputStream dataInput = new DataInputStream(socket.getInputStream());
|
||||
|
||||
int numOfWarnings = dataInput.readInt();
|
||||
for (int i = 0; i < numOfWarnings; i++) {
|
||||
warnings.append(new String(readDataBlock(dataInput)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public String getWarnings() {
|
||||
return warnings.toString();
|
||||
if (arguments != null && arguments.size() != 0) {
|
||||
cmdArguments.addAll(arguments);
|
||||
}
|
||||
return cmdArguments;
|
||||
}
|
||||
|
||||
private static class PromptReceiver extends SocketServer.Protocol {
|
||||
@@ -132,7 +103,7 @@ public class HgPromptCommandExecutor extends HgCommandExecutor {
|
||||
choicePresentationArray[i] = choices[i].toString();
|
||||
}
|
||||
index[0] = Messages
|
||||
.showDialog(message, "Hg4idea",
|
||||
.showDialog(message, "Mercurial Prompt Message",
|
||||
choicePresentationArray,
|
||||
defaultChoice.getChosenIndex(), Messages.getQuestionIcon());
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ package org.zmlx.hg4idea.execution;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.zmlx.hg4idea.action.HgCommandResultNotifier;
|
||||
@@ -24,17 +25,12 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class HgRemoteCommandExecutor extends HgCommandExecutor {
|
||||
|
||||
@Nullable private ModalityState myState;
|
||||
|
||||
public HgRemoteCommandExecutor(@NotNull Project project) {
|
||||
this(project, null);
|
||||
}
|
||||
|
||||
public HgRemoteCommandExecutor(@NotNull Project project, @Nullable String destination) {
|
||||
this(project, destination, null);
|
||||
}
|
||||
@@ -65,43 +61,49 @@ public class HgRemoteCommandExecutor extends HgCommandExecutor {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public HgCommandResult executeInCurrentThread(@Nullable final VirtualFile repo,
|
||||
private HgCommandResult executeInCurrentThread(@Nullable final VirtualFile repo,
|
||||
@NotNull final String operation,
|
||||
@Nullable final List<String> arguments,
|
||||
boolean forceAuthorization) {
|
||||
|
||||
final List<String> cmdLine = new LinkedList<String>();
|
||||
PassReceiver passReceiver = new PassReceiver(myProject, forceAuthorization, myState);
|
||||
SocketServer passServer = new SocketServer(passReceiver);
|
||||
|
||||
try {
|
||||
int passPort = passServer.start();
|
||||
cmdLine.add("--config");
|
||||
cmdLine.add("extensions.hg4ideapromptextension=" + myVcs.getPromptHooksExtensionFile().getAbsolutePath());
|
||||
|
||||
cmdLine.add("--config");
|
||||
cmdLine.add("hg4ideapass.port=" + passPort);
|
||||
HgCommandResult result = super.executeInCurrentThread(repo, operation, prepareArguments(arguments, passPort));
|
||||
if (!HgErrorUtil.isAuthorizationError(result)) {
|
||||
passReceiver.saveCredentials();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (IOException e) {
|
||||
showError(e);
|
||||
LOG.info("IOException during preparing command", e);
|
||||
passServer.stop();
|
||||
return null;
|
||||
}
|
||||
if (arguments != null && arguments.size() != 0) {
|
||||
cmdLine.addAll(arguments);
|
||||
finally {
|
||||
passServer.stop();
|
||||
}
|
||||
|
||||
HgCommandResult result;
|
||||
|
||||
result = super.executeInCurrentThread(repo, operation, cmdLine);
|
||||
if (!HgErrorUtil.isAuthorizationError(result)) {
|
||||
passReceiver.saveCredentials();
|
||||
}
|
||||
passServer.stop();
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<String> prepareArguments(List<String> arguments, int port) {
|
||||
List<String> cmdArguments = ContainerUtil.newArrayList();
|
||||
cmdArguments.add("--config");
|
||||
cmdArguments.add("extensions.hg4ideapromptextension=" + myVcs.getPromptHooksExtensionFile().getAbsolutePath());
|
||||
cmdArguments.add("--config");
|
||||
cmdArguments.add("hg4ideapass.port=" + port);
|
||||
|
||||
if (arguments != null && arguments.size() != 0) {
|
||||
cmdArguments.addAll(arguments);
|
||||
}
|
||||
return cmdArguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void logCommand(@NotNull String operation, @Nullable List<String> arguments) {
|
||||
//do not log arguments for remote command because of internal password port info etc
|
||||
super.logCommand(operation, null);
|
||||
}
|
||||
|
||||
private static class PassReceiver extends SocketServer.Protocol {
|
||||
private final Project myProject;
|
||||
|
||||
@@ -263,7 +263,8 @@ public class HgRegularUpdater implements HgUpdater {
|
||||
|
||||
HgRevisionNumber parentBeforeUpdate = new HgWorkingCopyRevisionsCommand(project).firstParent(repo);
|
||||
HgUpdateCommand hgUpdateCommand = new HgUpdateCommand(project, repo);
|
||||
String warningMessages = ensureSuccess(hgUpdateCommand.execute()).getWarnings();
|
||||
HgCommandResult updateResult = hgUpdateCommand.execute();
|
||||
String warningMessages = ensureSuccess(updateResult).getRawError();
|
||||
handlePossibleWarning(warnings, warningMessages);
|
||||
|
||||
HgRevisionNumber parentAfterUpdate = new HgWorkingCopyRevisionsCommand(project).firstParent(repo);
|
||||
|
||||
Reference in New Issue
Block a user