本文整理汇总了Java中com.intellij.xdebugger.XDebuggerUtil类的典型用法代码示例。如果您正苦于以下问题:Java XDebuggerUtil类的具体用法?Java XDebuggerUtil怎么用?Java XDebuggerUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XDebuggerUtil类属于com.intellij.xdebugger包,在下文中一共展示了XDebuggerUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getExpressionRangeAtOffset
import com.intellij.xdebugger.XDebuggerUtil; //导入依赖的package包/类
@Nullable
@Override
public TextRange getExpressionRangeAtOffset(final Project project, final Document document, final int offset, final boolean sideEffectsAllowed) {
final Ref<TextRange> currentRange = Ref.create(null);
PsiDocumentManager.getInstance(project).commitAndRunReadAction(() -> {
try {
PsiElement elementAtCursor = XDebuggerUtil.getInstance().findContextElement(PsiDocumentManager
.getInstance(project).getPsiFile(document).getVirtualFile(), offset, project, false);
if (elementAtCursor == null) return;
Pair<PsiElement, TextRange> pair = findExpression(elementAtCursor, sideEffectsAllowed);
if (pair != null) {
currentRange.set(pair.getSecond());
}
} catch (IndexNotReadyException ignored) {}
});
return currentRange.get();
}
示例2: setBreakpointDefaults
import com.intellij.xdebugger.XDebuggerUtil; //导入依赖的package包/类
public void setBreakpointDefaults(Key<? extends Breakpoint> category, BreakpointDefaults defaults) {
Class typeCls = null;
if (LineBreakpoint.CATEGORY.toString().equals(category.toString())) {
typeCls = JavaLineBreakpointType.class;
}
else if (MethodBreakpoint.CATEGORY.toString().equals(category.toString())) {
typeCls = JavaMethodBreakpointType.class;
}
else if (FieldBreakpoint.CATEGORY.toString().equals(category.toString())) {
typeCls = JavaFieldBreakpointType.class;
}
else if (ExceptionBreakpoint.CATEGORY.toString().equals(category.toString())) {
typeCls = JavaExceptionBreakpointType.class;
}
if (typeCls != null) {
XBreakpointType<XBreakpoint<?>, ?> type = XDebuggerUtil.getInstance().findBreakpointType(typeCls);
((XBreakpointManagerImpl)getXBreakpointManager()).getBreakpointDefaults(type).setSuspendPolicy(Breakpoint.transformSuspendPolicy(defaults.getSuspendPolicy()));
}
}
示例3: addExceptionBreakpoint
import com.intellij.xdebugger.XDebuggerUtil; //导入依赖的package包/类
@NotNull
public ExceptionBreakpoint addExceptionBreakpoint(@NotNull final String exceptionClassName, final String packageName) {
ApplicationManager.getApplication().assertIsDispatchThread();
final JavaExceptionBreakpointType type = (JavaExceptionBreakpointType)XDebuggerUtil.getInstance().findBreakpointType(JavaExceptionBreakpointType.class);
return ApplicationManager.getApplication().runWriteAction(new Computable<ExceptionBreakpoint>() {
@Override
public ExceptionBreakpoint compute() {
XBreakpoint<JavaExceptionBreakpointProperties> xBreakpoint = XDebuggerManager.getInstance(myProject).getBreakpointManager()
.addBreakpoint(type, new JavaExceptionBreakpointProperties(exceptionClassName, packageName));
Breakpoint javaBreakpoint = getJavaBreakpoint(xBreakpoint);
if (javaBreakpoint instanceof ExceptionBreakpoint) {
ExceptionBreakpoint exceptionBreakpoint = (ExceptionBreakpoint)javaBreakpoint;
exceptionBreakpoint.setQualifiedName(exceptionClassName);
exceptionBreakpoint.setPackageName(packageName);
addBreakpoint(exceptionBreakpoint);
if (LOG.isDebugEnabled()) {
LOG.debug("ExceptionBreakpoint Added");
}
return exceptionBreakpoint;
}
return null;
}
});
}
示例4: getSourcePosition
import com.intellij.xdebugger.XDebuggerUtil; //导入依赖的package包/类
@Nullable
@Override
public XSourcePosition getSourcePosition(@NotNull XBreakpoint<T> breakpoint) {
Breakpoint javaBreakpoint = BreakpointManager.getJavaBreakpoint(breakpoint);
if (javaBreakpoint != null) {
final PsiClass aClass = javaBreakpoint.getPsiClass();
if (aClass != null) {
return ApplicationManager.getApplication().runReadAction(new Computable<XSourcePosition>() {
@Override
public XSourcePosition compute() {
PsiFile containingFile = aClass.getContainingFile();
if (containingFile != null && aClass.getTextOffset() >= 0) {
return XDebuggerUtil.getInstance().createPositionByOffset(containingFile.getVirtualFile(), aClass.getTextOffset());
}
return null;
}
});
}
}
return null;
}
示例5: XValueHint
import com.intellij.xdebugger.XDebuggerUtil; //导入依赖的package包/类
public XValueHint(@NotNull Project project, @NotNull Editor editor, @NotNull Point point, @NotNull ValueHintType type,
@NotNull ExpressionInfo expressionInfo, @NotNull XDebuggerEvaluator evaluator,
@NotNull XDebugSession session) {
super(project, editor, point, type, expressionInfo.getTextRange());
myEvaluator = evaluator;
myDebugSession = session;
myExpression = XDebuggerEvaluateActionHandler.getExpressionText(expressionInfo, editor.getDocument());
myValueName = XDebuggerEvaluateActionHandler.getDisplayText(expressionInfo, editor.getDocument());
myExpressionInfo = expressionInfo;
VirtualFile file;
ConsoleView consoleView = ConsoleViewImpl.CONSOLE_VIEW_IN_EDITOR_VIEW.get(editor);
if (consoleView instanceof LanguageConsoleView) {
LanguageConsoleView console = ((LanguageConsoleView)consoleView);
file = console.getHistoryViewer() == editor ? console.getVirtualFile() : null;
}
else {
file = FileDocumentManager.getInstance().getFile(editor.getDocument());
}
myExpressionPosition = file != null ? XDebuggerUtil.getInstance().createPositionByOffset(file, expressionInfo.getTextRange().getStartOffset()) : null;
}
示例6: findBreakpoint
import com.intellij.xdebugger.XDebuggerUtil; //导入依赖的package包/类
@Nullable
public XBreakpoint<?> findBreakpoint(@NotNull final Project project, @NotNull final Document document, final int offset) {
XBreakpointManager breakpointManager = XDebuggerManager.getInstance(project).getBreakpointManager();
int line = document.getLineNumber(offset);
VirtualFile file = FileDocumentManager.getInstance().getFile(document);
if (file == null) {
return null;
}
for (XLineBreakpointType<?> type : XDebuggerUtil.getInstance().getLineBreakpointTypes()) {
XLineBreakpoint<? extends XBreakpointProperties> breakpoint = breakpointManager.findBreakpointAtLine(type, file, line);
if (breakpoint != null) {
return breakpoint;
}
}
return null;
}
示例7: computeSmartStepVariants
import com.intellij.xdebugger.XDebuggerUtil; //导入依赖的package包/类
@Override
@NotNull
public List<PySmartStepIntoVariant> computeSmartStepVariants(@NotNull XSourcePosition position) {
final Document document = FileDocumentManager.getInstance().getDocument(position.getFile());
final List<PySmartStepIntoVariant> variants = Lists.newArrayList();
final Set<PyCallExpression> visitedCalls = Sets.newHashSet();
final int line = position.getLine();
XDebuggerUtil.getInstance().iterateLine(mySession.getProject(), document, line, new Processor<PsiElement>() {
@Override
public boolean process(PsiElement psiElement) {
addVariants(document, line, psiElement, variants, visitedCalls);
return true;
}
});
return variants;
}
示例8: canPutAt
import com.intellij.xdebugger.XDebuggerUtil; //导入依赖的package包/类
@Override
public boolean canPutAt(@NotNull final VirtualFile file, final int line, @NotNull final Project project) {
final Ref<Boolean> stoppable = Ref.create(false);
final Document document = FileDocumentManager.getInstance().getDocument(file);
if (document != null) {
if (file.getFileType() == PythonFileType.INSTANCE || isPythonScratch(file)) {
XDebuggerUtil.getInstance().iterateLine(project, document, line, new Processor<PsiElement>() {
@Override
public boolean process(PsiElement psiElement) {
if (psiElement instanceof PsiWhiteSpace || psiElement instanceof PsiComment) return true;
if (psiElement.getNode() != null && notStoppableElementType(psiElement.getNode().getElementType())) return true;
// Python debugger seems to be able to stop on pretty much everything
stoppable.set(true);
return false;
}
});
if (PyDebugSupportUtils.isContinuationLine(document, line - 1)) {
stoppable.set(false);
}
}
}
return stoppable.get();
}
示例9: actionPerformed
import com.intellij.xdebugger.XDebuggerUtil; //导入依赖的package包/类
@SuppressWarnings("ConstantConditions")
@Override
public void actionPerformed(AnActionEvent event) {
DataContext dataContext = event.getDataContext();
Editor editor = EDITOR.getData(dataContext);
if (editor instanceof EditorEx
&& event.getInputEvent() instanceof MouseEvent
&& editor.getUserData(POPUP_LINE) != null) {
EditorEx exEditor = (EditorEx) editor;
if (exEditor.getProject() == null) {
LOG.error("could not add a snapshot location as the target editor was unexpectedly null.");
return;
}
if (editor.getUserData(POPUP_LINE) == null) {
LOG.error("could not add a snapshot location as the target line was unexpectedly null.");
return;
}
XDebuggerUtil.getInstance()
.toggleLineBreakpoint(
exEditor.getProject(),
CloudLineBreakpointType.getInstance(),
exEditor.getVirtualFile(),
editor.getUserData(POPUP_LINE));
}
}
示例10: CloudStackFrame
import com.intellij.xdebugger.XDebuggerUtil; //导入依赖的package包/类
/** Initialize the frame. */
public CloudStackFrame(
@NotNull Project project,
@NotNull StackFrame frame,
@NotNull List<Variable> variableTable,
@Nullable List<Variable> evaluatedExpressions,
@NotNull ServerToIdeFileResolver fileResolver) {
this.frame = frame;
this.variableTable = variableTable;
this.evaluatedExpressions = evaluatedExpressions;
String path = frame.getLocation().getPath();
if (!Strings.isNullOrEmpty(path)) {
sourcePosition =
XDebuggerUtil.getInstance()
.createPosition(
fileResolver.getFileFromPath(project, path), frame.getLocation().getLine() - 1);
} else {
sourcePosition = null;
}
}
示例11: perform
import com.intellij.xdebugger.XDebuggerUtil; //导入依赖的package包/类
public void perform(@NotNull final Project project, final AnActionEvent event) {
XSourcePosition position = XDebuggerUtilImpl.getCaretPosition(project, event.getDataContext());
if (position == null) return;
ExpandRegionAction.expandRegionAtCaret(project, event.getData(PlatformDataKeys.EDITOR));
int line = position.getLine();
VirtualFile file = position.getFile();
final XBreakpointManager breakpointManager = XDebuggerManager.getInstance(project).getBreakpointManager();
for (XLineBreakpointType<?> type : XDebuggerUtil.getInstance().getLineBreakpointTypes()) {
final XLineBreakpoint<? extends XBreakpointProperties> breakpoint = breakpointManager.findBreakpointAtLine(type, file, line);
if (breakpoint != null && myTemporary && !breakpoint.isTemporary()) {
breakpoint.setTemporary(true);
} else if (type.canPutAt(file, line, project) || breakpoint != null) {
XDebuggerUtil.getInstance().toggleLineBreakpoint(project, type, file, line, myTemporary);
return;
}
}
}
示例12: XValueHint
import com.intellij.xdebugger.XDebuggerUtil; //导入依赖的package包/类
public XValueHint(@Nonnull Project project, @Nonnull Editor editor, @Nonnull Point point, @Nonnull ValueHintType type,
@Nonnull ExpressionInfo expressionInfo, @Nonnull XDebuggerEvaluator evaluator,
@Nonnull XDebugSession session) {
super(project, editor, point, type, expressionInfo.getTextRange());
myEvaluator = evaluator;
myDebugSession = session;
myExpression = XDebuggerEvaluateActionHandler.getExpressionText(expressionInfo, editor.getDocument());
myValueName = XDebuggerEvaluateActionHandler.getDisplayText(expressionInfo, editor.getDocument());
myExpressionInfo = expressionInfo;
VirtualFile file;
ConsoleView consoleView = ConsoleViewImpl.CONSOLE_VIEW_IN_EDITOR_VIEW.get(editor);
if (consoleView instanceof LanguageConsoleView) {
LanguageConsoleView console = ((LanguageConsoleView)consoleView);
file = console.getHistoryViewer() == editor ? console.getVirtualFile() : null;
}
else {
file = FileDocumentManager.getInstance().getFile(editor.getDocument());
}
myExpressionPosition = file != null ? XDebuggerUtil.getInstance().createPositionByOffset(file, expressionInfo.getTextRange().getStartOffset()) : null;
}
示例13: isEnabled
import com.intellij.xdebugger.XDebuggerUtil; //导入依赖的package包/类
@Override
public boolean isEnabled(@Nonnull final Project project, final AnActionEvent event) {
XLineBreakpointType<?>[] breakpointTypes = XDebuggerUtil.getInstance().getLineBreakpointTypes();
final XBreakpointManager breakpointManager = XDebuggerManager.getInstance(project).getBreakpointManager();
for (XSourcePosition position : XDebuggerUtilImpl.getAllCaretsPositions(project, event.getDataContext())) {
for (XLineBreakpointType<?> breakpointType : breakpointTypes) {
final VirtualFile file = position.getFile();
final int line = position.getLine();
if (XLineBreakpointResolverTypeExtension.INSTANCE.resolveBreakpointType(project, file, line) != null ||
breakpointManager.findBreakpointAtLine(breakpointType, file, line) != null) {
return true;
}
}
}
return false;
}
示例14: findBreakpoint
import com.intellij.xdebugger.XDebuggerUtil; //导入依赖的package包/类
@Override
@Nullable
public XBreakpoint<?> findBreakpoint(@Nonnull final Project project, @Nonnull final Document document, final int offset) {
XBreakpointManager breakpointManager = XDebuggerManager.getInstance(project).getBreakpointManager();
int line = document.getLineNumber(offset);
VirtualFile file = FileDocumentManager.getInstance().getFile(document);
if (file == null) {
return null;
}
for (XLineBreakpointType<?> type : XDebuggerUtil.getInstance().getLineBreakpointTypes()) {
XLineBreakpoint<? extends XBreakpointProperties> breakpoint = breakpointManager.findBreakpointAtLine(type, file, line);
if (breakpoint != null) {
return breakpoint;
}
}
return null;
}
示例15: setBreakpointDefaults
import com.intellij.xdebugger.XDebuggerUtil; //导入依赖的package包/类
public void setBreakpointDefaults(Key<? extends Breakpoint> category, BreakpointDefaults defaults)
{
Class typeCls = null;
if(LineBreakpoint.CATEGORY.toString().equals(category.toString()))
{
typeCls = JavaLineBreakpointType.class;
}
else if(MethodBreakpoint.CATEGORY.toString().equals(category.toString()))
{
typeCls = JavaMethodBreakpointType.class;
}
else if(FieldBreakpoint.CATEGORY.toString().equals(category.toString()))
{
typeCls = JavaFieldBreakpointType.class;
}
else if(ExceptionBreakpoint.CATEGORY.toString().equals(category.toString()))
{
typeCls = JavaExceptionBreakpointType.class;
}
if(typeCls != null)
{
XBreakpointType<XBreakpoint<?>, ?> type = XDebuggerUtil.getInstance().findBreakpointType(typeCls);
((XBreakpointManagerImpl) getXBreakpointManager()).getBreakpointDefaults(type).setSuspendPolicy(Breakpoint.transformSuspendPolicy(defaults.getSuspendPolicy()));
}
}