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


Java PsiTreeUtil.findChildOfType方法代码示例

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


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

示例1: getClassName

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
public static String getClassName(@NotNull PsiElement element) {
    ParameterList parameterList = PsiTreeUtil.getParentOfType(element, ParameterList.class);
    if (parameterList == null) {
        return null;
    }

    MethodReference methodReference = PsiTreeUtil.getParentOfType(element, MethodReference.class);
    if (methodReference == null) {
        return null;
    }

    Variable variableBeingCalledOn = PsiTreeUtil.findChildOfType(methodReference, Variable.class);
    if (variableBeingCalledOn != null && variableBeingCalledOn.getInferredType() != null) {
        PhpType inferredType = variableBeingCalledOn.getInferredType();
        return inferredType.toString();
    }

    ClassReference classReference = PsiTreeUtil.getChildOfType(methodReference, ClassReference.class);

    return extractFqnFromClassReference(methodReference, classReference);
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:22,代码来源:PhpLangUtil.java

示例2: testVariableReferences

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
public void testVariableReferences() throws Throwable {
  myFixture.configureByFiles("CompletionSource.soy");
  PsiElement container = PsiTreeUtil.findChildOfType(myFixture.getFile(), SoyMsgStatement.class);
  Collection<SoyVariableReferenceIdentifier> vars =
      PsiTreeUtil.findChildrenOfType(container, SoyVariableReferenceIdentifier.class);
  assertSize(3, vars);
  for (SoyVariableReferenceIdentifier var : vars) {
    Class expectedClass;
    if (var.getText().equals("$planet")) {
      // @param
      expectedClass = SoyParamDefinitionIdentifier.class;
    } else if (var.getText().equals("$probe")) {
      // @inject
      expectedClass = SoyParamDefinitionIdentifier.class;
    } else {
      // {let}
      expectedClass = SoyVariableDefinitionIdentifier.class;
    }
    PsiElement id = var.getReference().resolve();
    assertInstanceOf(id, expectedClass);
  }
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:23,代码来源:SoyReferenceTest.java

示例3: firstStageMainSketchIdentification

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
public static Collection<PsiFile> firstStageMainSketchIdentification(@NotNull Collection<PsiFile> parsedPdeFiles) {
    Set<PsiFile> shortlist = new HashSet<>();

    for (PsiFile parsedPdeFile : parsedPdeFiles) {
        PsiErrorElement firstErrorInFile = PsiTreeUtil.findChildOfType(parsedPdeFile, PsiErrorElement.class);

        if (firstErrorInFile == null) {
            continue;
        }

        PsiClass errorContainingClass = PsiTreeUtil.getParentOfType(firstErrorInFile, PsiClass.class);

        if (errorContainingClass == null) {
            shortlist.add(parsedPdeFile);
        }
    }

    return shortlist;
}
 
开发者ID:mistodev,项目名称:processing-idea,代码行数:20,代码来源:MigrationActions.java

示例4: isAvailable

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
    if (!element.isWritable()) return false;
    boolean isTwigFile = GravFileTemplateUtil.isTwigTemplateFile(element.getContainingFile()) || element.getContainingFile() instanceof HtmlFileImpl;
    boolean isXmlAttribute = false;
    if (!isTwigFile) return false;
    if (element.getParent() instanceof XmlAttributeValueImpl) {
        XmlAttributeValueImpl parent0 = ((XmlAttributeValueImpl) element.getParent());
        boolean hasTwigElement = PsiTreeUtil.findChildOfType(parent0, OuterLanguageElement.class) != null;
        if (!hasTwigElement && parent0.getParent() instanceof XmlAttributeImpl) {
            XmlAttributeImpl parent1 = (XmlAttributeImpl) parent0.getParent();
            if (parent1.getName().equalsIgnoreCase("href") || parent1.getName().equalsIgnoreCase("src"))
                isXmlAttribute = true;
        }
    }
    return isXmlAttribute;
}
 
开发者ID:PioBeat,项目名称:GravSupport,代码行数:18,代码来源:ConvertTwigResource.java

示例5: getApplicationName

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@Nullable
public static String getApplicationName(AppleScriptUseStatement useStatement) {
  if (useStatement.getText().contains("application")) {
    AppleScriptApplicationReference appRef = PsiTreeUtil.findChildOfType(useStatement,
            AppleScriptApplicationReference.class);
    if (appRef == null) return null;
    ASTNode appNameNode = appRef.getNode().findChildByType(AppleScriptTypes.STRING_LITERAL);
    return appNameNode != null ? appNameNode.getText().replace("\"", "") : null;
  } else if (useStatement.getNode().findChildByType(AppleScriptTypes.SCRIPTING_ADDITIONS) != null) {
    return ApplicationDictionary.SCRIPTING_ADDITIONS_LIBRARY;
  }
  return null;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:14,代码来源:AppleScriptPsiImplUtil.java

示例6: getIndexer

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

        /* ignore file if its' structure is not as expected */
        final PhpReturn returnExpression = PsiTreeUtil.findChildOfType(fileContent.getPsiFile(), PhpReturn.class);
        final PsiElement argument        = null == returnExpression ? null : returnExpression.getArgument();
        if (!(argument instanceof ArrayCreationExpression)) {
            return map;
        }

        /* extract translations from the file */
        for (ArrayHashElement item : ((ArrayCreationExpression) argument).getHashElements()) {
            final PhpPsiElement key = item.getKey();
            if (key instanceof StringLiteralExpression) {
                final StringLiteralExpression literal = (StringLiteralExpression) key;
                final String message                  = literal.getContents();
                if (message.length() > 0) {
                    map.putIfAbsent(PhpStringUtil.unescapeText(message, literal.isSingleQuote()), null);
                }
            }
        }

        return map;
    };
}
 
