本文整理汇总了Java中org.jetbrains.yaml.psi.YAMLFile类的典型用法代码示例。如果您正苦于以下问题:Java YAMLFile类的具体用法?Java YAMLFile怎么用?Java YAMLFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
YAMLFile类属于org.jetbrains.yaml.psi包,在下文中一共展示了YAMLFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSystemFile
import org.jetbrains.yaml.psi.YAMLFile; //导入依赖的package包/类
private SmartPsiElementPointer<YAMLFile> getSystemFile(@NotNull Project project) {
String prefix = "";
try {
prefix = GravProjectSettings.getInstance(project).withSrcDirectory ? "src/" + "" : "";
} catch (NullPointerException ignored) {
}
String path = prefix + SYSTEM_SYSTEM_CONFIG_FILE;
VirtualFile systemFile = project.getBaseDir().findFileByRelativePath(path);
if (systemFile != null) {
PsiFile psiFile = PsiManager.getInstance(project).findFile(systemFile);
if (psiFile != null && psiFile instanceof YAMLFile) {
systemYamlFile = SmartPointerManagerImpl.getInstance(project).createSmartPsiElementPointer((YAMLFile) psiFile);
return systemYamlFile;
}
}
return null;
}
示例2: getHelpersInFile
import org.jetbrains.yaml.psi.YAMLFile; //导入依赖的package包/类
public static HashMap<String, String> getHelpersInFile(@NotNull PsiFile psiFile) {
YAMLKeyValue defaultContext = YAMLUtil.getQualifiedKeyInFile((YAMLFile) psiFile, "Neos", "Fusion", "defaultContext");
if (defaultContext == null) {
defaultContext = YAMLUtil.getQualifiedKeyInFile((YAMLFile) psiFile, "TYPO3", "TypoScript", "defaultContext");
}
HashMap<String, String> result = new HashMap<>();
if (defaultContext != null) {
PsiElement mapping = defaultContext.getLastChild();
if (mapping instanceof YAMLMapping) {
for (PsiElement mappingElement : mapping.getChildren()) {
if (mappingElement instanceof YAMLKeyValue) {
YAMLKeyValue keyValue = (YAMLKeyValue) mappingElement;
result.put(keyValue.getKeyText(), keyValue.getValueText());
NeosProjectComponent.getLogger().debug(keyValue.getKeyText() + ": " + keyValue.getValueText());
}
}
}
}
return result;
}
示例3: multiResolve
import org.jetbrains.yaml.psi.YAMLFile; //导入依赖的package包/类
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
String nodeTypeNameToFindReferenceFor = yamlElement.getKeyText();
// files which contain the NodeType definition
Collection<VirtualFile> files = FileBasedIndex.getInstance().getContainingFiles(NodeTypesYamlFileIndex.KEY, nodeTypeNameToFindReferenceFor, GlobalSearchScope.allScope(yamlElement.getProject()));
return files
.stream()
// get the PSI for each file
.map(file -> PsiManager.getInstance(yamlElement.getProject()).findFile(file))
// ensure we only have YAML files
.filter(psiFile -> psiFile instanceof YAMLFile)
.map(psiFile -> (YAMLFile) psiFile)
// get all YAML keys in these files
.flatMap(yamlFile -> YAMLUtil.getTopLevelKeys(yamlFile).stream())
// get the correct YAML key
.filter(yamlKeyValue -> yamlKeyValue.getKeyText().equals(nodeTypeNameToFindReferenceFor))
// remove "current" element if it exists
.filter(yamlKeyValue -> yamlElement != yamlKeyValue)
// build up the result object
.map(yamlKeyValue -> new PsiElementResolveResult(yamlKeyValue, true))
.toArray(PsiElementResolveResult[]::new);
}
示例4: getIndexer
import org.jetbrains.yaml.psi.YAMLFile; //导入依赖的package包/类
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
return inputData -> {
Map<String, Void> map = new THashMap<>();
PsiFile psiFile = inputData.getPsiFile();
if(!(psiFile instanceof YAMLFile) || !psiFile.getName().endsWith(".menu.yml")) {
return map;
}
for (YAMLKeyValue yamlKeyValue : YamlHelper.getTopLevelKeyValues((YAMLFile) psiFile)) {
String keyText = yamlKeyValue.getKeyText();
if(StringUtils.isBlank(keyText)) {
continue;
}
map.put(keyText, null);
}
return map;
};
}
示例5: getIndexer
import org.jetbrains.yaml.psi.YAMLFile; //导入依赖的package包/类
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
return inputData -> {
Map<String, Void> map = new THashMap<>();
PsiFile psiFile = inputData.getPsiFile();
if(!(psiFile instanceof YAMLFile) || !psiFile.getName().endsWith(".permissions.yml")) {
return map;
}
for (YAMLKeyValue yamlKeyValue : YamlHelper.getTopLevelKeyValues((YAMLFile) psiFile)) {
String keyText = yamlKeyValue.getKeyText();
if(StringUtils.isBlank(keyText)) {
continue;
}
map.put(keyText, null);
}
return map;
};
}
示例6: buildVisitor
import org.jetbrains.yaml.psi.YAMLFile; //导入依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder, boolean isOnTheFly) {
if(!Symfony2ProjectComponent.isEnabled(holder.getProject())) {
return super.buildVisitor(holder, isOnTheFly);
}
return new PsiElementVisitor() {
@Override
public void visitFile(PsiFile psiFile) {
if(psiFile instanceof YAMLFile) {
psiFile.acceptChildren(new YmlClassElementWalkingVisitor(holder, new ContainerCollectionResolver.LazyServiceCollector(holder.getProject())));
} else if(psiFile instanceof XmlFile) {
psiFile.acceptChildren(new XmlClassElementWalkingVisitor(holder, new ContainerCollectionResolver.LazyServiceCollector(holder.getProject())));
}
}
};
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:19,代码来源:TaggedExtendsInterfaceClassInspection.java
示例7: visitFile
import org.jetbrains.yaml.psi.YAMLFile; //导入依赖的package包/类
@Override
public void visitFile(PsiFile psiFile) {
ProblemRegistrar problemRegistrar = null;
if(psiFile instanceof YAMLFile) {
psiFile.acceptChildren(new YmlClassElementWalkingVisitor(holder, problemRegistrar = new ProblemRegistrar()));
} else if(psiFile instanceof XmlFile) {
psiFile.acceptChildren(new XmlClassElementWalkingVisitor(holder, problemRegistrar = new ProblemRegistrar()));
} else if(psiFile instanceof PhpFile) {
psiFile.acceptChildren(new PhpClassWalkingVisitor(holder, problemRegistrar = new ProblemRegistrar()));
}
if(problemRegistrar != null) {
problemRegistrar.reset();
}
super.visitFile(psiFile);
}
示例8: getMetadata
import org.jetbrains.yaml.psi.YAMLFile; //导入依赖的package包/类
@Nullable
public DoctrineMetadataModel getMetadata(@NotNull DoctrineMappingDriverArguments args) {
PsiFile psiFile = args.getPsiFile();
if(!(psiFile instanceof YAMLFile)) {
return null;
}
Collection<DoctrineModelField> fields = new ArrayList<>();
DoctrineMetadataModel model = new DoctrineMetadataModel(fields);
for (YAMLKeyValue yamlKeyValue : YamlHelper.getTopLevelKeyValues((YAMLFile) psiFile)) {
// first line is class name; check of we are right
if(args.isEqualClass(YamlHelper.getYamlKeyName(yamlKeyValue))) {
model.setTable(YamlHelper.getYamlKeyValueAsString(yamlKeyValue, "table"));
fields.addAll(EntityHelper.getModelFieldsSet(yamlKeyValue));
}
}
if(model.isEmpty()) {
return null;
}
return model;
}
示例9: buildVisitor
import org.jetbrains.yaml.psi.YAMLFile; //导入依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder, boolean isOnTheFly) {
if(!Symfony2ProjectComponent.isEnabled(holder.getProject())) {
return super.buildVisitor(holder, isOnTheFly);
}
return new PsiElementVisitor() {
@Override
public void visitFile(PsiFile psiFile) {
if(psiFile instanceof YAMLFile) {
visitYaml(holder, psiFile);
}
if(psiFile instanceof XmlFile) {
visitXml(holder, psiFile);
}
super.visitFile(psiFile);
}
};
}
示例10: getTwigPaths
import org.jetbrains.yaml.psi.YAMLFile; //导入依赖的package包/类
@NotNull
private Collection<TwigPath> getTwigPaths(@NotNull TwigNamespaceExtensionParameter parameter) {
Collection<TwigPath> twigPaths = new ArrayList<>();
for (VirtualFile file : ConfigUtil.getConfigurations(parameter.getProject(), "twig")) {
PsiFile psiFile = PsiManager.getInstance(parameter.getProject()).findFile(file);
if(!(psiFile instanceof YAMLFile)) {
continue;
}
for (Pair<String, String> stringStringPair : TwigUtil.getTwigPathFromYamlConfigResolved((YAMLFile) psiFile)) {
// default path
String first = stringStringPair.getFirst();
if(first == null || first.equals("")) {
first = TwigUtil.MAIN;
}
twigPaths.add(new TwigPath(stringStringPair.getSecond(), first, TwigUtil.NamespaceType.ADD_PATH, true));
}
}
return twigPaths;
}
示例11: findParameterDefinitions
import org.jetbrains.yaml.psi.YAMLFile; //导入依赖的package包/类
public static List<PsiElement> findParameterDefinitions(@NotNull PsiFile psiFile, @NotNull String parameterName) {
List<PsiElement> items = new ArrayList<>();
if(psiFile instanceof YAMLFile) {
PsiElement servicePsiElement = YamlHelper.getLocalParameterMap(psiFile, parameterName);
if(servicePsiElement != null) {
items.add(servicePsiElement);
}
}
if(psiFile instanceof XmlFile) {
PsiElement localParameterName = XmlHelper.getLocalParameterName(psiFile, parameterName);
if(localParameterName != null) {
items.add(localParameterName);
}
}
return items;
}
示例12: getIndexer
import org.jetbrains.yaml.psi.YAMLFile; //导入依赖的package包/类
@NotNull
@Override
public DataIndexer<String, String, FileContent> getIndexer() {
return inputData -> {
Map<String, String> map = new HashMap<>();
PsiFile psiFile = inputData.getPsiFile();
if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject())) {
return map;
}
if(!ServicesDefinitionStubIndex.isValidForIndex(inputData, psiFile)) {
return map;
}
if(psiFile instanceof YAMLFile) {
attachTHashMapNullable(YamlHelper.getLocalParameterMap(psiFile), map);
} else if(psiFile instanceof XmlFile) {
attachTHashMapNullable(XmlHelper.getFileParameterMap((XmlFile) psiFile), map);
}
return map;
};
}
示例13: filterList
import org.jetbrains.yaml.psi.YAMLFile; //导入依赖的package包/类
private void filterList(String domainName) {
// clear list no all*() method?
while(this.listTableModel.getRowCount() > 0) {
this.listTableModel.removeRow(0);
}
// we only support yaml files right now
// filter on PsiFile instance
Collection<PsiFile> domainPsiFilesYaml = TranslationUtil.getDomainPsiFiles(this.project, domainName).stream()
.filter(domainPsiFile -> domainPsiFile instanceof YAMLFile || TranslationUtil.isSupportedXlfFile(domainPsiFile))
.collect(Collectors.toCollection(ArrayList::new));
this.listTableModel.addRows(this.getFormattedFileModelList(domainPsiFilesYaml));
// only one domain; fine preselect it
if(this.listTableModel.getRowCount() == 1) {
this.listTableModel.getItem(0).setEnabled(true);
}
}
示例14: invokeTranslation
import org.jetbrains.yaml.psi.YAMLFile; //导入依赖的package包/类
private static PsiElement invokeTranslation(@NotNull final YAMLFile yamlFile, @NotNull final String keyName, @NotNull final String translation) {
String[] split = keyName.split("\\.");
PsiElement psiElement = YamlHelper.insertKeyIntoFile(yamlFile, "'" + translation + "'", split);
if(psiElement == null) {
return null;
}
// resolve target to get value
YAMLKeyValue target = YAMLUtil.getQualifiedKeyInFile(yamlFile, split);
if(target != null && target.getValue() != null) {
return target.getValue();
} else if(target != null) {
return target;
}
return yamlFile;
}
示例15: visitYamlFile
import org.jetbrains.yaml.psi.YAMLFile; //导入依赖的package包/类
/**
* foo:
* resources: 'FOO'
*/
private static void visitYamlFile(@NotNull YAMLFile yamlFile, @NotNull Consumer<FileResourceConsumer> consumer) {
for (YAMLKeyValue yamlKeyValue : YamlHelper.getTopLevelKeyValues(yamlFile)) {
YAMLKeyValue resourceKey = YamlHelper.getYamlKeyValue(yamlKeyValue, "resource", true);
if(resourceKey == null) {
continue;
}
String resource = PsiElementUtils.trimQuote(resourceKey.getValueText());
if(StringUtils.isBlank(resource)) {
continue;
}
consumer.consume(new FileResourceConsumer(resourceKey, yamlKeyValue, normalize(resource)));
}
}