use of com.intellij.psi.xml.XmlToken in project intellij-plugins by JetBrains.
the class AngularJSXmlCompletionContributor method fillCompletionVariants.
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
final PsiElement originalPosition = parameters.getOriginalPosition();
if (originalPosition != null && AngularIndexUtil.hasAngularJS(originalPosition.getProject())) {
final PsiElement position = originalPosition instanceof XmlToken ? originalPosition.getParent() : originalPosition;
if (AngularJSReferencesContributor.NG_APP_REF.accepts(position)) {
final Collection<String> keys = AngularIndexUtil.getAllKeys(AngularModuleIndex.KEY, originalPosition.getProject());
addCompletionVariants(result, keys, " (AngularJS module)");
result.stopHere();
} else if (AngularJSReferencesContributor.UI_VIEW_REF.accepts(position)) {
final Collection<String> keys = AngularIndexUtil.getAllKeys(AngularUiRouterStatesIndex.KEY, originalPosition.getProject());
addCompletionVariants(result, keys, " (angular-ui-router state)");
result.stopHere();
}
}
}
use of com.intellij.psi.xml.XmlToken in project android by JetBrains.
the class AndroidInlineLayoutHandler method getLayoutUsageDataFromContext.
@Nullable
private static LayoutUsageData getLayoutUsageDataFromContext(Editor editor) {
if (editor == null) {
return null;
}
final PsiElement element = PsiUtilBase.getElementAtCaret(editor);
if (!(element instanceof XmlToken) || AndroidFacet.getInstance(element) == null) {
return null;
}
final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
return tag != null ? AndroidInlineUtil.getLayoutUsageData(tag) : null;
}
use of com.intellij.psi.xml.XmlToken in project intellij-plugins by JetBrains.
the class XmlBackedClassLineMarkerProvider method collectSlowLineMarkers.
public void collectSlowLineMarkers(@NotNull List<PsiElement> elements, @NotNull Collection<LineMarkerInfo> result) {
for (PsiElement element : elements) {
ProgressManager.checkCanceled();
if (element instanceof XmlTag && element.getParent() instanceof XmlDocument && element.getContainingFile() != null && JavaScriptSupportLoader.isFlexMxmFile(element.getContainingFile())) {
final XmlBackedJSClass clazz = XmlBackedJSClassFactory.getInstance().getXmlBackedClass((XmlTag) element);
Query<JSClass> classQuery = JSClassSearch.searchClassInheritors(clazz, true);
XmlToken nameElement = XmlTagUtil.getStartTagNameElement((XmlTag) element);
if (classQuery.findFirst() != null && nameElement != null) {
result.add(new LineMarkerInfo<>(clazz, nameElement.getTextRange(), AllIcons.Gutter.OverridenMethod, Pass.LINE_MARKERS, JavaScriptLineMarkerProvider.ourClassInheritorsTooltipProvider, JavaScriptLineMarkerProvider.ourClassInheritorsNavHandler, GutterIconRenderer.Alignment.RIGHT));
}
}
}
}
use of com.intellij.psi.xml.XmlToken in project intellij-plugins by JetBrains.
the class ActionScriptTypeEvaluator method addTypeFromElementResolveResult.
@Override
protected boolean addTypeFromElementResolveResult(PsiElement resolveResult, boolean hasSomeType) {
if (resolveResult instanceof JSOffsetBasedImplicitElement && JavaScriptSupportLoader.isFlexMxmFile(resolveResult.getContainingFile())) {
resolveResult = ((JSOffsetBasedImplicitElement) resolveResult).getElementAtOffset();
}
if (resolveResult instanceof XmlToken) {
final XmlToken xmlToken = (XmlToken) resolveResult;
final XmlAttribute xmlAttribute = PsiTreeUtil.getParentOfType(xmlToken, XmlAttribute.class);
final XmlTag xmlTag = PsiTreeUtil.getParentOfType(xmlToken, XmlTag.class);
if (xmlToken.getTokenType() == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN && xmlAttribute != null && "id".equals(xmlAttribute.getName()) && xmlTag != null && isInsideRepeaterTag(xmlTag)) {
final PsiElement arrayClass = ActionScriptClassResolver.findClassByQNameStatic(ARRAY_CLASS_NAME, xmlToken);
if (arrayClass != null) {
final String arrayType = new JSTagContextBuilder(resolveResult, null).typeName;
JSTypeSource source = JSTypeSourceFactory.createTypeSource(resolveResult);
JSType type;
if (arrayType != null) {
JSType baseType = JSNamedType.createType(arrayType, source, JSContext.INSTANCE);
type = new JSArrayTypeImpl(baseType, source);
} else {
type = new JSPrimitiveArrayType(source, JSTypeContext.INSTANCE);
}
addType(type, arrayClass);
}
} else {
final XmlTag tag = PsiTreeUtil.getParentOfType(resolveResult, XmlTag.class, false);
final JSClass clazz = JSResolveUtil.getClassFromTagNameInMxml(tag);
if (clazz != null) {
final String name = clazz.getQualifiedName();
if (name != null) {
addType(name, clazz);
}
}
}
return hasSomeType;
}
return super.addTypeFromElementResolveResult(resolveResult, hasSomeType);
}
use of com.intellij.psi.xml.XmlToken in project intellij-community by JetBrains.
the class JavaFxCollapseSubTagToAttributeIntention method isAvailable.
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
if (element instanceof XmlToken && ((XmlToken) element).getTokenType() == XmlTokenType.XML_NAME && element.getParent() instanceof XmlTag) {
final XmlTag tag = (XmlTag) element.getParent();
for (XmlTag xmlTag : tag.getSubTags()) {
if (xmlTag.getAttribute(FxmlConstants.FX_VALUE) == null)
return false;
}
final XmlTag parentTag = tag.getParentTag();
if (parentTag != null && tag.getDescriptor() instanceof JavaFxPropertyTagDescriptor && parentTag.getDescriptor() instanceof JavaFxClassTagDescriptorBase) {
setText("Collapse tag '" + tag.getName() + "' to attribute");
return true;
}
}
return false;
}
Aggregations