use of com.jetbrains.lang.dart.analyzer.DartServerData.DartNavigationRegion in project intellij-plugins by JetBrains.
the class DartCalleeTreeStructure method getRegionAt.
@NotNull
private static List<DartNavigationTarget> getRegionAt(int offset, @NotNull List<DartNavigationRegion> regions) {
for (DartNavigationRegion region : regions) {
int targetStart = region.getOffset();
int targetEnd = targetStart + region.getLength();
if (offset >= targetStart && offset <= targetEnd) {
return region.getTargets();
}
}
return new ArrayList<>(0);
}
use of com.jetbrains.lang.dart.analyzer.DartServerData.DartNavigationRegion in project intellij-plugins by JetBrains.
the class DartResolver method resolve.
@Nullable
@Override
public List<? extends PsiElement> resolve(@NotNull DartReference reference, boolean incompleteCode) {
reference = replaceQualifiedReferenceWithLast(reference);
final PsiFile refPsiFile = reference.getContainingFile();
int refOffset = reference.getTextRange().getStartOffset();
int refLength = reference.getTextRange().getLength();
DartNavigationRegion region = findRegion(refPsiFile, refOffset, refLength);
if (region == null && reference instanceof DartLibraryId) {
// DAS returns the whole "part of foo" as a region, but we have only "foo" as a reference
final PsiElement parent = reference.getParent();
if (parent instanceof DartPartOfStatement) {
refOffset = parent.getTextRange().getStartOffset();
refLength = reference.getTextRange().getEndOffset() - refOffset;
region = findRegion(refPsiFile, refOffset, refLength);
}
}
if (region == null && (reference instanceof DartSuperExpression || reference instanceof DartReferenceExpression)) {
// DAS from SDK 1.13- returns 'super.foo' as a single range; SDK 1.14 returns 'super' and 'foo' separately.
final PsiElement parent = reference.getParent();
if (parent instanceof DartSuperCallOrFieldInitializer) {
final List<DartExpression> expressions = ((DartSuperCallOrFieldInitializer) parent).getExpressionList();
if (expressions.size() == 2 && expressions.get(0) instanceof DartSuperExpression && expressions.get(1) instanceof DartReferenceExpression) {
refOffset = expressions.get(0).getTextRange().getStartOffset();
refLength = expressions.get(1).getTextRange().getEndOffset() - refOffset;
region = findRegion(refPsiFile, refOffset, refLength);
}
}
}
return region != null ? getTargetElements(reference.getProject(), region) : null;
}
Aggregations