Java Code Examples for com.intellij.psi.PsiElementVisitor

The following examples show how to use com.intellij.psi.PsiElementVisitor. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@NotNull
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 visitElement(PsiElement element) {
            if(TwigPattern.getAutocompletableRoutePattern().accepts(element) && TwigUtil.isValidStringWithoutInterpolatedOrConcat(element)) {
                invoke(element, holder);
            }

            super.visitElement(element);
        }
    };
}
 
Example 2
Source Project: idea-php-typo3-plugin   Source File: ClassNameMatcherInspection.java    License: MIT License 6 votes vote down vote up
@NotNull
@Override
public PsiElementVisitor buildRealVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
    return new PhpElementVisitor() {

        @Override
        public void visitPhpClassReference(ClassReference classReference) {
            Set<String> deprecatedClassNames = getDeprecatedClassNames(classReference.getProject());
            if (deprecatedClassNames.contains(classReference.getFQN())) {
                problemsHolder.registerProblem(classReference, "Class scheduled for removal in upcoming TYPO3 version, consider using an alternative");
            }

            super.visitPhpClassReference(classReference);
        }
    };
}
 
Example 3
Source Project: BashSupport   Source File: EvaluateExpansionInspection.java    License: Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
    return new BashVisitor() {
        @Override
        public void visitExpansion(BashExpansion expansion) {
            if (isOnTheFly && expansion.isValidExpansion()) {
                boolean bash4 = BashProjectSettings.storedSettings(holder.getProject()).isSupportBash4();
                holder.registerProblem(expansion, "Evaluate expansion", new EvaluateExpansionQuickfix(expansion, bash4));
            }
        }
    };
}
 
Example 4
@Nonnull
@Override
public PsiElementVisitor buildVisitor(@Nonnull ProblemsHolder holder, boolean isOnTheFly)
{
	if(Unity3dModuleExtensionUtil.getRootModule(holder.getProject()) == null)
	{
		return PsiElementVisitor.EMPTY_VISITOR;
	}

	return new CSharpElementVisitor()
	{
		@Override
		@RequiredReadAction
		public void visitMethodDeclaration(CSharpMethodDeclaration declaration)
		{
			UnityFunctionManager.FunctionInfo magicMethod = UnityEventCSharpMethodLineMarkerProvider.findMagicMethod(declaration);
			if(magicMethod != null)
			{
				PsiElement codeBlock = declaration.getCodeBlock().getElement();
				if(codeBlock == null || codeBlock instanceof CSharpBlockStatementImpl && ((CSharpBlockStatementImpl) codeBlock).getStatements().length == 0)
				{
					PsiElement nameIdentifier = declaration.getNameIdentifier();
					assert nameIdentifier != null;
					holder.registerProblem(nameIdentifier, Unity3dBundle.message("empty.magic.method.inspection.message"), new RemoveMethodFix(declaration));
				}
			}
		}
	};
}
 
Example 5
@NotNull
@Override
public PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder, boolean isOnTheFly) {
    return new PsiElementVisitor() {
        @Override
        public void visitElement(PsiElement element) {
            if (element instanceof PhpDocTag && AnnotationUtil.isAnnotationPhpDocTag((PhpDocTag) element)) {
                visitAnnotationDocTag((PhpDocTag) element, holder);
            }

            super.visitElement(element);
        }
    };
}
 
Example 6
@Nonnull
@Override
public PsiElementVisitor buildVisitor(@Nonnull ProblemsHolder holder, boolean isOnTheFly)
{
	if(Unity3dModuleExtensionUtil.getRootModule(holder.getProject()) == null)
	{
		return PsiElementVisitor.EMPTY_VISITOR;
	}

	return new CSharpElementVisitor()
	{
		@Override
		@RequiredReadAction
		public void visitMethodDeclaration(CSharpMethodDeclaration declaration)
		{
			String name = declaration.getName();
			if("OnGUI".equals(name))
			{
				UnityFunctionManager.FunctionInfo magicMethod = UnityEventCSharpMethodLineMarkerProvider.findMagicMethod(declaration);
				if(magicMethod != null)
				{
					PsiElement nameIdentifier = declaration.getNameIdentifier();
					assert nameIdentifier != null;
					holder.registerProblem(nameIdentifier, Unity3dBundle.message("ongui.method.inspection.message"), new UnityEmptyMagicMethodInspection.RemoveMethodFix(declaration));
				}
			}
		}
	};
}
 
Example 7
Source Project: idea-php-typo3-plugin   Source File: PluginEnabledPhpInspection.java    License: MIT License 5 votes vote down vote up
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
    if (!TYPO3CMSProjectSettings.getInstance(problemsHolder.getProject()).pluginEnabled) {
        return new PhpElementVisitor() {
        };
    }

    return buildRealVisitor(problemsHolder, b);
}
 
Example 8
Source Project: idea-php-typo3-plugin   Source File: ConstantMatcherInspection.java    License: MIT License 5 votes vote down vote up
@NotNull
@Override
public PsiElementVisitor buildRealVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpConstantReference(ConstantReference reference) {
            if (DeprecationUtility.isDeprecated(problemsHolder.getProject(), reference)) {
                problemsHolder.registerProblem(reference, "Constant scheduled for removal in upcoming TYPO3 version, consider using an alternative");
            }

            super.visitPhpConstantReference(reference);
        }
    };
}
 
Example 9
Source Project: intellij-haskforce   Source File: HaskellBkindImpl.java    License: Apache License 2.0 4 votes vote down vote up
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof HaskellVisitor) accept((HaskellVisitor)visitor);
  else super.accept(visitor);
}
 
