use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.
the class NoNamespaceSchemaProvider method getSchema.
@Override
@Nullable
public XmlFile getSchema(@NotNull @NonNls String url, @Nullable Module module, @NotNull PsiFile baseFile) {
if ("".equals(url)) {
final Project project = baseFile.getProject();
final VirtualFile file = NoNamespaceConfig.getInstance(project).getMappedFile(baseFile);
if (file == null)
return null;
final PsiFile f = PsiManager.getInstance(project).findFile(file);
if (f instanceof XmlFile) {
return (XmlFile) f;
}
}
return null;
}
use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.
the class ResolvingVisitor method processInclude.
private void processInclude(XmlFile xmlFile, XmlAttribute attribute) {
final Set<XmlFile> set = myProcessingContext.get(VISITED_KEY);
if (set.contains(xmlFile)) {
return;
}
set.add(xmlFile);
final XmlDocument document = xmlFile.getDocument();
if (document == null)
return;
final XmlTag rootTag = document.getRootTag();
if (rootTag == null)
return;
rootTag.processElements(this, attribute);
}
use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.
the class AntBuildModelImpl method getTargetListImpl.
// todo: return list of dependent psi files as well
private static Pair<List<AntBuildTargetBase>, Collection<Object>> getTargetListImpl(final AntBuildModelBase model) {
final List<AntBuildTargetBase> list = new ArrayList<>();
final Set<Object> dependencies = new HashSet<>();
final AntDomProject project = model.getAntProject();
if (project != null) {
final AntBuildFile buildFile = model.getBuildFile();
final XmlFile xmlFile = buildFile.getAntFile();
dependencies.add(xmlFile != null ? xmlFile : PsiModificationTracker.MODIFICATION_COUNT);
final VirtualFile sourceFile = buildFile.getVirtualFile();
new Object() {
private boolean myIsImported = false;
private final Set<VirtualFile> myProcessed = new HashSet<>();
private AntDomTarget myDefaultTarget = null;
private void fillTargets(List<AntBuildTargetBase> list, AntBuildModelBase model, AntDomProject project, VirtualFile sourceFile) {
if (myProcessed.contains(sourceFile)) {
return;
}
myProcessed.add(sourceFile);
if (!myIsImported) {
final TargetResolver.Result result = project.getDefaultTarget().getValue();
if (result != null) {
final Pair<AntDomTarget, String> targetWithName = result.getResolvedTarget(project.getDefaultTarget().getRawText());
myDefaultTarget = targetWithName != null ? targetWithName.getFirst() : null;
}
}
for (final AntDomTarget target : project.getDeclaredTargets()) {
list.add(new AntBuildTargetImpl(target, model, sourceFile, myIsImported, target.equals(myDefaultTarget)));
}
myIsImported = true;
final Iterable<AntDomIncludingDirective> allIncludes = ContainerUtil.concat((Iterable<AntDomImport>) project.getDeclaredImports(), (Iterable<? extends AntDomInclude>) project.getDeclaredIncludes());
for (AntDomIncludingDirective incl : allIncludes) {
final PsiFileSystemItem includedFile = incl.getFile().getValue();
if (includedFile instanceof PsiFile) {
final PsiFile included = includedFile.getContainingFile().getOriginalFile();
dependencies.add(included);
final AntDomProject includedProject = AntSupport.getAntDomProject((PsiFile) includedFile);
if (includedProject != null) {
fillTargets(list, model, includedProject, included.getVirtualFile());
}
} else {
if (includedFile == null) {
// if not resolved yet, it's possible that the file will be created later,
// thus we need to recalculate the cached value
dependencies.add(PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
}
}
}
}
}.fillTargets(list, model, project, sourceFile);
}
if (dependencies.isEmpty()) {
dependencies.add(PsiModificationTracker.MODIFICATION_COUNT);
}
return new Pair<>(list, dependencies);
}
use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.
the class AntConfigurationImpl method addBuildFileImpl.
private AntBuildFileBase addBuildFileImpl(final VirtualFile file) throws AntNoFileException {
PsiFile xmlFile = myPsiManager.findFile(file);
if (!(xmlFile instanceof XmlFile)) {
throw new AntNoFileException("the file is not an xml file", file);
}
AntSupport.markFileAsAntFile(file, xmlFile.getProject(), true);
if (!AntDomFileDescription.isAntFile(((XmlFile) xmlFile))) {
throw new AntNoFileException("the file is not recognized as an ANT file", file);
}
final AntBuildFileImpl buildFile = new AntBuildFileImpl((XmlFile) xmlFile, this);
myBuildFiles.add(buildFile);
return buildFile;
}
use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.
the class AntConfigurationImpl method getContextFile.
@Nullable
public XmlFile getContextFile(@Nullable final XmlFile file) {
if (file == null) {
return null;
}
final VirtualFile context = myAntFileToContextFileMap.get(file.getVirtualFile());
if (context == null) {
return null;
}
final PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(context);
if (!(psiFile instanceof XmlFile)) {
return null;
}
final XmlFile xmlFile = (XmlFile) psiFile;
return AntDomFileDescription.isAntFile(xmlFile) ? xmlFile : null;
}
Aggregations