mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -326,19 +326,36 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XV
|
||||
}
|
||||
|
||||
@Override
|
||||
public void computeSourcePosition(@NotNull XNavigatable navigatable) {
|
||||
if (myValueDescriptor instanceof FieldDescriptorImpl) {
|
||||
SourcePosition position = ((FieldDescriptorImpl)myValueDescriptor).getSourcePosition(getProject(), getDebuggerContext());
|
||||
if (position != null) {
|
||||
navigatable.setSourcePosition(DebuggerUtilsEx.toXSourcePosition(position));
|
||||
public void computeSourcePosition(@NotNull final XNavigatable navigatable) {
|
||||
if (myEvaluationContext.getSuspendContext().isResumed()) return;
|
||||
myEvaluationContext.getDebugProcess().getManagerThread().schedule(new SuspendContextCommandImpl(myEvaluationContext.getSuspendContext()) {
|
||||
@Override
|
||||
public Priority getPriority() {
|
||||
return Priority.NORMAL;
|
||||
}
|
||||
}
|
||||
if (myValueDescriptor instanceof LocalVariableDescriptorImpl) {
|
||||
SourcePosition position = ((LocalVariableDescriptorImpl)myValueDescriptor).getSourcePosition(getProject(), getDebuggerContext());
|
||||
if (position != null) {
|
||||
navigatable.setSourcePosition(DebuggerUtilsEx.toXSourcePosition(position));
|
||||
|
||||
@Override
|
||||
public void contextAction() throws Exception {
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (myValueDescriptor instanceof FieldDescriptorImpl) {
|
||||
SourcePosition position = ((FieldDescriptorImpl)myValueDescriptor).getSourcePosition(getProject(), getDebuggerContext());
|
||||
if (position != null) {
|
||||
navigatable.setSourcePosition(DebuggerUtilsEx.toXSourcePosition(position));
|
||||
}
|
||||
}
|
||||
if (myValueDescriptor instanceof LocalVariableDescriptorImpl) {
|
||||
SourcePosition position =
|
||||
((LocalVariableDescriptorImpl)myValueDescriptor).getSourcePosition(getProject(), getDebuggerContext());
|
||||
if (position != null) {
|
||||
navigatable.setSourcePosition(DebuggerUtilsEx.toXSourcePosition(position));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private DebuggerContextImpl getDebuggerContext() {
|
||||
|
||||
+40
-7
@@ -89,11 +89,23 @@ public class PsiNamesElementSignatureProvider extends AbstractElementSignaturePr
|
||||
return candidate instanceof PsiComment ? candidate : null;
|
||||
}
|
||||
else if (CODE_BLOCK_MARKER.equals(elementMarker)) {
|
||||
int index = 0;
|
||||
if (tokenizer.hasMoreTokens()) {
|
||||
String indexStr = tokenizer.nextToken();
|
||||
try {
|
||||
index = Integer.parseInt(indexStr);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
if (processingInfoStorage != null) {
|
||||
processingInfoStorage.append("Invalid block index: ").append(indexStr).append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
for (PsiElement child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
|
||||
PsiElement firstChild = child.getFirstChild();
|
||||
PsiElement lastChild = child.getLastChild();
|
||||
if (firstChild != null && lastChild != null && "{".equals(firstChild.getText()) && "}".equals(lastChild.getText())) {
|
||||
return child;
|
||||
if (isBlockElement(child)) {
|
||||
if (--index < 0) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -212,18 +224,39 @@ public class PsiNamesElementSignatureProvider extends AbstractElementSignaturePr
|
||||
|
||||
PsiElement parent = element.getParent();
|
||||
if (parent instanceof PsiNamedElement && !(parent instanceof PsiFile)) {
|
||||
PsiElement firstChild = element.getFirstChild();
|
||||
PsiElement lastChild = element.getLastChild();
|
||||
if (firstChild != null && "{".equals(firstChild.getText()) && lastChild != null && "}".equals(lastChild.getText())) {
|
||||
if (isBlockElement(element)) {
|
||||
int index = getBlockElementIndex(element);
|
||||
StringBuilder bufferToUse = buffer;
|
||||
if (bufferToUse == null) {
|
||||
bufferToUse = new StringBuilder();
|
||||
}
|
||||
bufferToUse.append(TYPE_MARKER).append(ELEMENT_TOKENS_SEPARATOR).append(CODE_BLOCK_MARKER);
|
||||
if (index > 0) {
|
||||
bufferToUse.append(ELEMENT_TOKENS_SEPARATOR).append(index);
|
||||
}
|
||||
return bufferToUse;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean isBlockElement(@NotNull PsiElement element) {
|
||||
PsiElement firstChild = element.getFirstChild();
|
||||
PsiElement lastChild = element.getLastChild();
|
||||
return firstChild != null && "{".equals(firstChild.getText()) && lastChild != null && "}".equals(lastChild.getText());
|
||||
}
|
||||
|
||||
private static int getBlockElementIndex(@NotNull PsiElement element) {
|
||||
int i = 0;
|
||||
for (PsiElement sibling : element.getParent().getChildren()) {
|
||||
if (element.equals(sibling)) {
|
||||
return i;
|
||||
}
|
||||
if (isBlockElement(sibling)) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("Malformed PSI");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.execution.ui.ConsoleView;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.execution.ui.RunnerLayoutUi;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.xdebugger.breakpoints.XBreakpoint;
|
||||
@@ -45,6 +46,7 @@ import javax.swing.event.HyperlinkListener;
|
||||
* @author nik
|
||||
*/
|
||||
public interface XDebugSession extends AbstractDebuggerSession {
|
||||
DataKey<XDebugSession> DATA_KEY = DataKey.create("XDebugSessionTab.XDebugSession");
|
||||
|
||||
@NotNull
|
||||
Project getProject();
|
||||
|
||||
@@ -170,6 +170,7 @@ public class XDebugSessionImpl implements XDebugSession {
|
||||
myPauseActionSupported = isSupported;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<AnAction> getRestartActions() {
|
||||
return myRestartActions;
|
||||
}
|
||||
@@ -180,6 +181,7 @@ public class XDebugSessionImpl implements XDebugSession {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<AnAction> getExtraActions() {
|
||||
return myExtraActions;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.ui.content.ContentManager;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
import com.intellij.xdebugger.impl.ui.XDebugSessionTab;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -68,11 +67,11 @@ public abstract class XDebugView implements Disposable {
|
||||
ViewContext viewContext = ViewContext.CONTEXT_KEY.getData(dataContext);
|
||||
ContentManager contentManager = viewContext == null ? null : viewContext.getContentManager();
|
||||
if (contentManager != null) {
|
||||
XDebugSession session = XDebugSessionTab.SESSION_KEY.getData(DataManager.getInstance().getDataContext(contentManager.getComponent()));
|
||||
XDebugSession session = XDebugSession.DATA_KEY.getData(DataManager.getInstance().getDataContext(contentManager.getComponent()));
|
||||
if (session != null) {
|
||||
return session;
|
||||
}
|
||||
}
|
||||
return XDebugSessionTab.SESSION_KEY.getData(dataContext);
|
||||
return XDebugSession.DATA_KEY.getData(dataContext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,6 @@ import java.util.List;
|
||||
|
||||
public class XDebugSessionTab extends DebuggerSessionTabBase {
|
||||
private static final DataKey<XDebugSessionTab> TAB_KEY = DataKey.create("XDebugSessionTab");
|
||||
public static final DataKey<XDebugSession> SESSION_KEY = DataKey.create("XDebugSessionTab.XDebugSession");
|
||||
|
||||
private XWatchesViewImpl myWatchesView;
|
||||
private final List<XDebugView> myViews = new ArrayList<XDebugView>();
|
||||
@@ -146,7 +145,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
|
||||
}
|
||||
|
||||
if (mySession != null) {
|
||||
if (SESSION_KEY.is(dataId)) {
|
||||
if (XDebugSession.DATA_KEY.is(dataId)) {
|
||||
return mySession;
|
||||
}
|
||||
else if (LangDataKeys.CONSOLE_VIEW.is(dataId)) {
|
||||
|
||||
@@ -20,12 +20,12 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.VcsNotifier;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.zmlx.hg4idea.action.HgCommandResultNotifier;
|
||||
import org.zmlx.hg4idea.command.HgPushCommand;
|
||||
import org.zmlx.hg4idea.execution.HgCommandResult;
|
||||
import org.zmlx.hg4idea.execution.HgCommandResultHandler;
|
||||
import org.zmlx.hg4idea.ui.HgPushDialog;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -34,40 +34,13 @@ import java.util.regex.Pattern;
|
||||
public class HgPusher {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance(HgPusher.class);
|
||||
private static Pattern PUSH_COMMITS_PATTERN = Pattern.compile(".*added (\\d+) changesets.*");
|
||||
private static final String ONE = "one";
|
||||
private static Pattern PUSH_COMMITS_PATTERN = Pattern.compile(".*(?:added|pushed) (\\d+|" + ONE + ") changeset.*");
|
||||
// hg push command has definite exit values for some cases:
|
||||
// mercurial returns 0 if push was successful, 1 if nothing to push. see hg push --help
|
||||
private static int PUSH_SUCCEEDED_EXIT_VALUE = 0;
|
||||
private static int NOTHING_TO_PUSH_EXIT_VALUE = 1;
|
||||
|
||||
private final Project myProject;
|
||||
|
||||
public HgPusher(Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
/* public void showDialogAndPush(@NotNull List<? extends Repository> selectedRepositories) {
|
||||
|
||||
if (selectedRepositories.isEmpty()) {
|
||||
VcsBalloonProblemNotifier.showOverChangesView(myProject, "No Mercurial repositories in the project", MessageType.ERROR);
|
||||
return;
|
||||
}
|
||||
final AtomicReference<HgPushCommand> pushCommand = new AtomicReference<HgPushCommand>();
|
||||
final HgPushDialog dialog = new HgPushDialog(myProject, repositories, selectedRepo);
|
||||
dialog.show();
|
||||
if (d2.isOK()) {
|
||||
pushCommand.set(preparePushCommand(myProject, dialog));
|
||||
new Task.Backgroundable(myProject, "Pushing...", false) {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
if (pushCommand.get() != null) {
|
||||
push(myProject, pushCommand.get());
|
||||
}
|
||||
}
|
||||
}.queue();
|
||||
}
|
||||
}*/
|
||||
|
||||
public static void push(final Project project, HgPushCommand command) {
|
||||
final VirtualFile repo = command.getRepo();
|
||||
command.execute(new HgCommandResultHandler() {
|
||||
@@ -95,17 +68,7 @@ public class HgPusher {
|
||||
});
|
||||
}
|
||||
|
||||
private static HgPushCommand preparePushCommand(Project project, HgPushDialog dialog) {
|
||||
final HgPushCommand command = new HgPushCommand(project, dialog.getRepository().getRoot(), dialog.getTarget());
|
||||
command.setRevision(dialog.getRevision());
|
||||
command.setForce(dialog.isForce());
|
||||
command.setBranchName(dialog.getBranch());
|
||||
command.setBookmarkName(dialog.getBookmarkName());
|
||||
command.setIsNewBranch(dialog.isNewBranch());
|
||||
return command;
|
||||
}
|
||||
|
||||
private static int getNumberOfPushedCommits(HgCommandResult result) {
|
||||
private static int getNumberOfPushedCommits(@NotNull HgCommandResult result) {
|
||||
int numberOfCommitsInAllSubrepos = 0;
|
||||
final List<String> outputLines = result.getOutputLines();
|
||||
for (String outputLine : outputLines) {
|
||||
@@ -113,7 +76,8 @@ public class HgPusher {
|
||||
final Matcher matcher = PUSH_COMMITS_PATTERN.matcher(outputLine);
|
||||
if (matcher.matches()) {
|
||||
try {
|
||||
numberOfCommitsInAllSubrepos += Integer.parseInt(matcher.group(1));
|
||||
String numberOfCommits = matcher.group(1);
|
||||
numberOfCommitsInAllSubrepos += ONE.equals(numberOfCommits) ? 1 : Integer.parseInt(numberOfCommits);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
LOG.error("getNumberOfPushedCommits ", e);
|
||||
|
||||
+32
-7
@@ -11,11 +11,13 @@ import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
import com.intellij.openapi.fileEditor.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.VerticalFlowLayout;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.HyperlinkLabel;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.util.ExceptionUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -42,8 +44,10 @@ public class SceneBuilderEditor extends UserDataHolderBase implements FileEditor
|
||||
private final CardLayout myLayout = new CardLayout();
|
||||
private final JPanel myPanel = new JPanel(myLayout);
|
||||
|
||||
private final JPanel myErrorPanel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 10, 5, true, false));
|
||||
//private final JPanel myErrorPanel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 10, 5, true, false));
|
||||
private final JPanel myErrorPanel = new JPanel(new BorderLayout());
|
||||
private final HyperlinkLabel myErrorLabel = new HyperlinkLabel();
|
||||
private JTextArea myErrorStack;
|
||||
|
||||
private final Document myDocument;
|
||||
private final ExternalChangeListener myChangeListener;
|
||||
@@ -72,11 +76,19 @@ public class SceneBuilderEditor extends UserDataHolderBase implements FileEditor
|
||||
}
|
||||
});
|
||||
|
||||
myErrorPanel.add(myErrorLabel);
|
||||
myErrorStack = new JTextArea(50, 20);
|
||||
myErrorStack.setEditable(false);
|
||||
|
||||
myErrorPanel.add(myErrorLabel, BorderLayout.NORTH);
|
||||
myErrorPanel.add(ScrollPaneFactory.createScrollPane(myErrorStack), BorderLayout.CENTER);
|
||||
myPanel.add(myErrorPanel);
|
||||
}
|
||||
|
||||
private void showErrorPage(State state, Throwable e) {
|
||||
if (e != null) {
|
||||
LOG.info(e);
|
||||
}
|
||||
|
||||
removeSceneBuilder();
|
||||
|
||||
if (e == null) {
|
||||
@@ -93,12 +105,21 @@ public class SceneBuilderEditor extends UserDataHolderBase implements FileEditor
|
||||
}
|
||||
myErrorLabel.setIcon(Messages.getWarningIcon());
|
||||
}
|
||||
|
||||
myErrorStack.setText(null);
|
||||
myErrorStack.setVisible(false);
|
||||
}
|
||||
else {
|
||||
myErrorLabel.setHyperlinkText("Error: " + e.getMessage(), "", "");
|
||||
String message = e.getMessage();
|
||||
if (message == null) {
|
||||
message = e.getClass().getName();
|
||||
}
|
||||
|
||||
myErrorLabel.setHyperlinkText("Error: " + message, "", "");
|
||||
myErrorLabel.setIcon(Messages.getErrorIcon());
|
||||
|
||||
LOG.info(e);
|
||||
myErrorStack.setText(ExceptionUtil.getThrowableText(e));
|
||||
myErrorStack.setVisible(true);
|
||||
}
|
||||
myLayout.show(myPanel, ERROR_CARD);
|
||||
}
|
||||
@@ -139,8 +160,12 @@ public class SceneBuilderEditor extends UserDataHolderBase implements FileEditor
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleError(Throwable e) {
|
||||
showErrorPage(null, e);
|
||||
public void handleError(final Throwable e) {
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
public void run() {
|
||||
showErrorPage(null, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initSceneBuilder(boolean choosePathIfEmpty) {
|
||||
|
||||
Reference in New Issue
Block a user