本文整理匯總了Java中org.jetbrains.yaml.psi.YAMLPsiElement類的典型用法代碼示例。如果您正苦於以下問題:Java YAMLPsiElement類的具體用法?Java YAMLPsiElement怎麽用?Java YAMLPsiElement使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
YAMLPsiElement類屬於org.jetbrains.yaml.psi包,在下文中一共展示了YAMLPsiElement類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: searchForKey
import org.jetbrains.yaml.psi.YAMLPsiElement; //導入依賴的package包/類
private static YAMLKeyValue searchForKey(YAMLPsiElement yamlPsiElement, String[] path, int index) {
if (index < path.length) {
for (YAMLPsiElement current : yamlPsiElement.getYAMLElements()) {
if (current instanceof YAMLKeyValue) {
if (path[index].equals(((YAMLKeyValue) current).getKeyText())) {
if (index == path.length - 1) {
return ((YAMLKeyValue) current);
} else {
return searchForKey(current, path, index + 1);
}
}
} else {
return searchForKey(current, path, index);
}
}
}
return null;
}
示例2: getElementNamePairs
import org.jetbrains.yaml.psi.YAMLPsiElement; //導入依賴的package包/類
private List<Pair<PsiElement, String>> getElementNamePairs(YAMLDocument yamlDocument, String elementName) {
final PsiElement psiElement = findChildRecursively(yamlDocument, new String[]{elementName});
if (psiElement == null) {
return Collections.emptyList();
}
List<Pair<PsiElement, String>> elementStringPairs = new ArrayList<>();
try (BufferedReader reader = new BufferedReader(new StringReader(psiElement.getText()))) {
for (String line; (line = reader.readLine()) != null;) {
final Matcher matcher = keyInListPattern.matcher(line);
if (matcher.find()) {
String elementNameGroup = matcher.group(1);
YAMLPsiElement childElement = findChildRecursively((YAMLPsiElement) psiElement, new String[]{elementNameGroup});
PsiElement elementToHighlight = (childElement != null) ? childElement : ((psiElement instanceof YAMLKeyValue) ? ((YAMLKeyValue) psiElement).getKey() : psiElement);
elementStringPairs.add(new ImmutablePair<>(elementToHighlight, elementNameGroup));
}
}
} catch (IOException ignore) { // this code is never reached because the reader reads from memory
}
return elementStringPairs;
}
示例3: getYAMLElements
import org.jetbrains.yaml.psi.YAMLPsiElement; //導入依賴的package包/類
public List<YAMLPsiElement> getYAMLElements() {
final ArrayList<YAMLPsiElement> result = new ArrayList<>();
for (ASTNode node : getNode().getChildren(null)) {
final PsiElement psi = node.getPsi();
if (psi instanceof YAMLPsiElement) {
result.add((YAMLPsiElement) psi);
}
}
return result;
}
示例4: getYAMLElements
import org.jetbrains.yaml.psi.YAMLPsiElement; //導入依賴的package包/類
public List<YAMLPsiElement> getYAMLElements()
{
ArrayList<YAMLPsiElement> result = new ArrayList<>();
ASTNode[] var2 = this.getNode().getChildren(null);
for (ASTNode node : var2)
{
PsiElement psi = node.getPsi();
if (psi instanceof YAMLPsiElement)
{
result.add((YAMLPsiElement) psi);
}
}
return result;
}
示例5: findChildRecursively
import org.jetbrains.yaml.psi.YAMLPsiElement; //導入依賴的package包/類
private YAMLPsiElement findChildRecursively(YAMLPsiElement element, String[] possibleName) {
List<YAMLPsiElement> yamlElements = element.getYAMLElements();
if (yamlElements.isEmpty()) {
return null;
}
Optional<YAMLPsiElement> matchingNode = yamlElements.stream().filter(e -> hasAcceptedName(e, possibleName)).findFirst();
return matchingNode.orElseGet(() -> yamlElements.stream()
.map(e -> findChildRecursively(e, possibleName))
.filter(Objects::nonNull)
.findFirst()
.orElse(null));
}
示例6: isPrivatePropertyTrue
import org.jetbrains.yaml.psi.YAMLPsiElement; //導入依賴的package包/類
private boolean isPrivatePropertyTrue(YAMLValue value) {
List<YAMLPsiElement> yamlElements = value.getYAMLElements();
for (YAMLPsiElement e : yamlElements) {
if (e instanceof YAMLKeyValue) {
YAMLKeyValue property = (YAMLKeyValue) e;
if (property.getKeyText().equals(PRIVATE) && property.getValueText().equals(TRUE.toString())) {
return true;
}
}
}
return false;
}
示例7: hasAcceptedName
import org.jetbrains.yaml.psi.YAMLPsiElement; //導入依賴的package包/類
private boolean hasAcceptedName(YAMLPsiElement e, String[] possibleName) {
return Stream.of(possibleName).anyMatch(n -> n.equals(e.getName()));
}