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; }
@Override @NotNull public StructureView createStructureView(final FileEditor fileEditor, @NotNull final Project project) { return new StructureViewComponent(fileEditor, createStructureViewModel(fileEditor instanceof TextEditor ? ((TextEditor)fileEditor).getEditor() : null), project, true) { @Override public AsyncResult<AbstractTreeNode> expandPathToElement(final Object element) { if (element instanceof XmlElement && ((XmlElement)element).isValid()) { final XmlElement xmlElement = (XmlElement)element; XmlTag tag = PsiTreeUtil.getParentOfType(xmlElement, XmlTag.class, false); while (tag != null) { final DomElement domElement = DomManager.getDomManager(xmlElement.getProject()).getDomElement(tag); if (domElement != null) { for (DomElement curElement = domElement; curElement != null; curElement = curElement.getParent()) { if (myDescriptor.fun(curElement) == DomService.StructureViewMode.SHOW) { return super.expandPathToElement(curElement.getXmlElement()); } } } tag = PsiTreeUtil.getParentOfType(tag, XmlTag.class, true); } } return super.expandPathToElement(element); } }; }
private static void findExtensionPointCandidates(PsiClass psiClass, final List<ExtensionPointCandidate> list) { String name = psiClass.getQualifiedName(); if (name == null) { return; } final Project project = psiClass.getProject(); final Collection<VirtualFile> candidates = DomService.getInstance().getDomFileCandidates(IdeaPlugin.class, project, GlobalSearchScope.allScope(project)); GlobalSearchScope scope = GlobalSearchScope.filesScope(project, candidates); PsiSearchHelper.SERVICE.getInstance(project).processUsagesInNonJavaFiles(name, new PsiNonJavaFileReferenceProcessor() { @Override public boolean process(PsiFile file, int startOffset, int endOffset) { PsiElement element = file.findElementAt(startOffset); processExtensionPointCandidate(element, list); return true; } }, scope); }
@Override @NotNull public StructureView createStructureView(final FileEditor fileEditor, final Project project) { return new StructureViewComponent(fileEditor, createStructureViewModel(fileEditor instanceof TextEditor ? ((TextEditor)fileEditor).getEditor() : null), project) { @Override public AsyncResult<AbstractTreeNode> expandPathToElement(final Object element) { if (element instanceof XmlElement) { final XmlElement xmlElement = (XmlElement)element; XmlTag tag = PsiTreeUtil.getParentOfType(xmlElement, XmlTag.class, false); while (tag != null) { final DomElement domElement = DomManager.getDomManager(xmlElement.getProject()).getDomElement(tag); if (domElement != null) { for (DomElement curElement = domElement; curElement != null; curElement = curElement.getParent()) { if (myDescriptor.fun(curElement) == DomService.StructureViewMode.SHOW) { return super.expandPathToElement(curElement.getXmlElement()); } } } tag = PsiTreeUtil.getParentOfType(tag, XmlTag.class, true); } } return super.expandPathToElement(element); } }; }
public <T extends DomElement> TSStructureTreeElement( final T stableCopy, final Function<DomElement, DomService.StructureViewMode> myDescriptor, final DomElementNavigationProvider myNavigationProvider ) { super(stableCopy, myDescriptor, myNavigationProvider); this.myDescriptor = myDescriptor; this.myNavigationProvider = myNavigationProvider; }
public TSStructureViewBuilder( final XmlFile file, final Function<DomElement, DomService.StructureViewMode> descriptor ) { super(file, descriptor); myFile = file; myDescriptor = descriptor; }
@Nullable @Override public StructureViewBuilder createStructureViewBuilder(@NotNull final XmlFile xmlFile) { if (!TypeSystemUtils.isTypeSystemXmlFile(xmlFile)) { return null; } return new TSStructureViewBuilder(xmlFile, (dom) -> { if (dom instanceof Attributes) { return DomService.StructureViewMode.SHOW_CHILDREN; } return DomService.StructureViewMode.SHOW; }); }
public TSMetaClassImpl( final @NotNull TSMetaModelImpl model, final @NotNull String name, final @NotNull ItemType dom ) { super(name, dom); myMetaModel = model; myAllDoms.add(DomService.getInstance().createAnchor(dom)); registerExtends(dom); }
public ReferenceEndImpl( final @NotNull TSMetaModelImpl metaModel, final @NotNull TSMetaReference owner, final @NotNull RelationElement dom ) { myOwner = owner; myMetaModel = metaModel; myDomAnchor = DomService.getInstance().createAnchor(dom); myTypeName = StringUtil.notNullize(dom.getType().getStringValue()); myRole = StringUtil.notNullize(dom.getQualifier().getStringValue()); myNavigatable = Optional.ofNullable(dom.getNavigable().getValue()).orElse(true); }
@NotNull public static Collection<IdeaPlugin> getPlugins(Project project, GlobalSearchScope scope) { if (DumbService.isDumb(project)) return Collections.emptyList(); List<DomFileElement<IdeaPlugin>> files = DomService.getInstance().getFileElements(IdeaPlugin.class, project, scope); return ContainerUtil.map(files, new Function<DomFileElement<IdeaPlugin>, IdeaPlugin>() { public IdeaPlugin fun(DomFileElement<IdeaPlugin> ideaPluginDomFileElement) { return ideaPluginDomFileElement.getRootElement(); } }); }
public static Collection<IdeaPlugin> getAllPlugins(final Project project) { if (DumbService.isDumb(project)) return Collections.emptyList(); GlobalSearchScope scope = GlobalSearchScopesCore.projectProductionScope(project); List<DomFileElement<IdeaPlugin>> files = DomService.getInstance().getFileElements(IdeaPlugin.class, project, scope); return ContainerUtil.map(files, new Function<DomFileElement<IdeaPlugin>, IdeaPlugin>() { public IdeaPlugin fun(DomFileElement<IdeaPlugin> ideaPluginDomFileElement) { return ideaPluginDomFileElement.getRootElement(); } }); }
@Override @NonNls public String getName(final PsiElement context) { final String name = getDefaultName(); if(context instanceof XmlTag) { XmlTag tag = (XmlTag) context; final PsiFile file = tag.getContainingFile(); DomElement element = myManager.getDomElement(tag); if(element == null && tag.getParentTag() != null) { element = myManager.getDomElement(tag.getParentTag()); } if(element != null && file instanceof XmlFile && !(myChildrenDescription instanceof MyRootDomChildrenDescription)) { final String namespace = DomService.getInstance().getEvaluatedXmlName(element).evaluateChildName(myChildrenDescription.getXmlName()).getNamespace(tag, (XmlFile) file); if(!tag.getNamespaceByPrefix("").equals(namespace)) { final String s = tag.getPrefixByNamespace(namespace); if(StringUtil.isNotEmpty(s)) { return s + ":" + name; } } } } return name; }
public DomStructureViewTreeModel( @NotNull XmlFile file, @NotNull Function<DomElement, DomService.StructureViewMode> descriptor, @Nullable Editor editor) { this(file, DomElementsNavigationManager.getManager(file.getProject()).getDomElementsNavigateProvider(DomElementsNavigationManager .DEFAULT_PROVIDER_NAME), descriptor, editor); }
public DomStructureViewTreeModel( @NotNull XmlFile file, final DomElementNavigationProvider navigationProvider, @NotNull Function<DomElement, DomService.StructureViewMode> descriptor, @Nullable Editor editor) { super(file, editor); myNavigationProvider = navigationProvider; myDescriptor = descriptor; }
@Override @NotNull public StructureView createStructureView(final FileEditor fileEditor, @NotNull final Project project) { return new StructureViewComponent(fileEditor, createStructureViewModel(fileEditor instanceof TextEditor ? ((TextEditor) fileEditor) .getEditor() : null), project, true) { @Override public AsyncResult<AbstractTreeNode> expandPathToElement(final Object element) { if(element instanceof XmlElement && ((XmlElement) element).isValid()) { final XmlElement xmlElement = (XmlElement) element; XmlTag tag = PsiTreeUtil.getParentOfType(xmlElement, XmlTag.class, false); while(tag != null) { final DomElement domElement = DomManager.getDomManager(xmlElement.getProject()).getDomElement(tag); if(domElement != null) { for(DomElement curElement = domElement; curElement != null; curElement = curElement.getParent()) { if(myDescriptor.fun(curElement) == DomService.StructureViewMode.SHOW) { return super.expandPathToElement(curElement.getXmlElement()); } } } tag = PsiTreeUtil.getParentOfType(tag, XmlTag.class, true); } } return super.expandPathToElement(element); } }; }
public void addDomRepresentation(final @NotNull ItemType anotherDom) { myAllDoms.add(DomService.getInstance().createAnchor(anotherDom)); registerExtends(anotherDom); }
public TSMetaEntityImpl(final String name, final D dom) { myDomAnchor = DomService.getInstance().createAnchor(dom); myName = name; }
@Override public DomService.StructureViewMode fun(DomElement element) { return DomService.StructureViewMode.SHOW; }
public DomStructureViewBuilder(final XmlFile file, final Function<DomElement,DomService.StructureViewMode> descriptor) { myFile = file; myDescriptor = descriptor; }
public DomStructureViewBuilder(final XmlFile file, final Function<DomElement, DomService.StructureViewMode> descriptor) { myFile = file; myDescriptor = descriptor; }
@Override public Stub buildStubTree(FileContent fileContent) { VirtualFile file = fileContent.getFile(); Project project = fileContent.getProject(); PsiFile psiFile = PsiManager.getInstance(project).findFile(file); if(!(psiFile instanceof XmlFile)) { return null; } XmlFile xmlFile = (XmlFile) psiFile; try { XmlUtil.BUILDING_DOM_STUBS.set(Boolean.TRUE); psiFile.putUserData(CONTENT_FOR_DOM_STUBS, fileContent); DomFileElement<? extends DomElement> fileElement = DomManager.getDomManager(project).getFileElement(xmlFile); if(fileElement == null || !fileElement.getFileDescription().hasStubs()) { return null; } XmlFileHeader header = DomService.getInstance().getXmlFileHeader(xmlFile); if(header.getRootTagLocalName() == null) { LOG.error("null root tag for " + fileElement + " for " + file); } FileStub fileStub = new FileStub(header); XmlTag rootTag = xmlFile.getRootTag(); if(rootTag != null) { new DomStubBuilderVisitor(DomManagerImpl.getDomManager(project)).visitXmlElement(rootTag, fileStub, 0); } return fileStub; } finally { XmlUtil.BUILDING_DOM_STUBS.set(Boolean.FALSE); psiFile.putUserData(CONTENT_FOR_DOM_STUBS, null); } }
public FileDescriptionCachedValueProvider(final DomManagerImpl domManager, final XmlFile xmlFile) { myDomManager = domManager; myXmlFile = xmlFile; myDomService = DomService.getInstance(); }
protected BaseDomModelFactory(@NotNull Class<T> aClass, final Project project, @NonNls String name) { super(aClass, DomService.getInstance().createModelMerger()); myProject = project; mySimpleDomModelFactory = createSimpleModelFactory(aClass, getModelMerger(), project, name); myMultipleDomModelFactory = createMultipleDomModelFactory(aClass, getModelMerger(), project, name); }