开发者ID:kalessil,项目名称:yii2inspections,代码行数:29,代码来源:TranslationKeysIndexer.java

示例7: annotate

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {
  if (psiElement instanceof CallStatementElement) {
    CallStatementElement statement = (CallStatementElement) psiElement;

    Collection<String> givenParameters = ParamUtils.getGivenParameters(statement);

    // TODO(thso): Detect data="" in more robust way.
    if (statement.getText().contains("data=")) return;

    PsiElement identifier =
        PsiTreeUtil.findChildOfType(statement, SoyTemplateReferenceIdentifier.class);

    if (identifier == null) return;

    List<String> requiredParameters =
        ParamUtils.getParametersForInvocation(statement, identifier.getText())
            .stream()
            .filter((var) -> !var.isOptional)
            .map((var) -> var.name)
            .collect(Collectors.toList());

    if (!givenParameters.containsAll(requiredParameters)) {
      requiredParameters.removeAll(givenParameters);
      annotationHolder.createErrorAnnotation(
          identifier, "Missing required parameters: " + String.join(",", requiredParameters));
    }
  }
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:30,代码来源:MissingParametersAnnotator.java

示例8: getNamespace

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
public String getNamespace() {
  if (getStub() != null) {
    return getStub().getNamespace();
  }
  SoyNamespaceDeclarationIdentifier namespaceDeclaration =
      PsiTreeUtil.findChildOfType(this, SoyNamespaceDeclarationIdentifier.class);
  return namespaceDeclaration == null ? "" : namespaceDeclaration.getName();
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:9,代码来源:SoyFile.java

示例9: testTemplateReference

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
public void testTemplateReference() throws Throwable {
  myFixture.configureByFiles("ReferenceSource.soy", "CompletionSource.soy");
  CallStatementElement element =
      PsiTreeUtil.findChildOfType(myFixture.getFile(), CallStatementElement.class);
  PsiElement id =
      element.getBeginCall().getTemplateReferenceIdentifier().getReference().resolve();
  assertInstanceOf(id, SoyTemplateDefinitionIdentifier.class);
  assertEquals(".moon", ((SoyTemplateDefinitionIdentifier) id).getName());
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:10,代码来源:SoyReferenceTest.java

示例10: testParamReference

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
public void testParamReference() throws Throwable {
  myFixture.configureByFiles("ReferenceSource.soy", "CompletionSource.soy");
  SoyParamListElement element =
      PsiTreeUtil.findChildOfType(myFixture.getFile(), SoyParamListElement.class);
  PsiElement id =
      element.getBeginParamTag().getParamSpecificationIdentifier().getReference().resolve();
  assertInstanceOf(id, SoyParamDefinitionIdentifier.class);
  assertEquals("planet", ((SoyParamDefinitionIdentifier) id).getName());
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:10,代码来源:SoyReferenceTest.java

示例11: isWritable

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
private static boolean isWritable(SwiftPatternInitializer pattern) {
  boolean isComputed = pattern.isComputed();
  if (isComputed) {
    return PsiTreeUtil.findChildOfType(pattern, SwiftSetterClause.class) != null;
  } else {
    return true;
  }
}
 
开发者ID:seanhenry,项目名称:TearDownGenerator,代码行数:9,代码来源:TearDownUtil.java

示例12: isStartOfValueLine

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@Contract(pure = true)
private boolean isStartOfValueLine(@Nullable final ASTNode currentNode) {
    return null != currentNode
           && PsiTreeUtil.findChildOfType(
        currentNode.getTreeParent().getPsi(),
        ImpexValueGroup.class
    ) == currentNode.getPsi();
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:9,代码来源:ColumnsAlignmentStrategy.java

示例13: getSelectorIdentifier

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
public static AppleScriptIdentifier getSelectorIdentifier(AppleScriptArgumentSelector argumentSelector) {
  return PsiTreeUtil.findChildOfType(argumentSelector, AppleScriptIdentifier.class);
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:4,代码来源:AppleScriptPsiImplUtil.java

示例14: findApplicationNameFromTellStatement

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
public static String findApplicationNameFromTellStatement(PsiElement tellStatement) {
  //todo: could be not only application but any class of the application (process "Mail", etc)
  AppleScriptApplicationReference appRef = PsiTreeUtil.findChildOfType(tellStatement, AppleScriptApplicationReference.class);
  return getNameFromApplicationReference(appRef);
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:6,代码来源:AppleScriptPsiImplUtil.java

示例15: visitElement

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@Override
public void visitElement(PsiElement element) {
    Variable iconFolder = PsiTreeUtil.findChildOfType(element, Variable.class);
    if (iconFolder == null || !iconFolder.getName().equals("iconFolder")) {
        // Something changed - dynamic parsing failed.
        return;
    }

    StringLiteralExpression iconFolderValueString = PsiTreeUtil.getNextSiblingOfType(iconFolder, StringLiteralExpression.class);
    if (iconFolderValueString == null) {
        return;
    }

    String iconFolderValue = iconFolderValueString.getContents();

    Statement parentStatement = PsiTreeUtil.getParentOfType(iconFolder, Statement.class);
    Statement iconArrayAssignment = PsiTreeUtil.getNextSiblingOfType(
            parentStatement,
            Statement.class
    );
    if (iconArrayAssignment == null) {
        return;
    }

    Variable iconArray = PsiTreeUtil.findChildOfType(iconArrayAssignment, Variable.class);
    if (iconArray == null) {
        // something changed, meh. dynamic parsing failed.
        return;
    }

    ClassConstantReference iconProvider = PsiTreeUtil.findChildOfType(element, ClassConstantReference.class);
    if (iconProvider == null) {
        // something changed. - ...
        return;
    }

    ArrayCreationExpression flagsArray = PsiTreeUtil.getNextSiblingOfType(iconArray, ArrayCreationExpression.class);
    if (flagsArray == null) {
        return;
    }

    Collection<StringLiteralExpression> flagNames = PsiTreeUtil.findChildrenOfType(flagsArray, StringLiteralExpression.class);
    for (StringLiteralExpression flagNameExpression : flagNames) {
        String countryAbbreviation = flagNameExpression.getContents();

        this.createFlagIcon(iconProvider, iconFolderValue, countryAbbreviation, flagNameExpression);
    }
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:49,代码来源:CoreFlagParserVisitor.java


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