本文整理汇总了Java中com.intellij.util.xml.DomElement类的典型用法代码示例。如果您正苦于以下问题:Java DomElement类的具体用法?Java DomElement怎么用?Java DomElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DomElement类属于com.intellij.util.xml包,在下文中一共展示了DomElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: expectDomAttributeValue
import com.intellij.util.xml.DomElement; //导入依赖的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);
}
示例2: localizeModifiers
import com.intellij.util.xml.DomElement; //导入依赖的package包/类
private String localizeModifiers(final DomElement dom) {
if (dom instanceof Modifiers) {
final Modifiers modifiers = (Modifiers) dom;
final List<String> modList = newArrayList();
resolveModifier(modifiers.getDoNotOptimize(), "doNotOptimize", modList);
resolveModifier(modifiers.getEncrypted(), "encrypted", modList);
resolveModifier(modifiers.getInitial(), "initial", modList);
resolveModifier(modifiers.getOptional(), "optional", modList);
resolveModifier(modifiers.getPartOf(), "partOf", modList);
resolveModifier(modifiers.getPrivate(), "private", modList);
resolveModifier(modifiers.getRead(), "read", modList);
resolveModifier(modifiers.getRemovable(), "removable", modList);
resolveModifier(modifiers.getSearch(), "search", modList);
resolveModifier(modifiers.getUnique(), "unique", modList);
resolveModifier(modifiers.getWrite(), "write", modList);
if (!modList.isEmpty()) {
return StringUtils.join(modList, ", ");
}
}
return null;
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:22,代码来源:TSStructureTreeElement.java
示例3: localizeAttribute
import com.intellij.util.xml.DomElement; //导入依赖的package包/类
private String localizeAttribute(final DomElement dom) {
if (dom instanceof Attribute) {
final Attribute attribute = (Attribute) dom;
String value = resolveValue(attribute.getType());
if (value == null) {
return null;
}
if (value.startsWith("localized:")) {
value = value.substring("localized:".length());
}
if (value.startsWith("java.lang.")) {
value = value.substring("java.lang.".length());
}
return value;
}
return null;
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:18,代码来源:TSStructureTreeElement.java
示例4: TSStructureViewTreeModel
import com.intellij.util.xml.DomElement; //导入依赖的package包/类
public TSStructureViewTreeModel(
@NotNull XmlFile file,
@NotNull Function<DomElement, DomService.StructureViewMode> descriptor,
@Nullable Editor editor
) {
super(
file,
DomElementsNavigationManager.getManager(file.getProject())
.getDomElementsNavigateProvider(DomElementsNavigationManager.DEFAULT_PROVIDER_NAME),
descriptor,
editor
);
myNavigationProvider = DomElementsNavigationManager.getManager(file.getProject())
.getDomElementsNavigateProvider(DomElementsNavigationManager.DEFAULT_PROVIDER_NAME);
myDescriptor = descriptor;
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:17,代码来源:TSStructureViewTreeModel.java
示例5: getRoot
import com.intellij.util.xml.DomElement; //导入依赖的package包/类
@Override
@NotNull
public StructureViewTreeElement getRoot() {
XmlFile myFile = getPsiFile();
final DomFileElement<DomElement> fileElement = DomManager.getDomManager(myFile.getProject()).getFileElement(
myFile,
DomElement.class
);
return fileElement == null ?
new XmlFileTreeElement(myFile) :
new TSStructureTreeElement(
fileElement.getRootElement().createStableCopy(),
myDescriptor,
myNavigationProvider
);
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:17,代码来源:TSStructureViewTreeModel.java
示例6: setValue
import com.intellij.util.xml.DomElement; //导入依赖的package包/类
protected void setValue(String value) {
final PsiType type = JvmPsiTypeConverterImpl.convertFromString(value, new AbstractConvertContext() {
@NotNull
public DomElement getInvocationElement() {
return getDomElement();
}
public PsiManager getPsiManager() {
return PsiTypeControl.this.getPsiManager();
}
});
if (type != null) {
value = type.getCanonicalText();
}
super.setValue(value);
}
示例7: loadDomElement
import com.intellij.util.xml.DomElement; //导入依赖的package包/类
@Nullable
public static <T extends DomElement> T loadDomElement(@NotNull final Project project,
@NotNull final VirtualFile file,
@NotNull final Class<T> aClass) {
return ApplicationManager.getApplication().runReadAction(new Computable<T>() {
@Override
@Nullable
public T compute() {
if (project.isDisposed()) return null;
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile instanceof XmlFile) {
return loadDomElementWithReadPermission(project, (XmlFile)psiFile, aClass);
}
else {
return null;
}
}
});
}
示例8: handleInsert
import com.intellij.util.xml.DomElement; //导入依赖的package包/类
@Override
public void handleInsert(final InsertionContext context, LookupElement item) {
if (TemplateManager.getInstance(context.getProject()).getActiveTemplate(context.getEditor()) != null) {
return; // Don't brake the template.
}
context.commitDocument();
XmlFile xmlFile = (XmlFile)context.getFile();
PsiElement element = xmlFile.findElementAt(context.getStartOffset());
XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
if (tag == null) return;
XmlTag dependencyTag = tag.getParentTag();
DomElement domElement = DomManager.getDomManager(context.getProject()).getDomElement(dependencyTag);
if (!(domElement instanceof MavenDomDependency)) return;
MavenDomDependency dependency = (MavenDomDependency)domElement;
String artifactId = dependency.getArtifactId().getStringValue();
if (StringUtil.isEmpty(artifactId)) return;
MavenDependencyCompletionUtil.addTypeAndClassifierAndVersion(context, dependency, item.getLookupString(), artifactId);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:MavenArtifactCoordinatesGroupIdConverter.java
示例9: registerPluginParameter
import com.intellij.util.xml.DomElement; //导入依赖的package包/类
private static void registerPluginParameter(boolean isInPluginManagement, DomExtensionsRegistrar r, final ParameterData data, final String parameterName) {
DomExtension e = r.registerFixedNumberChildExtension(new XmlName(parameterName), MavenDomConfigurationParameter.class);
if (isCollection(data.parameter)) {
e.addExtender(new DomExtender() {
public void registerExtensions(@NotNull DomElement domElement, @NotNull DomExtensionsRegistrar registrar) {
for (String each : collectPossibleNameForCollectionParameter(parameterName)) {
DomExtension inner = registrar.registerCollectionChildrenExtension(new XmlName(each), MavenDomConfigurationParameter.class);
inner.setDeclaringElement(data.parameter);
}
}
});
}
else {
addValueConverter(e, data.parameter);
if (!isInPluginManagement) {
addRequiredAnnotation(e, data);
}
}
e.setDeclaringElement(data.parameter);
data.parameter.getXmlElement().putUserData(PLUGIN_PARAMETER_KEY, data);
}
示例10: getProblemHolder
import com.intellij.util.xml.DomElement; //导入依赖的package包/类
@Override
@NotNull
public DomElementsProblemsHolder getProblemHolder(DomElement element) {
if (element == null || !element.isValid()) return EMPTY_PROBLEMS_HOLDER;
final DomFileElement<DomElement> fileElement = DomUtil.getFileElement(element);
synchronized (LOCK) {
final XmlTag tag = fileElement.getRootElement().getXmlTag();
if (tag != null) {
final DomElementsProblemsHolder readyHolder = tag.getUserData(DOM_PROBLEM_HOLDER_KEY);
if (readyHolder != null) {
return readyHolder;
}
}
return EMPTY_PROBLEMS_HOLDER;
}
}
示例11: annotateMavenDomPlugin
import com.intellij.util.xml.DomElement; //导入依赖的package包/类
private static void annotateMavenDomPlugin(@NotNull MavenDomPlugin plugin, @NotNull AnnotationHolder holder) {
XmlTag xmlTag = plugin.getArtifactId().getXmlTag();
if (xmlTag == null) return;
DomElement plugins = plugin.getParent();
if (plugins == null) return;
DomElement parent = plugins.getParent();
if (parent instanceof MavenDomPluginManagement) {
annotateMavenDomPluginInManagement(plugin, holder);
return;
}
MavenDomPlugin managingPlugin = MavenDomProjectProcessorUtils.searchManagingPlugin(plugin);
if (managingPlugin != null) {
NavigationGutterIconBuilder<MavenDomPlugin> iconBuilder =
NavigationGutterIconBuilder.create(AllIcons.General.OverridingMethod, PluginConverter.INSTANCE);
iconBuilder.
setTargets(Collections.singletonList(managingPlugin)).
setTooltipText(MavenDomBundle.message("overriden.plugin.title")).
install(holder, xmlTag);
}
}
示例12: navigate
import com.intellij.util.xml.DomElement; //导入依赖的package包/类
public void navigate(final DomElement element) {
if (element != null && element.isValid()) {
final DomElement copy = element.createStableCopy();
final Project project = element.getManager().getProject();
final DomElementNavigationProvider navigateProvider = getNavigationProviderName(project);
if (navigateProvider != null && navigateProvider.canNavigate(copy)) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (!project.isDisposed()) {
doNavigate(navigateProvider, copy);
}
}
});
}
}
}
示例13: setupErrorOutdatingUserActivityWatcher
import com.intellij.util.xml.DomElement; //导入依赖的package包/类
@Override
public void setupErrorOutdatingUserActivityWatcher(final CommittablePanel panel, final DomElement... elements) {
final UserActivityWatcher userActivityWatcher = createEditorAwareUserActivityWatcher();
userActivityWatcher.addUserActivityListener(new UserActivityListener() {
private boolean isProcessingChange;
@Override
public void stateChanged() {
if (isProcessingChange) return;
isProcessingChange = true;
try {
for (final DomElement element : elements) {
DomElementAnnotationsManagerImpl.outdateProblemHolder(element);
}
CommittableUtil.updateHighlighting(panel);
}
finally {
isProcessingChange = false;
}
}
}, panel);
userActivityWatcher.register(panel.getComponent());
}
示例14: createPathStableCopy
import com.intellij.util.xml.DomElement; //导入依赖的package包/类
@Override
public DomElement createPathStableCopy() {
final AbstractDomChildDescriptionImpl description = getChildDescription();
final DomElement parent = getParent();
assert parent != null;
final DomElement parentCopy = parent.createStableCopy();
final int index = description.getValues(parent).indexOf(getProxy());
return getManager().createStableValue(new Factory<DomElement>() {
@Override
@Nullable
public DomElement create() {
if (parentCopy.isValid()) {
final List<? extends DomElement> list = description.getValues(parentCopy);
if (list.size() > index) {
return list.get(index);
}
}
return null;
}
});
}
示例15: addAndroidPrefixElement
import com.intellij.util.xml.DomElement; //导入依赖的package包/类
private static void addAndroidPrefixElement(PsiElement position, PsiElement parent, CompletionResultSet resultSet) {
if (position.getText().startsWith("android:")) {
return;
}
final PsiElement gp = parent.getParent();
if (!(gp instanceof XmlTag)) {
return;
}
final DomElement element = DomManager.getDomManager(gp.getProject()).getDomElement((XmlTag)gp);
if (!(element instanceof LayoutElement) &&
!(element instanceof PreferenceElement)) {
return;
}
final String prefix = ((XmlTag)gp).getPrefixByNamespace(SdkConstants.NS_RESOURCES);
if (prefix == null || prefix.length() < 3) {
return;
}
final LookupElementBuilder e = LookupElementBuilder.create(prefix + ":").withTypeText("[Namespace Prefix]", true);
resultSet.addElement(PrioritizedLookupElement.withPriority(e, Double.MAX_VALUE));
}