com.intellij.psi.search.GlobalSearchScopes#com.intellij.xdebugger.XSourcePosition源码实例Demo

下面列出了com.intellij.psi.search.GlobalSearchScopes#com.intellij.xdebugger.XSourcePosition 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
public XDebuggerEditorsProvider getEditorsProvider(@NotNull XLineBreakpoint<XBreakpointProperties> breakpoint, @NotNull Project project)
{
    final XSourcePosition position = breakpoint.getSourcePosition();
    if (position == null)
    {
        return null;
    }

    final PsiFile file = PsiManager.getInstance(project).findFile(position.getFile());
    if (file == null)
    {
        return null;
    }

    return new MuleDebuggerEditorsProvider();
}
 
源代码2 项目: flutter-intellij   文件: FlutterPositionMapper.java
/**
 * Returns the local position (to display to the user) corresponding to a token position in Observatory.
 */
@Nullable
private XSourcePosition getSourcePosition(@NotNull final String isolateId, @NotNull final String scriptId,
                                          @NotNull final String scriptUri, int tokenPos) {
  if (scriptProvider == null) {
    FlutterUtils.warn(LOG, "attempted to get source position before connected to observatory");
    return null;
  }

  final VirtualFile local = findLocalFile(scriptUri);

  final ObservatoryFile.Cache cache =
    fileCache.computeIfAbsent(isolateId, (id) -> new ObservatoryFile.Cache(id, scriptProvider));

  final ObservatoryFile remote = cache.downloadOrGet(scriptId, local == null);
  if (remote == null) return null;

  return remote.createPosition(local, tokenPos);
}
 
