本文整理汇总了Java中com.intellij.psi.xml.XmlElement类的典型用法代码示例。如果您正苦于以下问题:Java XmlElement类的具体用法?Java XmlElement怎么用?Java XmlElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XmlElement类属于com.intellij.psi.xml包,在下文中一共展示了XmlElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCompletions
import com.intellij.psi.xml.XmlElement; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition().getOriginalElement();
if (position == null || !(position instanceof XmlElement)) {
return;
}
DiIndex diIndex = DiIndex.getInstance(position.getProject());
PhpClass phpClass = diIndex.getPhpClassOfArgument((XmlElement) position);
if (phpClass != null) {
Method constructor = phpClass.getConstructor();
if (constructor != null) {
for (Parameter parameter : constructor.getParameters()) {
result.addElement(
LookupElementBuilder
.create(parameter.getName())
.withIcon(parameter.getIcon())
);
}
}
}
}
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:26,代码来源:PhpConstructorArgumentCompletionProvider.java
示例2: addCompletions
import com.intellij.psi.xml.XmlElement; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition().getOriginalElement();
if (position == null) {
return;
}
PhpClass phpClass = DiIndex.getPhpClassOfServiceMethod((XmlElement) position);
if (phpClass != null) {
for (Method method : phpClass.getMethods()) {
result.addElement(
LookupElementBuilder
.create(method.getName())
.withIcon(method.getIcon())
);
}
}
}
示例3: getReferencesByElement
import com.intellij.psi.xml.XmlElement; //导入依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
if (!(element instanceof XmlElement)) {
return PsiReference.EMPTY_ARRAY;
}
List<PsiReference> psiReferences = new ArrayList<>();
String methodName = StringUtil.unquoteString(element.getText());
PhpClass phpClass = DiIndex.getPhpClassOfServiceMethod((XmlElement) element);
if (phpClass != null) {
Collection<Method> methods = phpClass.getMethods();
methods.removeIf(m -> !m.getName().equalsIgnoreCase(methodName));
psiReferences.add(new PolyVariantReferenceBase(element, methods));
}
return psiReferences.toArray(new PsiReference[psiReferences.size()]);
}
示例4: getReferencesByElement
import com.intellij.psi.xml.XmlElement; //导入依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
String parameterName = StringUtil.unquoteString(element.getText());
if (parameterName.isEmpty() || !(element instanceof XmlElement)) {
return PsiReference.EMPTY_ARRAY;
}
DiIndex diIndex = DiIndex.getInstance(element.getProject());
PhpClass phpClass = diIndex.getPhpClassOfArgument((XmlElement) element);
if (phpClass != null) {
Method constructor = phpClass.getConstructor();
if (constructor != null) {
Collection<Parameter> parameterList = new THashSet<>(Arrays.asList(constructor.getParameters()));
parameterList.removeIf(p -> !p.getName().contains(parameterName));
if (parameterList.size() > 0) {
return new PsiReference[] {new PolyVariantReferenceBase(element, parameterList)};
}
}
}
return PsiReference.EMPTY_ARRAY;
}
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:26,代码来源:PhpConstructorArgumentReferenceProvider.java
示例5: expectDomAttributeValue
import com.intellij.psi.xml.XmlElement; //导入依赖的package包/类
public static <T extends DomElement, V> GenericAttributeValue<V> expectDomAttributeValue(
@NotNull final PsiElement element,
@NotNull final Class<? extends T> domTagClass,
@NotNull final Function<T, GenericAttributeValue<V>> domGetter
) {
final DomManager domManager = DomManager.getDomManager(element.getProject());
if (!(element instanceof XmlElement)) {
return null;
}
final XmlAttribute xmlAttribute = PsiTreeUtil.getParentOfType(element, XmlAttribute.class, false);
if (xmlAttribute == null) {
return null;
}
final XmlTag xmlParentTag = PsiTreeUtil.getParentOfType(element, XmlTag.class, false);
DomElement domParentTag = domManager.getDomElement(xmlParentTag);
return Optional.ofNullable(domParentTag)
.map(o -> ObjectUtils.tryCast(o, domTagClass))
.map(domGetter)
.filter(val -> val == domManager.getDomElement(xmlAttribute))
.orElse(null);
}
示例6: createTargetsWithGutterIcon
import com.intellij.psi.xml.XmlElement; //导入依赖的package包/类
private void createTargetsWithGutterIcon(
final Collection<? super RelatedItemLineMarkerInfo> result,
final PsiClass psiClass,
final Collection<XmlElement> list
) {
final NavigationGutterIconBuilder builder
= NavigationGutterIconBuilder.create(HybrisIcons.TYPE_SYSTEM).setTargets(list);
builder.setEmptyPopupText(HybrisI18NBundleUtils.message(
"hybris.gutter.navigate.no.matching.beans",
new Object[0]
));
builder.setPopupTitle(HybrisI18NBundleUtils.message(
"hybris.bean.class.navigate.choose.class.title",
new Object[0]
));
builder.setTooltipText(HybrisI18NBundleUtils.message(
"hybris.item.class.tooltip.navigate.declaration", new Object[0]
));
result.add(builder.createLineMarkerInfo(psiClass.getNameIdentifier()));
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:23,代码来源:HybrisItemLineMakerProvider.java
示例7: findAlternativeDoms
import com.intellij.psi.xml.XmlElement; //导入依赖的package包/类
private static Collection<XmlAttributeValue> findAlternativeDoms(@NotNull final ItemType source) {
final String code = source.getCode().getStringValue();
if (StringUtil.isEmpty(code)) {
return Collections.emptyList();
}
final XmlElement element = source.getXmlElement();
final PsiFile psiFile = element == null ? null : element.getContainingFile();
if (psiFile == null) {
return Collections.emptyList();
}
final TSMetaModel externalModel = TSMetaModelAccess.getInstance(psiFile.getProject()).
getExternalTypeSystemMeta(psiFile);
return Optional.ofNullable(externalModel.findMetaClassForDom(source))
.map(TSMetaClass::retrieveAllDomsStream)
.orElse(Stream.empty())
.filter(dom -> !dom.equals(source))
.map(ItemType::getCode)
.map(GenericAttributeValue::getXmlAttributeValue)
.collect(Collectors.toList());
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:24,代码来源:TypeSystemGutterAnnotator.java
示例8: getExtendingMetaClassNamesStream
import com.intellij.psi.xml.XmlElement; //导入依赖的package包/类
@NotNull
private static Stream<TSMetaClass> getExtendingMetaClassNamesStream(@NotNull final ItemType source) {
final String code = source.getCode().getStringValue();
if (StringUtil.isEmpty(code)) {
return Stream.empty();
}
final XmlElement xmlElement = source.getXmlElement();
final PsiFile psiFile = xmlElement == null ? null : xmlElement.getContainingFile();
if (psiFile == null) {
return Stream.empty();
}
final TSMetaModel metaModel = TSMetaModelAccess.getInstance(psiFile.getProject()).getTypeSystemMeta(psiFile);
final TSMetaClass sourceMeta = metaModel.findMetaClassForDom(source);
if (sourceMeta == null) {
return Stream.empty();
}
return metaModel
.getMetaClassesStream()
.map(TSMetaClass.class::cast)
.filter(meta -> sourceMeta.getName().equals(meta.getExtendedMetaClassName()));
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:25,代码来源:TypeSystemGutterAnnotator.java
示例9: getSelectStatelessComponent
import com.intellij.psi.xml.XmlElement; //导入依赖的package包/类
@Nullable
private JSFunction getSelectStatelessComponent(String selectText, PsiFile file){
return PsiTreeUtil.findChildrenOfType(file, JSFunction.class)
.stream()
.filter(o -> o.getName()!=null && o.getName().equals(selectText))
.filter(o -> {
XmlElement element = PsiTreeUtil.findChildrenOfType(o, XmlElement.class)
.stream()
.findFirst()
.orElse(null);
return element != null;
})
.findFirst()
.orElse(null);
}
示例10: getValueDeclaration
import com.intellij.psi.xml.XmlElement; //导入依赖的package包/类
@Override
public PsiElement getValueDeclaration(XmlElement xmlElement, String value) {
CatberryProjectConfigurationManager configurationManager = CatberryProjectConfigurationManager.getInstance(project);
PsiDirectory directory = configurationManager.getStoresDirectory();
if(directory == null)
return super.getValueDeclaration(xmlElement, value);
final String requiredPath = directory.getVirtualFile().getPath() + "/" + value+".js";
int index = value.lastIndexOf('/');
String className = index == -1 ? value : value.substring(index+1);
Collection<JSElement> elements = StubIndex.getElements(JSClassIndex.KEY, className, project,
GlobalSearchScope.allScope(project), JSElement.class);
for(JSElement element : elements) {
if (element instanceof JSClass && element.getContainingFile().getVirtualFile().getPath().equals(requiredPath))
return element;
}
return super.getValueDeclaration(xmlElement, value);
}
示例11: canSelectBasic
import com.intellij.psi.xml.XmlElement; //导入依赖的package包/类
public static boolean canSelectBasic(final PsiElement e) {
return
!(e instanceof PsiWhiteSpace) &&
!(e instanceof PsiComment) &&
!(e instanceof PsiCodeBlock) &&
!(e instanceof PsiArrayInitializerExpression) &&
!(e instanceof PsiParameterList) &&
!(e instanceof PsiExpressionList) &&
!(e instanceof PsiBlockStatement) &&
!(e instanceof PsiJavaCodeReferenceElement) &&
!(e instanceof PsiJavaToken &&
!(e instanceof PsiKeyword)) &&
!(e instanceof XmlToken) &&
!(e instanceof XmlElement) &&
!(e instanceof PsiDocTag);
}
示例12: inputXPathExpression
import com.intellij.psi.xml.XmlElement; //导入依赖的package包/类
/**
* Opens an input box to input an XPath expression. The box will have a history dropdown from which
* previously entered expressions can be selected.
* @return The expression or <code>null</code> if the user hits the cancel button
* @param project The project to take the history from
*/
@Nullable
private EvalExpressionDialog.Context inputXPathExpression(final Project project, XmlElement contextNode) {
final XPathProjectComponent pc = XPathProjectComponent.getInstance(project);
LOG.assertTrue(pc != null);
// get expression history from project component
final HistoryElement[] history = pc.getHistory();
final EvalExpressionDialog dialog = new EvalExpressionDialog(project, myComponent.getConfig(), history);
if (!dialog.show(contextNode)) {
// cancel
LOG.debug("Input canceled");
return null;
}
final InputExpressionDialog.Context context = dialog.getContext();
LOG.debug("expression = " + context.input.expression);
pc.addHistory(context.input);
return context;
}
示例13: getCollectionIndex
import com.intellij.psi.xml.XmlElement; //导入依赖的package包/类
public static int getCollectionIndex(@NotNull final MavenDomDependencies dependencies, @Nullable final Editor editor) {
if (editor != null) {
int offset = editor.getCaretModel().getOffset();
List<MavenDomDependency> dependencyList = dependencies.getDependencies();
for (int i = 0; i < dependencyList.size(); i++) {
MavenDomDependency dependency = dependencyList.get(i);
XmlElement xmlElement = dependency.getXmlElement();
if (xmlElement != null && xmlElement.getTextRange().getStartOffset() >= offset) {
return i;
}
}
}
return -1;
}
示例14: getPropertyFiles
import com.intellij.psi.xml.XmlElement; //导入依赖的package包/类
@NotNull
private static Collection<PropertiesFile> getPropertyFiles(@Nullable AntDomProject antDomProject, @NotNull XmlElement stopElement) {
if (antDomProject == null) {
return Collections.emptyList();
}
final Set<PropertiesFile> files = new java.util.HashSet<PropertiesFile>();
final int stopOffset = stopElement.getTextOffset();
for (Iterator<AntDomElement> iterator = antDomProject.getAntChildrenIterator(); iterator.hasNext(); ) {
AntDomElement child = iterator.next();
final XmlElement xmlElement = child.getXmlElement();
if (xmlElement != null && xmlElement.getTextOffset() >= stopOffset) {
break; // no need to offer to add properties to files that are imported after the property reference
}
if (child instanceof AntDomProperty) {
final AntDomProperty property = (AntDomProperty)child;
final PropertiesFile file = property.getPropertiesFile();
if (file != null) {
files.add(file);
}
}
}
return files;
}
示例15: processEnumeration
import com.intellij.psi.xml.XmlElement; //导入依赖的package包/类
private boolean processEnumeration(XmlElement context, PairProcessor<PsiElement, String> processor, boolean forCompletion) {
XmlTag contextTag = context != null ? PsiTreeUtil.getContextOfType(context, XmlTag.class, false) : null;
final XmlElementDescriptorImpl elementDescriptor = (XmlElementDescriptorImpl)XmlUtil.findXmlDescriptorByType(getDeclaration(), contextTag);
if (elementDescriptor!=null && elementDescriptor.getType() instanceof ComplexTypeDescriptor) {
return processEnumerationImpl(((ComplexTypeDescriptor)elementDescriptor.getType()).getDeclaration(), processor, forCompletion);
}
final String namespacePrefix = getDeclaration().getNamespacePrefix();
XmlTag type = getDeclaration().findFirstSubTag(
((namespacePrefix.length() > 0) ? namespacePrefix + ":" : "") + "simpleType"
);
if (type != null) {
return processEnumerationImpl(type, processor, forCompletion);
}
return false;
}