当前位置: 首页>>代码示例>>Java>>正文


Java PsiTreeUtil.getChildrenOfType方法代码示例

本文整理汇总了Java中com.intellij.psi.util.PsiTreeUtil.getChildrenOfType方法的典型用法代码示例。如果您正苦于以下问题:Java PsiTreeUtil.getChildrenOfType方法的具体用法?Java PsiTreeUtil.getChildrenOfType怎么用?Java PsiTreeUtil.getChildrenOfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.util.PsiTreeUtil的用法示例。


在下文中一共展示了PsiTreeUtil.getChildrenOfType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNamedSubComponentsFor

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@NotNull
public static List<AppleScriptComponent> getNamedSubComponentsFor(@NotNull AppleScriptScriptObject script) {
  List<AppleScriptComponent> result = new ArrayList<>();
  AppleScriptScriptBody scriptBody = script.getScriptBody();
  AppleScriptComponent[] namedComponents = PsiTreeUtil.getChildrenOfType(scriptBody, AppleScriptComponent.class);
  AppleScriptAssignmentStatement[] varsCreations = PsiTreeUtil.getChildrenOfType(scriptBody, AppleScriptAssignmentStatement.class);
  AppleScriptVarDeclarationList[] varsDeclarations = PsiTreeUtil.getChildrenOfType(scriptBody, AppleScriptVarDeclarationList.class);

  if (namedComponents != null) {
    result.addAll(Arrays.asList(namedComponents));
  }
  if (varsCreations != null) {
    for (AppleScriptAssignmentStatement variable : varsCreations) {
      result.addAll(variable.getTargets());
    }
  }
  if (varsDeclarations != null) {
    for (AppleScriptVarDeclarationList declarationList : varsDeclarations) {
      AppleScriptComponent[] vars = PsiTreeUtil.getChildrenOfType(declarationList, AppleScriptComponent.class);
      if (vars != null) {
        result.addAll(Arrays.asList(vars));
      }
    }
  }
  return result;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:27,代码来源:AppleScriptResolveUtil.java

示例2: findModules

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@NotNull
public static List<PsiModule> findModules(@NotNull Project project, @NotNull String name) {
    ArrayList<PsiModule> result = new ArrayList<>();

    Collection<VirtualFile> virtualFiles = FilenameIndex.getAllFilesByExt(project, RmlFileType.INSTANCE.getDefaultExtension());
    for (VirtualFile virtualFile : virtualFiles) {
        PsiFile file = PsiManager.getInstance(project).findFile(virtualFile);
        PsiModule[] modules = PsiTreeUtil.getChildrenOfType(file, PsiModule.class);
        if (modules != null) {
            for (PsiModule module : modules) {
                if (name.equals(module.getName())) {
                    result.add(module);
                }
            }
        }
    }

    return result;
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:20,代码来源:RmlPsiUtil.java

示例3: findMappings

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
public static List<CptMapping> findMappings(Project project, String key) {
	List<CptMapping> result = null;

	Collection<VirtualFile> virtualFiles =
		FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, CptFileType.INSTANCE,
			GlobalSearchScope.allScope(project));

	for (VirtualFile virtualFile : virtualFiles) {
		CptFile cptFile = (CptFile) PsiManager.getInstance(project).findFile(virtualFile);

		if (cptFile != null) {
			CptMapping[] mappings = PsiTreeUtil.getChildrenOfType(cptFile, CptMapping.class);
			if (mappings != null) {
				for (CptMapping mapping : mappings) {
					if (key.equals(mapping.getMatchingClass())) {
						if (result == null) {
							result = new ArrayList<>();
						}
						result.add(mapping);
					}
				}
			}
		}
	}
	return result != null ? result : Collections.emptyList();
}
 
开发者ID:xylo,项目名称:intellij-postfix-templates,代码行数:27,代码来源:CptUtil.java

示例4: findProperties

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
public static List<CrystalProperty> findProperties(Project project, String key) {
    List<CrystalProperty> result = null;
    Collection<VirtualFile> virtualFiles =
            FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, CrystalFileType.INSTANCE,
                    GlobalSearchScope.allScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        CrystalFile simpleFile = (CrystalFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (simpleFile != null) {
            CrystalProperty[] properties = PsiTreeUtil.getChildrenOfType(simpleFile, CrystalProperty.class);
            if (properties != null) {
                for (CrystalProperty property : properties) {
                    if (key.equals(property.getKey())) {
                        if (result == null) {
                            result = new ArrayList<CrystalProperty>();
                        }
                        result.add(property);
                    }
                }
            }
        }
    }
    return result != null ? result : Collections.<CrystalProperty>emptyList();
}
 
开发者ID:benoist,项目名称:intellij-crystal,代码行数:24,代码来源:CrystalUtil.java

示例5: createColumnInfoMap

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
private Map<Integer, CsvColumnInfo<PsiElement>> createColumnInfoMap(CsvFile csvFile) {
    Map<Integer, CsvColumnInfo<PsiElement>> columnInfoMap = new HashMap<>();
    CsvRecord[] records = PsiTreeUtil.getChildrenOfType(csvFile, CsvRecord.class);
    int row = 0;
    for (CsvRecord record : records) {
        int column = 0;
        for (CsvField field : record.getFieldList()) {
            Integer length = field.getTextLength();
            if (!columnInfoMap.containsKey(column)) {
                columnInfoMap.put(column, new CsvColumnInfo(column, length));
            } else if (columnInfoMap.get(column).getMaxLength() < length) {
                columnInfoMap.get(column).setMaxLength(length);
            }
            columnInfoMap.get(column).addElement(field, row);
            ++column;
        }
        ++row;
    }
    return columnInfoMap;
}
 
开发者ID:SeeSharpSoft,项目名称:intellij-csv-validator,代码行数:21,代码来源:CsvStructureViewElement.java

示例6: generate

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@Override
public Set<TSFnDeclStmt> generate(Project project) {
    Set<TSFnDeclStmt> items = new HashSet<>();
    //Search every file in the project
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, TSFileType.INSTANCE, GlobalSearchScope.projectScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        TSFile tsFile = (TSFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (tsFile != null) {
            TSFnDeclStmt[] functions = PsiTreeUtil.getChildrenOfType(tsFile, TSFnDeclStmt.class);
            if (functions != null) {
                Collections.addAll(items, functions);
            }

            TSPackageDecl[] packages = PsiTreeUtil.getChildrenOfType(tsFile, TSPackageDecl.class);
            if (packages != null) {
                for (TSPackageDecl pack : packages) {
                    functions = PsiTreeUtil.getChildrenOfType(pack, TSFnDeclStmt.class);
                    if (functions != null) {
                        Collections.addAll(items, functions);
                    }
                }
            }
            ProgressManager.progress("Loading Symbols");
        }
    }
    return items;
}
 
开发者ID:CouleeApps,项目名称:TS-IJ,代码行数:28,代码来源:TSFunctionCachedListGenerator.java

示例7: getRangeInElement

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@Override
public TextRange getRangeInElement() {
  final TextRange textRange = getTextRange();

  AppleScriptReferenceElement[] appleScriptReferences = PsiTreeUtil.getChildrenOfType(this, AppleScriptReferenceElement.class);
  if (appleScriptReferences != null && appleScriptReferences.length > 0) {
    TextRange lastReferenceRange = appleScriptReferences[appleScriptReferences.length - 1].getTextRange();
    return new UnfairTextRange(
        lastReferenceRange.getStartOffset() - textRange.getStartOffset(),
        lastReferenceRange.getEndOffset() - textRange.getEndOffset()
    );
  }
  return new UnfairTextRange(0, textRange.getEndOffset() - textRange.getStartOffset());
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:15,代码来源:AppleScriptReferenceElementImpl.java

示例8: from

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@Nullable
public static ArrayAdapter from(@Nullable final PhpTypedElement element) {
    if (!(element instanceof ArrayCreationExpression)) {
        return null;
    }

    final PhpPsiElement[] arrayElements = PsiTreeUtil.getChildrenOfType((PsiElement) element, PhpPsiElement.class);

    if (arrayElements == null) {
        return null;
    }

    return new ArrayAdapter(new ArrayList<>(Arrays.asList(arrayElements)));
}
 
开发者ID:rentalhost,项目名称:laravel-insight,代码行数:15,代码来源:ArrayAdapter.java

示例9: getIndexer

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
    return inputData -> {
        Map<String, Void> map = new HashMap<>();

        PsiFile psiFile = inputData.getPsiFile();
        if (!Settings.isEnabled(psiFile.getProject())) {
            return map;
        }

        if (!(psiFile instanceof XmlFile)) {
            return map;
        }

        XmlDocument document = ((XmlFile) psiFile).getDocument();
        if (document == null) {
            return map;
        }

        XmlTag xmlTags[] = PsiTreeUtil.getChildrenOfType(psiFile.getFirstChild(), XmlTag.class);
        if (xmlTags == null) {
            return map;
        }

        for (XmlTag xmlTag : xmlTags) {
            if (xmlTag.getName().equals("routes")) {
                for (XmlTag routeNode : xmlTag.findSubTags("route")) {
                    for (XmlTag serviceNode : routeNode.findSubTags("service")) {
                        String typeName = serviceNode.getAttributeValue("class");
                        if (typeName != null) {
                            map.put(PhpLangUtil.toPresentableFQN(typeName), null);
                        }
                    }
                }
            }
        }
        return map;
    };
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:41,代码来源:WebApiTypeIndex.java

示例10: getChildren

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@Override
public TreeElement[] getChildren() {
	if (element instanceof CptFile) {
		CptTemplate[] templates = PsiTreeUtil.getChildrenOfType(element, CptTemplate.class);
		List<TreeElement> treeElements = new ArrayList<>(templates.length);
		for (CptTemplate template : templates) {
			treeElements.add(new CptStructureViewElement(template));
		}
		return treeElements.toArray(new TreeElement[treeElements.size()]);
	} else {
		return EMPTY_ARRAY;
	}
}
 
开发者ID:xylo,项目名称:intellij-postfix-templates,代码行数:14,代码来源:CptStructureViewElement.java

示例11: processNamespaces

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
public static void processNamespaces(Project project, Set<PhpNamespaceRootInfo> roots) {
    VirtualFile composerFile = project.getBaseDir().findChild("composer.json");

    if (composerFile == null) {
        PhpPsr4NamespaceNotifier.showNotificationByMessageId(
                project,
                "actions.detect.namespace.roots.no.composer.json.detected",
                (NotificationListener)null
        );

        throw new ProcessCanceledException();
    }

    JsonFile psiFile = (JsonFile) PsiManager.getInstance(project).findFile(composerFile);

    if (psiFile != null) {
        JsonProperty[] properties = PsiTreeUtil.getChildrenOfType(psiFile.getTopLevelValue(), JsonProperty.class);

        if (properties != null) {
            boolean found = false;
            for (JsonProperty property : properties) {
                if (!property.getName().equals("autoload") && !property.getName().equals("autoload-dev")) {
                    continue;
                }

                if (property.getValue() != null && property.getValue() instanceof JsonObject) {
                    JsonProperty[] namespacesTypes = PsiTreeUtil.getChildrenOfType(
                        property.getValue(),
                        JsonProperty.class
                    );

                    if (namespacesTypes != null) {
                        for (JsonProperty namespaceType : namespacesTypes) {
                            if (!namespaceType.getName().equals("psr-4")) {
                                continue;
                            }

                            JsonProperty[] namespaces = PsiTreeUtil.getChildrenOfType(
                                    namespaceType.getValue(),
                                    JsonProperty.class
                            );

                            if (namespaces != null) {
                                for (JsonProperty namespace : namespaces) {
                                    if (namespace.getValue() != null &&
                                        namespace.getValue() instanceof JsonStringLiteral
                                    ) {
                                        String path = project.getBasePath()
                                                + File.separator
                                                + ((JsonStringLiteral) namespace.getValue()).getValue();

                                        if (!FileUtil.exists(path)) {
                                            continue;
                                        }

                                        PhpNamespaceRootInfo rootInfo = PhpNamespaceRootInfo.create(
                                            path,
                                            namespace.getName()
                                        );

                                        roots.add(rootInfo);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:aurimasniekis,项目名称:idea-php-psr4-namespace-detector,代码行数:72,代码来源:PhpPsr4NamespaceRootDetector.java


注:本文中的com.intellij.psi.util.PsiTreeUtil.getChildrenOfType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。