本文整理汇总了Java中org.jetbrains.yaml.psi.YAMLFile类的典型用法代码示例。如果您正苦于以下问题:Java YAMLFile类的具体用法?Java YAMLFile怎么用?Java YAMLFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
YAMLFile类属于org.jetbrains.yaml.psi包,在下文中一共展示了YAMLFile类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:PioBeat,项目名称:GravSupport,代码行数:19,代码来源:SystemSettingsToolWindowFactory.java
示例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;
}
开发者ID:cvette,项目名称:intellij-neos,代码行数:24,代码来源:EelHelperUtil.java
示例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);
}
开发者ID:cvette,项目名称:intellij-neos,代码行数:26,代码来源:NodeTypeReference.java
示例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;
};
}
开发者ID:Haehnchen,项目名称:idea-php-drupal-symfony2-bridge,代码行数:26,代码来源:MenuIndex.java
示例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;
};
}
开发者ID:Haehnchen,项目名称:idea-php-drupal-symfony2-bridge,代码行数:26,代码来源:PermissionIndex.java
示例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);
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:20,代码来源:ServiceDeprecatedClassesInspection.java
示例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;
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:26,代码来源:DoctrineYamlMappingDriver.java
示例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);
}
};
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:23,代码来源:ControllerMethodInspection.java
示例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;
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:24,代码来源:ConfigAddPathTwigNamespaces.java
示例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;
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:21,代码来源:ServiceIndexUtil.java
示例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;
};
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:25,代码来源:ContainerParameterStubIndex.java
示例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);
}
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:22,代码来源:TranslatorKeyExtractorDialog.java
示例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;
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:18,代码来源:TranslationInsertUtil.java
示例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)));
}
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:20,代码来源:FileResourceVisitorUtil.java
示例16: visitFile
import org.jetbrains.yaml.psi.YAMLFile; //导入依赖的package包/类
@Override
public void visitFile(PsiFile file) {
if(!(file instanceof YAMLFile)) {
return;
}
for (ServiceActionUtil.ServiceYamlContainer serviceYamlContainer : ServiceActionUtil.getYamlContainerServiceArguments((YAMLFile) file)) {
// we dont support parent services for now
if("_defaults".equalsIgnoreCase(serviceYamlContainer.getServiceKey().getKeyText()) || !isValidService(serviceYamlContainer)) {
continue;
}
List<String> yamlMissingArgumentTypes = ServiceActionUtil.getYamlMissingArgumentTypes(problemsHolder.getProject(), serviceYamlContainer, false, getLazyServiceCollector(problemsHolder.getProject()));
if(yamlMissingArgumentTypes.size() > 0) {
problemsHolder.registerProblem(serviceYamlContainer.getServiceKey().getFirstChild(), "Missing argument", ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new YamlArgumentQuickfix());
}
}
this.lazyServiceCollector = null;
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:22,代码来源:YamlServiceArgumentInspection.java
示例17: update
import org.jetbrains.yaml.psi.YAMLFile; //导入依赖的package包/类
public void update(AnActionEvent event) {
Project project = event.getData(PlatformDataKeys.PROJECT);
if (project == null || !Symfony2ProjectComponent.isEnabled(project)) {
this.setStatus(event, false);
return;
}
Pair<PsiFile, PhpClass> pair = findPhpClass(event);
if(pair == null) {
return;
}
PsiFile psiFile = pair.getFirst();
if(!(psiFile instanceof YAMLFile) && !(psiFile instanceof XmlFile) && !(psiFile instanceof PhpFile)) {
this.setStatus(event, false);
}
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:19,代码来源:SymfonyContainerServiceBuilder.java
示例18: insertYamlServiceTag
import org.jetbrains.yaml.psi.YAMLFile; //导入依赖的package包/类
private void insertYamlServiceTag() {
if(!(this.psiFile instanceof YAMLFile)) {
return;
}
String text = createServiceAsText(ServiceBuilder.OutputType.Yaml, this.psiFile);
YAMLKeyValue fromText = YamlPsiElementFactory.createFromText(project, YAMLKeyValue.class, text);
if(fromText == null) {
return;
}
PsiElement psiElement = YamlHelper.insertKeyIntoFile((YAMLFile) psiFile, fromText, "services");
if(psiElement != null) {
navigateToElement(new TextRange[] {psiElement.getTextRange()});
}
dispose();
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:19,代码来源:SymfonyCreateService.java
示例19: testGetTwigPathFromYamlConfigResolved
import org.jetbrains.yaml.psi.YAMLFile; //导入依赖的package包/类
/**
* @see TwigUtil#getTwigPathFromYamlConfigResolved
*/
public void testGetTwigPathFromYamlConfigResolved() {
createFile("app/test/foo.yaml");
PsiFile dummyFile = YamlPsiElementFactory.createDummyFile(getProject(), "" +
"twig:\n" +
" paths:\n" +
" '%kernel.root_dir%/test': foo\n" +
" '%kernel.project_dir%/app/test': project\n" +
" '%kernel.root_dir%/../app': app\n"
);
Collection<Pair<String, String>> paths = TwigUtil.getTwigPathFromYamlConfigResolved((YAMLFile) dummyFile);
assertNotNull(
paths.stream().filter(pair -> "foo".equals(pair.getFirst()) && "app/test".equals(pair.getSecond())).findFirst()
);
assertNotNull(
paths.stream().filter(pair -> "project".equals(pair.getFirst()) && "app/test".equals(pair.getSecond())).findFirst()
);
assertNotNull(
paths.stream().filter(pair -> "app".equals(pair.getFirst()) && "app".equals(pair.getSecond())).findFirst()
);
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:29,代码来源:TwigUtilTempTest.java
示例20: testGetTwigGlobalsFromYamlConfig
import org.jetbrains.yaml.psi.YAMLFile; //导入依赖的package包/类
/**
* @see TwigUtil#getTwigGlobalsFromYamlConfig
*/
public void testGetTwigGlobalsFromYamlConfig() {
String content = "twig:\n" +
" globals:\n" +
" ga_tracking: '%ga_tracking%'\n" +
" user_management: '@AppBundle\\Service\\UserManagement'\n"
;
YAMLFile yamlFile = (YAMLFile) PsiFileFactory.getInstance(getProject())
.createFileFromText("DUMMY__." + YAMLFileType.YML.getDefaultExtension(), YAMLFileType.YML, content, System.currentTimeMillis(), false);
Map<String, String> globals = TwigUtil.getTwigGlobalsFromYamlConfig(yamlFile);
assertEquals("%ga_tracking%", globals.get("ga_tracking"));
assertEquals("@AppBundle\\Service\\UserManagement", globals.get("user_management"));
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:19,代码来源:TwigUtilTest.java
注:本文中的org.jetbrains.yaml.psi.YAMLFile类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论