use of com.intellij.xdebugger.XSourcePosition in project intellij-community by JetBrains.
the class XsltBreakpointType method getEditorsProvider.
@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;
}
final XsltChecker.LanguageLevel level = XsltSupport.getXsltLanguageLevel(file);
if (level == XsltChecker.LanguageLevel.V1) {
return myMyEditorsProvider1;
} else if (level == XsltChecker.LanguageLevel.V2) {
return myMyEditorsProvider2;
}
return null;
}
use of com.intellij.xdebugger.XSourcePosition in project intellij-community by JetBrains.
the class JavaLineBreakpointType method computeVariants.
@NotNull
@Override
public List<JavaBreakpointVariant> computeVariants(@NotNull Project project, @NotNull XSourcePosition position) {
PsiFile file = PsiManager.getInstance(project).findFile(position.getFile());
if (file == null) {
return Collections.emptyList();
}
SourcePosition pos = SourcePosition.createFromLine(file, position.getLine());
List<PsiLambdaExpression> lambdas = DebuggerUtilsEx.collectLambdas(pos, true);
if (lambdas.isEmpty()) {
return Collections.emptyList();
}
PsiElement startMethod = DebuggerUtilsEx.getContainingMethod(pos);
//noinspection SuspiciousMethodCalls
if (lambdas.contains(startMethod) && lambdas.size() == 1) {
return Collections.emptyList();
}
Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
if (document == null) {
return Collections.emptyList();
}
List<JavaBreakpointVariant> res = new SmartList<>();
if (!(startMethod instanceof PsiLambdaExpression)) {
// base method
res.add(new LineJavaBreakpointVariant(position, startMethod, -1));
}
int ordinal = 0;
for (PsiLambdaExpression lambda : lambdas) {
//lambdas
PsiElement firstElem = DebuggerUtilsEx.getFirstElementOnTheLine(lambda, document, position.getLine());
XSourcePositionImpl elementPosition = XSourcePositionImpl.createByElement(firstElem);
if (elementPosition != null) {
if (lambda == startMethod) {
res.add(0, new LineJavaBreakpointVariant(elementPosition, lambda, ordinal++));
} else {
res.add(new LambdaJavaBreakpointVariant(elementPosition, lambda, ordinal++));
}
}
}
//all
res.add(new JavaBreakpointVariant(position));
return res;
}
use of com.intellij.xdebugger.XSourcePosition in project intellij-community by JetBrains.
the class AlternativeSourceNotificationProvider method createNotificationPanel.
@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
if (!DebuggerSettings.getInstance().SHOW_ALTERNATIVE_SOURCE) {
return null;
}
XDebugSession session = XDebuggerManager.getInstance(myProject).getCurrentSession();
if (session == null) {
FILE_PROCESSED_KEY.set(file, null);
return null;
}
XSourcePosition position = session.getCurrentPosition();
if (position == null || !file.equals(position.getFile())) {
FILE_PROCESSED_KEY.set(file, null);
return null;
}
final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
if (psiFile == null)
return null;
if (!(psiFile instanceof PsiJavaFile))
return null;
PsiClass[] classes = ((PsiJavaFile) psiFile).getClasses();
if (classes.length == 0)
return null;
PsiClass baseClass = classes[0];
String name = baseClass.getQualifiedName();
if (name == null)
return null;
if (DumbService.getInstance(myProject).isDumb())
return null;
ArrayList<PsiClass> alts = ContainerUtil.newArrayList(JavaPsiFacade.getInstance(myProject).findClasses(name, GlobalSearchScope.allScope(myProject)));
ContainerUtil.removeDuplicates(alts);
FILE_PROCESSED_KEY.set(file, true);
if (alts.size() > 1) {
for (PsiClass cls : alts) {
if (cls.equals(baseClass) || cls.getNavigationElement().equals(baseClass)) {
alts.remove(cls);
break;
}
}
alts.add(0, baseClass);
ComboBoxClassElement[] elems = ContainerUtil.map2Array(alts, ComboBoxClassElement.class, psiClass -> new ComboBoxClassElement((PsiClass) psiClass.getNavigationElement()));
String locationDeclName = null;
XStackFrame frame = session.getCurrentStackFrame();
if (frame instanceof JavaStackFrame) {
Location location = ((JavaStackFrame) frame).getDescriptor().getLocation();
if (location != null) {
locationDeclName = location.declaringType().name();
}
}
return new AlternativeSourceNotificationPanel(elems, baseClass, myProject, file, locationDeclName);
}
return null;
}
use of com.intellij.xdebugger.XSourcePosition in project intellij-community by JetBrains.
the class BreakpointWithHighlighter method isAt.
public boolean isAt(@NotNull Document document, int offset) {
final VirtualFile file = FileDocumentManager.getInstance().getFile(document);
int line = document.getLineNumber(offset);
XSourcePosition position = myXBreakpoint.getSourcePosition();
return position != null && position.getLine() == line && position.getFile().equals(file);
}
use of com.intellij.xdebugger.XSourcePosition in project intellij-elixir by KronicDeth.
the class ElixirSourcePosition method create.
@Nullable
public static ElixirSourcePosition create(@NotNull String filePath, int line) {
VirtualFile file = LocalFileSystem.getInstance().findFileByPath(filePath);
XSourcePosition sourcePosition = XDebuggerUtil.getInstance().createPosition(file, line);
if (sourcePosition != null) {
return new ElixirSourcePosition(sourcePosition);
} else {
return null;
}
}
Aggregations