use of com.jetbrains.lang.dart.analyzer.DartServerData.DartNavigationTarget in project intellij-plugins by JetBrains.
the class InlineMethodDialog method findContext.
@Nullable
private static InlineRefactoringContext findContext(@Nullable Editor editor) {
if (editor == null) {
return null;
}
// prepare project
final Project project = editor.getProject();
if (project == null) {
return null;
}
// prepare files
final Document document = editor.getDocument();
final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document);
if (psiFile == null) {
return null;
}
final VirtualFile virtualFile = psiFile.getVirtualFile();
// prepare navigation regions
final int offset = editor.getCaretModel().getOffset();
final List<DartNavigationRegion> navigationRegions = DartAnalysisServerService.getInstance(project).getNavigation(virtualFile);
// find the navigation region
for (DartNavigationRegion region : navigationRegions) {
if (region.getOffset() <= offset && offset <= region.getOffset() + region.getLength()) {
final List<DartNavigationTarget> targets = region.getTargets();
final String kind = targets.get(0).getKind();
return new InlineRefactoringContext(virtualFile, offset, kind);
}
}
// fail
return null;
}
Aggregations