Example 10
Source Project: intellij-xquery   Source File: XQueryPITestImpl.java    License: Apache License 2.0 4 votes vote down vote up
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof XQueryVisitor) accept((XQueryVisitor)visitor);
  else super.accept(visitor);
}
 
Example 11
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof CypherVisitor) accept((CypherVisitor)visitor);
  else super.accept(visitor);
}
 
Example 12
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof MelVisitor) accept((MelVisitor)visitor);
  else super.accept(visitor);
}
 
Example 13
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof CypherVisitor) accept((CypherVisitor)visitor);
  else super.accept(visitor);
}
 
Example 14
Source Project: nix-idea   Source File: NixExprSimpleImpl.java    License: Apache License 2.0 4 votes vote down vote up
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof NixVisitor) accept((NixVisitor)visitor);
  else super.accept(visitor);
}
 
Example 15
Source Project: intellij-thrift   Source File: ThriftConstListImpl.java    License: Apache License 2.0 4 votes vote down vote up
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof ThriftVisitor) accept((ThriftVisitor)visitor);
  else super.accept(visitor);
}
 
Example 16
Source Project: mule-intellij-plugins   Source File: WeaveHeaderImpl.java    License: Apache License 2.0 4 votes vote down vote up
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof WeaveVisitor) accept((WeaveVisitor)visitor);
  else super.accept(visitor);
}
 
Example 17
Source Project: intellij-xquery   Source File: XQuerySeparatorImpl.java    License: Apache License 2.0 4 votes vote down vote up
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof XQueryVisitor) accept((XQueryVisitor)visitor);
  else super.accept(visitor);
}
 
Example 18
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof GraphQLVisitor) accept((GraphQLVisitor)visitor);
  else super.accept(visitor);
}
 
Example 19
Source Project: intellij-yang   Source File: YangTypeBodyStmtsImpl.java    License: Apache License 2.0 4 votes vote down vote up
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof YangVisitor) ((YangVisitor)visitor).visitTypeBodyStmts(this);
  else super.accept(visitor);
}
 
Example 20
Source Project: arma-intellij-plugin   Source File: SQFPsiParenExpressionImpl.java    License: MIT License 4 votes vote down vote up
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof SQFPsiVisitor) accept((SQFPsiVisitor)visitor);
  else super.accept(visitor);
}
 
Example 21
Source Project: intellij-haskforce   Source File: HaskellCdeclImpl.java    License: Apache License 2.0 4 votes vote down vote up
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof HaskellVisitor) accept((HaskellVisitor)visitor);
  else super.accept(visitor);
}
 
Example 22
Source Project: arma-intellij-plugin   Source File: SQFPsiCommandImpl.java    License: MIT License 4 votes vote down vote up
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof SQFPsiVisitor) accept((SQFPsiVisitor)visitor);
  else super.accept(visitor);
}
 
Example 23
Source Project: mule-intellij-plugins   Source File: WeaveDataTypeImpl.java    License: Apache License 2.0 4 votes vote down vote up
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof WeaveVisitor) accept((WeaveVisitor)visitor);
  else super.accept(visitor);
}
 
Example 24
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof CypherVisitor) accept((CypherVisitor)visitor);
  else super.accept(visitor);
}
 
Example 25
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof YangVisitor) ((YangVisitor)visitor).visitLeafrefSpecification(this);
  else super.accept(visitor);
}
 
Example 26
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof WeaveVisitor) accept((WeaveVisitor)visitor);
  else super.accept(visitor);
}
 
Example 27
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof XQueryVisitor) accept((XQueryVisitor)visitor);
  else super.accept(visitor);
}
 
Example 28
Source Project: intellij-xquery   Source File: XQueryEscapeQuotImpl.java    License: Apache License 2.0 4 votes vote down vote up
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof XQueryVisitor) accept((XQueryVisitor)visitor);
  else super.accept(visitor);
}
 
Example 29
Source Project: idea-php-typo3-plugin   Source File: InternalTypeFileInspection.java    License: MIT License 4 votes vote down vote up
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
    if (!TYPO3CMSProjectSettings.getInstance(problemsHolder.getProject()).pluginEnabled) {
        return new PhpElementVisitor() {
        };
    }

    // the internal type was deprecated on 9 and dropped on 10
    if (TYPO3Utility.compareMajorMinorVersion(problemsHolder.getProject(), "9.0") < 0) {
        return new PhpElementVisitor() {
        };
    }

    return new PhpElementVisitor() {
        @Override
        public void visitPhpElement(PhpPsiElement element) {

            boolean isArrayStringValue = PhpElementsUtil.isStringArrayValue().accepts(element);
            if (!isArrayStringValue || !insideTCAColumnDefinition(element)) {
                return;
            }


            String arrayIndex = extractArrayIndexFromValue(element);
            if (arrayIndex != null && arrayIndex.equals("internal_type")) {
                if (element instanceof StringLiteralExpression) {
                    String internalType = ((StringLiteralExpression) element).getContents();

                    if (!internalType.equals("file_reference") && !internalType.equals("file")) {
                        return;
                    }

                    // the internal type was deprecated on 9 and dropped on 10
                    if (TYPO3Utility.compareMajorMinorVersion(problemsHolder.getProject(), "10.0") < 0) {
                        problemsHolder.registerProblem(element, String.format("Internal type '%s' is deprecated, will be removed with v10.0", internalType), ProblemHighlightType.LIKE_DEPRECATED);

                        return;
                    }

                    problemsHolder.registerProblem(element, String.format("Internal type '%s' was removed prior to v10.0", internalType), ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
                }
            }
        }
    };
}
 
Example 30
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof CypherVisitor) accept((CypherVisitor)visitor);
  else super.accept(visitor);
}