源代码3 项目: CppTools   文件: CppStackFrame.java
@Override
  public void customizePresentation(ColoredTextContainer component) {

  XSourcePosition position = getSourcePosition();
  component.append(myScope, SimpleTextAttributes.REGULAR_ATTRIBUTES);
  component.append(" in ", SimpleTextAttributes.REGULAR_ATTRIBUTES);

  if (position != null) {
    component.append(position.getFile().getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
    component.append(":" + position.getLine(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
  }
  else {
    component.append("<file name is not available>", SimpleTextAttributes.REGULAR_ATTRIBUTES);
  }
  component.setIcon(AllIcons.Debugger.StackFrame);
}
 
源代码4 项目: consulo   文件: XInspectDialog.java
public XInspectDialog(@Nonnull Project project,
                      XDebuggerEditorsProvider editorsProvider,
                      XSourcePosition sourcePosition,
                      @Nonnull String name,
                      @Nonnull XValue value,
                      XValueMarkers<?, ?> markers) {
  super(project, false);

  setTitle(XDebuggerBundle.message("inspect.value.dialog.title", name));
  setModal(false);

  Pair<XValue, String> initialItem = Pair.create(value, name);
  XDebuggerTreeCreator creator = new XDebuggerTreeCreator(project, editorsProvider, sourcePosition, markers);
  myDebuggerTreePanel = new DebuggerTreeWithHistoryPanel<Pair<XValue, String>>(initialItem, creator, project);
  init();
}
 
源代码5 项目: flutter-intellij   文件: ObservatoryFile.java
/**
 * Given a token id, returns the source position to display to the user.
 * <p>
 * If no local file was provided, uses the snapshot if available. (However, in that
 * case, breakpoints won't work.)
 */
@Nullable
XSourcePosition createPosition(@Nullable VirtualFile local, int tokenPos) {
  final VirtualFile fileToUse = local == null ? snapshot : local;
  if (fileToUse == null) return null;

  if (positionMap == null) {
    return null;
  }

  final Position pos = positionMap.get(tokenPos);
  if (pos == null) {
    return XDebuggerUtil.getInstance().createPositionByOffset(fileToUse, 0);
  }
  return XDebuggerUtil.getInstance().createPosition(fileToUse, pos.line, pos.column);
}
 
@Test
public void shouldGetPositionInFileUnderRemoteBaseUri() throws Exception {
  tmp.writeFile("root/pubspec.yaml", "");
  tmp.ensureDir("root/lib");
  final VirtualFile main = tmp.writeFile("root/lib/main.dart", "");
  final VirtualFile hello = tmp.writeFile("root/lib/hello.dart", "");

  final FlutterPositionMapper mapper = setUpMapper(main, "remote:root");

  scripts.addScript("1", "2", "remote:root/lib/hello.dart", ImmutableList.of(new Line(10, 123, 1)));

  final XSourcePosition pos = mapper.getSourcePosition("1", makeScriptRef("2", "remote:root/lib/hello.dart"), 123);
  assertNotNull(pos);
  assertEquals(pos.getFile(), hello);
  assertEquals(pos.getLine(), 9); // zero-based
}
 
源代码7 项目: intellij   文件: SkylarkDebuggerEditorsProvider.java
@Override
public Document createDocument(
    Project project,
    String expression,
    @Nullable XSourcePosition sourcePosition,
    EvaluationMode mode) {
  PsiElement context = null;
  if (sourcePosition != null) {
    context = getContextElement(sourcePosition.getFile(), sourcePosition.getOffset(), project);
  }
  PsiFile codeFragment =
      createExpressionCodeFragment(project, expression, sourcePosition, context);
  Document document = PsiDocumentManager.getInstance(project).getDocument(codeFragment);
  assert document != null;
  return document;
}
 
源代码8 项目: consulo   文件: XDebuggerTreePanel.java
public XDebuggerTreePanel(final @Nonnull Project project,
                          final @Nonnull XDebuggerEditorsProvider editorsProvider,
                          @Nonnull Disposable parentDisposable,
                          final @Nullable XSourcePosition sourcePosition,
                          @Nonnull @NonNls final String popupActionGroupId,
                          @Nullable XValueMarkers<?, ?> markers) {
  myTree = new XDebuggerTree(project, editorsProvider, sourcePosition, popupActionGroupId, markers);
  myMainPanel = new JPanel(new BorderLayout());
  myMainPanel.add(ScrollPaneFactory.createScrollPane(myTree), BorderLayout.CENTER);
  Disposer.register(parentDisposable, myTree);
  Disposer.register(parentDisposable, myMainPanel::removeAll);
}
 
@NotNull
@Override
public Document createDocument(@NotNull Project project, @NotNull String text, @Nullable XSourcePosition xSourcePosition, @NotNull EvaluationMode evaluationMode)
{

    final PsiFile psiFile = PsiFileFactory.getInstance(project)
                                          .createFileFromText("muleExpr." + getFileType().getDefaultExtension(), getFileType(), text, LocalTimeCounter.currentTime(), true);
    return PsiDocumentManager.getInstance(project).getDocument(psiFile);
}
 
@Override
public void evaluate(@NotNull String script, @NotNull final XEvaluationCallback xEvaluationCallback, @Nullable XSourcePosition xSourcePosition) {
    final String melExpression = MuleConfigUtils.asMelScript(script);
    session.eval(melExpression, new ScriptEvaluationCallback() {
        @Override
        public void onScriptEvaluationException(RemoteDebugException exception) {
            xEvaluationCallback.evaluated(new ObjectFieldDefinitionValue(session, exception.getException(), AllIcons.General.Error));
        }

        @Override
        public void onScriptEvaluation(ScriptResultInfo info) {
            xEvaluationCallback.evaluated(new ObjectFieldDefinitionValue(session, info.getResult(), AllIcons.Nodes.Function));
        }
    });
}
 
@NotNull
@Override
public Document createDocument(@NotNull Project project, @NotNull String text, @Nullable XSourcePosition sourcePosition, @NotNull EvaluationMode evaluationMode) {
    final PsiFile psiFile = PsiFileFactory.getInstance(project)
            .createFileFromText("MelExpr." + getFileType().getDefaultExtension(), getFileType(), text, LocalTimeCounter.currentTime(), true);
    final Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
    assert document != null;
    return document;
}
 
源代码12 项目: consulo   文件: XSourcePositionImpl.java
@Nonnull
public static OpenFileDescriptor createOpenFileDescriptor(@Nonnull Project project, @Nonnull XSourcePosition position) {
  Navigatable navigatable = position.createNavigatable(project);
  if (navigatable instanceof OpenFileDescriptor) {
    return (OpenFileDescriptor)navigatable;
  }
  else {
    return doCreateOpenFileDescriptor(project, position);
  }
}
 
源代码13 项目: consulo   文件: XBreakpointManagerImpl.java
private void updateBreakpointInFile(final VirtualFile file) {
  ApplicationManager.getApplication().invokeLater(() -> {
    for (XBreakpointBase breakpoint : getAllBreakpoints()) {
      XSourcePosition position = breakpoint.getSourcePosition();
      if (position != null && Comparing.equal(position.getFile(), file)) {
        fireBreakpointChanged(breakpoint);
      }
    }
  });
}
 
源代码14 项目: consulo   文件: XDebugView.java
@Nullable
protected VirtualFile getCurrentFile(@Nonnull Component component) {
  XDebugSession session = getSession(component);
  if (session != null) {
    XSourcePosition position = session.getCurrentPosition();
    if (position != null) {
      return position.getFile();
    }
  }
  return null;
}
 
源代码15 项目: consulo   文件: XStackFrame.java
/**
 * Customize presentation of the stack frame in frames list
 * @param component component
 */
public void customizePresentation(ColoredTextContainer component) {
  XSourcePosition position = getSourcePosition();
  if (position != null) {
    component.append(position.getFile().getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
    component.append(":" + (position.getLine() + 1), SimpleTextAttributes.REGULAR_ATTRIBUTES);
    component.setIcon(AllIcons.Debugger.StackFrame);
  }
  else {
    component.append(XDebuggerBundle.message("invalid.frame"), SimpleTextAttributes.ERROR_ATTRIBUTES);
  }
}
 
源代码16 项目: intellij-xquery   文件: XQueryBreakpointType.java
@Override
public XDebuggerEditorsProvider getEditorsProvider(@NotNull XLineBreakpoint<XBreakpointProperties> breakpoint, @NotNull Project project) {
    final XSourcePosition position = breakpoint.getSourcePosition();
    if (position == null) {
        return null;
    }
    final PsiFile file = PsiManager.getInstance(project).findFile(position.getFile());
    if (file == null) {
        return null;
    }
    return new XQueryEditorsProvider();
}
 
源代码17 项目: consulo   文件: XDebuggerEditorsProviderBase.java
@Nonnull
@Override
public final Document createDocument(@Nonnull Project project, @Nonnull String text, @Nullable XSourcePosition sourcePosition, @Nonnull EvaluationMode mode) {
  PsiElement context = null;
  if (sourcePosition != null) {
    context = getContextElement(sourcePosition.getFile(), sourcePosition.getOffset(), project);
  }

  PsiFile codeFragment = createExpressionCodeFragment(project, text, context, true);
  Document document = PsiDocumentManager.getInstance(project).getDocument(codeFragment);
  assert document != null;
  return document;
}
 
源代码18 项目: consulo   文件: XDebuggerEditorsProviderBase.java
@Nonnull
@Override
public Document createDocument(@Nonnull Project project,
                               @Nonnull XExpression expression,
                               @javax.annotation.Nullable XSourcePosition sourcePosition,
                               @Nonnull EvaluationMode mode) {
  PsiElement context = null;
  if (sourcePosition != null) {
    context = getContextElement(sourcePosition.getFile(), sourcePosition.getOffset(), project);
  }
  return createDocument(project, expression, context, mode);
}
 
源代码19 项目: consulo   文件: XDebuggerEditorsProvider.java
@Nonnull
public Document createDocument(@Nonnull Project project,
                               @Nonnull XExpression expression,
                               @Nullable XSourcePosition sourcePosition,
                               @Nonnull EvaluationMode mode) {
  return createDocument(project, expression.getExpression(), sourcePosition, mode);
}
 
源代码20 项目: intellij-xquery   文件: XQueryEditorsProvider.java
@NotNull
@Override
public Document createDocument(@NotNull Project project, @NotNull String text,
                               @Nullable XSourcePosition sourcePosition, @NotNull EvaluationMode mode) {
    final PsiFile psiFile = PsiFileFactory.getInstance(project)
            .createFileFromText("XQueryExpr." + fileType.getDefaultExtension(), fileType, text,
                    LocalTimeCounter.currentTime(), true);
    final Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
    assert document != null;
    return document;
}
 
源代码21 项目: intellij-xquery   文件: XQueryStackFrame.java
@Override
public void customizePresentation(@NotNull ColoredTextContainer component) {
    XSourcePosition position = this.getSourcePosition();
    if(position != null) {
        component.append(where != null && !"".equals(where) ? where + "()" : "<main>()", SimpleTextAttributes.REGULAR_ATTRIBUTES);
        component.append(":" + (lineNumber) +", ", SimpleTextAttributes.REGULAR_ATTRIBUTES);
        component.append(position.getFile().getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
        component.append("(" + position.getFile().getPath() + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
        component.setIcon(AllIcons.Debugger.StackFrame);
    } else {
        component.append(XDebuggerBundle.message("invalid.frame", new Object[0]), SimpleTextAttributes.ERROR_ATTRIBUTES);
    }

}
 
源代码22 项目: consulo   文件: XDebuggerSmartStepIntoHandler.java
@Override
protected void perform(@Nonnull XDebugSession session, DataContext dataContext) {
  XSmartStepIntoHandler<?> handler = session.getDebugProcess().getSmartStepIntoHandler();
  XSourcePosition position = session.getTopFramePosition();
  if (position == null || handler == null) return;

  FileEditor editor = FileEditorManager.getInstance(session.getProject()).getSelectedEditor(position.getFile());
  if (editor instanceof TextEditor) {
    doSmartStepInto(handler, position, session, ((TextEditor)editor).getEditor());
  }
}
 
源代码23 项目: flutter-intellij   文件: DartVmServiceValue.java
private static void reportSourcePosition(@NotNull final DartVmServiceDebugProcess debugProcess,
                                         @NotNull final XNavigatable navigatable,
                                         @NotNull final String isolateId,
                                         @Nullable final ScriptRef script,
                                         final int tokenPos) {
  if (script == null || tokenPos <= 0) {
    navigatable.setSourcePosition(null);
    return;
  }

  ApplicationManager.getApplication().executeOnPooledThread(() -> {
    final XSourcePosition sourcePosition = debugProcess.getSourcePosition(isolateId, script, tokenPos);
    ApplicationManager.getApplication().runReadAction(() -> navigatable.setSourcePosition(sourcePosition));
  });
}
 
源代码24 项目: flutter-intellij   文件: DiagnosticsNode.java
private CompletableFuture<String> createPropertyDocFuture() {
  final DiagnosticsNode parent = getParent();
  if (parent != null) {
    return inspectorService.thenComposeAsync((service) -> service.toDartVmServiceValueForSourceLocation(parent.getValueRef())
      .thenComposeAsync((DartVmServiceValue vmValue) -> {
        if (vmValue == null) {
          return CompletableFuture.completedFuture(null);
        }
        return inspectorService.getNow(null).getPropertyLocation(vmValue.getInstanceRef(), getName())
          .thenApplyAsync((XSourcePosition sourcePosition) -> {
            if (sourcePosition != null) {
              final VirtualFile file = sourcePosition.getFile();
              final int offset = sourcePosition.getOffset();

              final Project project = getProject(file);
              if (project != null) {
                final List<HoverInformation> hovers =
                  DartAnalysisServerService.getInstance(project).analysis_getHover(file, offset);
                if (!hovers.isEmpty()) {
                  return hovers.get(0).getDartdoc();
                }
              }
            }
            return "Unable to find property source";
          });
      })).exceptionally(t -> {
      LOG.info("ignoring exception from toObjectForSourceLocation: " + t.toString());
      return null;
    });
  }

  return CompletableFuture.completedFuture("Unable to find property source");
}
 
源代码25 项目: flutter-intellij   文件: InspectorSourceLocation.java
public XSourcePosition getXSourcePosition() {
  final VirtualFile file = getFile();
  if (file == null) {
    return null;
  }
  final int line = getLine();
  final int column = getColumn();
  if (line < 0 || column < 0) {
    return null;
  }
  return XSourcePositionImpl.create(file, line - 1, column - 1);
}
 
源代码26 项目: consulo   文件: XBreakpointItem.java
@Override
public void doUpdateDetailView(DetailView panel, boolean editorOnly) {
  XBreakpointBase breakpoint = (XBreakpointBase)myBreakpoint;
  Project project = breakpoint.getProject();
  //saveState();
  if (myPropertiesPanel != null) {
    myPropertiesPanel.dispose();
    myPropertiesPanel = null;
  }
  if (!editorOnly) {
    myPropertiesPanel = new XLightBreakpointPropertiesPanel(project, getManager(), breakpoint, true);

    panel.setPropertiesPanel(myPropertiesPanel.getMainPanel());
  }

  XSourcePosition sourcePosition = myBreakpoint.getSourcePosition();
  if (sourcePosition != null && sourcePosition.getFile().isValid()) {
    showInEditor(panel, sourcePosition.getFile(), sourcePosition.getLine());
  }
  else {
    panel.clearEditor();
  }

  if (myPropertiesPanel != null) {
    myPropertiesPanel.setDetailView(panel);
    myPropertiesPanel.loadProperties();
    myPropertiesPanel.getMainPanel().revalidate();

  }

}
 
源代码27 项目: flutter-intellij   文件: JumpToSourceAction.java
@Override
protected XSourcePosition getSourcePosition(DiagnosticsNode node) {
  if (!node.hasCreationLocation()) {
    return null;
  }
  return node.getCreationLocation().getXSourcePosition();
}
 
源代码28 项目: flutter-intellij   文件: EvalOnDartLibrary.java
@NotNull
public CompletableFuture<XSourcePosition> getSourcePosition(DartVmServiceDebugProcess debugProcess,
                                                            ScriptRef script,
                                                            int tokenPos,
                                                            InspectorService.ObjectGroup isAlive) {
  return addRequest(isAlive, "getSourcePosition",
                    () -> CompletableFuture.completedFuture(debugProcess.getSourcePosition(isolateId, script, tokenPos)));
}
 
源代码29 项目: consulo   文件: XDebuggerExpressionComboBox.java
public XDebuggerExpressionComboBox(@Nonnull Project project, @Nonnull XDebuggerEditorsProvider debuggerEditorsProvider, @Nullable @NonNls String historyId,
                                   @Nullable XSourcePosition sourcePosition, boolean showEditor) {
  super(project, debuggerEditorsProvider, EvaluationMode.EXPRESSION, historyId, sourcePosition);
  myComboBox = new ComboBox<>(100);
  myComboBox.setEditable(true);
  myExpression = XExpressionImpl.EMPTY_EXPRESSION;
  Dimension minimumSize = new Dimension(myComboBox.getMinimumSize());
  minimumSize.width = 100;
  myComboBox.setMinimumSize(minimumSize);
  initEditor();
  fillComboBox();
  myComponent = showEditor ? addMultilineButton(myComboBox) : myComboBox;
}
 
源代码30 项目: flutter-intellij   文件: WidgetPerfTable.java
private void navigateToStatsEntry(SlidingWindowStatsSummary stats) {
  if (stats == null) {
    return;
  }
  final Location location = stats.getLocation();
  final XSourcePosition position = location.getXSourcePosition();
  if (position != null) {
    AsyncUtils.invokeLater(() -> {
      position.createNavigatable(app.getProject()).navigate(false);
    });
  }
}