use of com.jetbrains.lang.dart.psi.DartComponentName in project intellij-plugins by JetBrains.
the class DartServerOverrideMarkerProvider method tryCreateOverrideMarker.
@Nullable
private static LineMarkerInfo tryCreateOverrideMarker(@NotNull final DartComponentName componentName, @Nullable final DartComponent superclassComponent, @NotNull final List<DartComponent> interfaceComponents) {
if (superclassComponent == null && interfaceComponents.isEmpty()) {
return null;
}
final String name = componentName.getName();
final boolean overrides;
final DartComponent superComponent;
if (superclassComponent != null) {
overrides = true;
superComponent = superclassComponent;
} else {
overrides = false;
superComponent = interfaceComponents.iterator().next();
}
final Icon icon = overrides ? AllIcons.Gutter.OverridingMethod : AllIcons.Gutter.ImplementingMethod;
return new LineMarkerInfo<>(componentName, componentName.getTextRange(), icon, Pass.LINE_MARKERS, element -> {
final DartClass superClass = PsiTreeUtil.getParentOfType(superComponent, DartClass.class);
if (superClass == null)
return "null";
if (overrides) {
return DartBundle.message(superclassComponent.isOperator() ? "overrides.operator.in" : "overrides.method.in", name, superClass.getName());
}
return DartBundle.message("implements.method.in", name, superClass.getName());
}, (GutterIconNavigationHandler<PsiElement>) (e, elt) -> {
List<DartComponent> superComponents = Lists.newArrayList();
if (superclassComponent != null) {
superComponents.add(superclassComponent);
}
superComponents.addAll(interfaceComponents);
PsiElementListNavigator.openTargets(e, DartResolveUtil.getComponentNameArray(superComponents), DaemonBundle.message("navigation.title.super.method", name), DaemonBundle.message("navigation.findUsages.title.super.method", name), new DefaultPsiElementCellRenderer());
}, GutterIconRenderer.Alignment.LEFT);
}
use of com.jetbrains.lang.dart.psi.DartComponentName in project intellij-plugins by JetBrains.
the class DartCalleeTreeStructure method getCallees.
private static void getCallees(@NotNull PsiElement element, @NotNull List<PsiElement> results) {
DartComponentName name = (DartComponentName) element;
DartComponent decl = (DartComponent) name.getParent();
PsiFile file = decl.getContainingFile();
if (file == null)
return;
VirtualFile vFile = file.getVirtualFile();
List<DartNavigationRegion> navRegions = DartAnalysisServerService.getInstance(element.getProject()).analysis_getNavigation(vFile, decl.getTextOffset(), decl.getTextLength());
if (navRegions == null)
return;
resolveReferences(decl, navRegions, results);
}
use of com.jetbrains.lang.dart.psi.DartComponentName in project intellij-plugins by JetBrains.
the class DartFilterByClassMacro method calculateResult.
@Override
public Result calculateResult(@NotNull Expression[] params, ExpressionContext context) {
final PsiElement at = context.getPsiElementAtStartOffset();
final Set<DartComponentName> variables = DartRefactoringUtil.collectUsedComponents(at);
final List<DartComponentName> filtered = ContainerUtil.filter(variables, name -> {
final PsiElement nameParent = name.getParent();
if (nameParent instanceof DartClass) {
return false;
}
final DartClassResolveResult result = DartResolveUtil.getDartClassResolveResult(nameParent);
final DartClass dartClass = result.getDartClass();
return dartClass != null && filter(dartClass);
});
return filtered.isEmpty() ? null : new PsiElementResult(filtered.iterator().next());
}
use of com.jetbrains.lang.dart.psi.DartComponentName in project intellij-plugins by JetBrains.
the class DartSymbolContributor method getItemsByName.
@NotNull
@Override
public NavigationItem[] getItemsByName(@NotNull final String name, @NotNull final String pattern, @NotNull final Project project, final boolean includeNonProjectItems) {
final GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project);
final Collection<DartComponentName> result = DartSymbolIndex.getItemsByName(name, project, scope);
return result.toArray(new NavigationItem[result.size()]);
}
use of com.jetbrains.lang.dart.psi.DartComponentName in project intellij-plugins by JetBrains.
the class DartInheritorsSearcher method prepare.
private static void prepare(@NotNull final DefinitionsScopedSearch.SearchParameters parameters, @NotNull final Ref<VirtualFile> fileRef, @NotNull final Ref<Integer> offsetRef, @NotNull final Ref<DartComponentType> componentTypeRef) {
ApplicationManager.getApplication().runReadAction(() -> {
final PsiElement element = parameters.getElement();
if (element.getLanguage() != DartLanguage.INSTANCE)
return;
final DartComponentType componentType = DartComponentType.typeOf(element);
if (componentType != DartComponentType.CLASS && componentType != DartComponentType.METHOD && componentType != DartComponentType.OPERATOR) {
return;
}
final DartComponentName componentName = element instanceof DartComponentName ? (DartComponentName) element : element instanceof DartComponent ? ((DartComponent) element).getComponentName() : null;
final VirtualFile file = componentName == null ? null : DartResolveUtil.getRealVirtualFile(componentName.getContainingFile());
if (file != null) {
fileRef.set(file);
offsetRef.set(componentName.getTextRange().getStartOffset());
componentTypeRef.set(componentType);
}
});
}
Aggregations