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


Java PsiRecursiveElementWalkingVisitor类代码示例

本文整理汇总了Java中com.intellij.psi.PsiRecursiveElementWalkingVisitor的典型用法代码示例。如果您正苦于以下问题:Java PsiRecursiveElementWalkingVisitor类的具体用法?Java PsiRecursiveElementWalkingVisitor怎么用?Java PsiRecursiveElementWalkingVisitor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: create

import com.intellij.psi.PsiRecursiveElementWalkingVisitor; //导入依赖的package包/类
@Nullable
@Override
protected List<DfaVariableValue> create(PsiElement closure) {
  final Set<DfaVariableValue> result = ContainerUtil.newLinkedHashSet();
  closure.accept(new PsiRecursiveElementWalkingVisitor() {
    @Override
    public void visitElement(PsiElement element) {
      if (element instanceof PsiReferenceExpression) {
        DfaValue value = myFactory.createValue((PsiReferenceExpression)element);
        if (value instanceof DfaVariableValue) {
          result.add((DfaVariableValue)value);
        }
      }
      super.visitElement(element);
    }
  });
  return ContainerUtil.newArrayList(result);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:LiveVariablesAnalyzer.java

示例2: scanCommentsInFile

import com.intellij.psi.PsiRecursiveElementWalkingVisitor; //导入依赖的package包/类
private void scanCommentsInFile(final Project project, final VirtualFile vFile) {
  if (!vFile.isDirectory() && vFile.getFileType() instanceof LanguageFileType) {
    ApplicationManager.getApplication().runReadAction(new Runnable() {
      @Override
      public void run() {
        PsiFile psiFile = PsiManager.getInstance(project).findFile(vFile);
        if (psiFile == null) return;

        for (PsiFile root : psiFile.getViewProvider().getAllFiles()) {
          root.accept(new PsiRecursiveElementWalkingVisitor() {
            @Override
            public void visitComment(PsiComment comment) {
              commentFound(vFile, comment.getText());
            }
          });
        }
      }
    });
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ScanSourceCommentsAction.java

示例3: findAllInstructionsInside

import com.intellij.psi.PsiRecursiveElementWalkingVisitor; //导入依赖的package包/类
@NotNull
private List<Pair<Instruction, String>> findAllInstructionsInside(@NotNull PsiElement scope) {
  final List<Pair<Instruction, String>> result = ContainerUtil.newArrayList();
  scope.accept(new PsiRecursiveElementWalkingVisitor() {
    @Override
    public void visitElement(PsiElement element) {
      if (element instanceof GrReferenceExpression && !((GrReferenceExpression)element).isQualified()) {
        String varName = ((GrReferenceExpression)element).getReferenceName();
        if (varName != null) {
          for (Instruction dependency : ControlFlowUtils.findAllInstructions(element, flow)) {
            result.add(Pair.create(dependency, varName));
          }
        }
      }
      super.visitElement(element);
    }
  });
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:TypeInferenceHelper.java

示例4: findOtherNamedArgumentsInFile

import com.intellij.psi.PsiRecursiveElementWalkingVisitor; //导入依赖的package包/类
private static Map<String, NamedArgumentDescriptor> findOtherNamedArgumentsInFile(PsiElement mapOrArgumentList) {
  final Map<String, NamedArgumentDescriptor> map = new HashMap<String, NamedArgumentDescriptor>();
  mapOrArgumentList.getContainingFile().accept(new PsiRecursiveElementWalkingVisitor() {
    @Override
    public void visitElement(PsiElement element) {
      if (element instanceof GrArgumentLabel) {
        final String name = ((GrArgumentLabel)element).getName();
        if (GroovyNamesUtil.isIdentifier(name)) {
          map.put(name, NamedArgumentDescriptor.SIMPLE_UNLIKELY);
        }
      }
      super.visitElement(element);
    }
  });
  return map;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:MapArgumentCompletionProvider.java

示例5: createFromText

import com.intellij.psi.PsiRecursiveElementWalkingVisitor; //导入依赖的package包/类
@Nullable
public static <T extends PsiElement> T createFromText(@NotNull Project p, final Class<T> aClass, String text) {
    final PsiElement[] ret = new PsiElement[]{null};

    createDummyFile(p, text).accept(new PsiRecursiveElementWalkingVisitor() {
        public void visitElement(PsiElement element) {
            if(ret[0] == null && aClass.isInstance(element)) {
                ret[0] = element;
            }

            super.visitElement(element);
        }
    });

    return (T) ret[0];
}
 
开发者ID:Haehnchen,项目名称:idea-php-laravel-plugin,代码行数:17,代码来源:BladePsiElementFactory.java

示例6: getDefinedSymbols

import com.intellij.psi.PsiRecursiveElementWalkingVisitor; //导入依赖的package包/类
public static List<PsiElement> getDefinedSymbols(Project project) {
    final List<PsiElement> result = new ArrayList<PsiElement>();
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, 
            CMakeFileType.INSTANCE,
            GlobalSearchScope.allScope(project));
    // Scan each file for named entities
    for (VirtualFile virtualFile : virtualFiles) {
        CMakeFile cmakeFile = (CMakeFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (cmakeFile != null) {
            cmakeFile.accept(new PsiRecursiveElementWalkingVisitor() {
                @Override
                public void visitElement(PsiElement element) {
                    super.visitElement(element);
                    if(element instanceof CMakeCommandExpr
                            && (element.getFirstChild().getNode().getElementType() == CMakeTypes.FUNCTION
                            || element.getFirstChild().getNode().getElementType() == CMakeTypes.MACRO
                            || element.getFirstChild().toString().equalsIgnoreCase("set")))
                    {
                        result.add(element);
                    }
                }
            });
        }
    }
    return result;
}
 
开发者ID:dubrousky,项目名称:CMaker,代码行数:27,代码来源:CMakeParserUtilImpl.java

示例7: getDefinedVars

import com.intellij.psi.PsiRecursiveElementWalkingVisitor; //导入依赖的package包/类
public static List<PsiElement> getDefinedVars(Project project, String name) {
    final List<PsiElement> result = new ArrayList<PsiElement>();
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME,
            CMakeFileType.INSTANCE,
            GlobalSearchScope.allScope(project));
    // Scan each file for named entities
    for (VirtualFile virtualFile : virtualFiles) {
        CMakeFile cmakeFile = (CMakeFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (cmakeFile != null) {
            cmakeFile.accept(new PsiRecursiveElementWalkingVisitor() {
                @Override
                public void visitElement(PsiElement element) {
                    super.visitElement(element);
                    if(element instanceof CMakeCommandExpr
                            && (element.getFirstChild().getText().contains("set")
                            || element.getFirstChild().getText().contains("list")
                            || element.getFirstChild().getText().contains("option")))
                    {
                        result.add(element);
                    }
                }
            });
        }
    }
    return result;
}
 
开发者ID:dubrousky,项目名称:CMaker,代码行数:27,代码来源:CMakeParserUtilImpl.java

示例8: getBlockPsiElement

import com.intellij.psi.PsiRecursiveElementWalkingVisitor; //导入依赖的package包/类
public static List<PsiElement> getBlockPsiElement(PsiFile psiFile, final String blockName) {
    final List<PsiElement> psiElements = new ArrayList<>();

    psiFile.acceptChildren(new PsiRecursiveElementWalkingVisitor() {
        @Override
        public void visitElement(PsiElement element) {

            if(SmartyPattern.getBlockPattern().accepts(element)) {
                String text = element.getText();
                if(blockName.equalsIgnoreCase(text)) {
                    psiElements.add(element);
                }

            }

            super.visitElement(element);
        }
    });

    return psiElements;
}
 
开发者ID:Haehnchen,项目名称:idea-php-shopware-plugin,代码行数:22,代码来源:SmartyBlockGoToHandler.java

示例9: getIncludePsiElement

import com.intellij.psi.PsiRecursiveElementWalkingVisitor; //导入依赖的package包/类
private static List<PsiElement> getIncludePsiElement(PsiFile psiFile, final String templateName) {
    final List<PsiElement> psiElements = new ArrayList<>();

    psiFile.acceptChildren(new PsiRecursiveElementWalkingVisitor() {
        @Override
        public void visitElement(PsiElement element) {

            if(SmartyPattern.getFileIncludePattern().accepts(element)) {
                String text = element.getText();
                if(templateName.equalsIgnoreCase(text)) {
                    psiElements.add(element);
                }

            }

            super.visitElement(element);
        }
    });

    return psiElements;
}
 
开发者ID:Haehnchen,项目名称:idea-php-shopware-plugin,代码行数:22,代码来源:SmartyTemplateLineMarkerProvider.java

示例10: findPrimaryType

import com.intellij.psi.PsiRecursiveElementWalkingVisitor; //导入依赖的package包/类
@Nullable
@RequiredReadAction
public static CSharpTypeDeclaration findPrimaryType(@NotNull PsiFile file)
{
	Ref<CSharpTypeDeclaration> typeRef = Ref.create();
	file.accept(new PsiRecursiveElementWalkingVisitor()
	{
		@Override
		public void visitElement(PsiElement element)
		{
			if(element instanceof CSharpTypeDeclaration)
			{
				typeRef.set((CSharpTypeDeclaration) element);
				stopWalking();
			}
			super.visitElement(element);
		}
	});
	return typeRef.get();
}
 
开发者ID:consulo,项目名称:consulo-unity3d,代码行数:21,代码来源:Unity3dAssetUtil.java

示例11: checkFile

import com.intellij.psi.PsiRecursiveElementWalkingVisitor; //导入依赖的package包/类
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull final InspectionManager manager, final boolean isOnTheFly) {
	if (!(file instanceof LatteFile)) {
		return null;
	}
	final List<ProblemDescriptor> problems = new ArrayList<ProblemDescriptor>();
	file.acceptChildren(new PsiRecursiveElementWalkingVisitor() {
		@Override
		public void visitElement(PsiElement element) {
			if (element instanceof LatteMacroTag) {
				boolean result = checkClassicMacro((LatteMacroTag) element);
				if (result) {
					ProblemDescriptor problem = manager.createProblemDescriptor(element, "Modifiers are not allowed here", true, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly);
					problems.add(problem);
				}
			} else {
				super.visitElement(element);
			}
		}
	});


	return problems.toArray(new ProblemDescriptor[problems.size()]);
}
 
开发者ID:JanTvrdik,项目名称:intellij-latte,代码行数:26,代码来源:ModifierNotAllowedInspection.java

示例12: collectWebReferences

import com.intellij.psi.PsiRecursiveElementWalkingVisitor; //导入依赖的package包/类
@NotNull
public static List<WebReference> collectWebReferences() {
  final List<WebReference> refs = new ArrayList<>();
  myFile.accept(new PsiRecursiveElementWalkingVisitor() {
    @Override
    public void visitElement(PsiElement element) {
      for (PsiReference ref : element.getReferences()) {
        if (ref instanceof WebReference) refs.add((WebReference)ref);
      }
      super.visitElement(element);
    }
  });
  assertTrue(refs.stream().allMatch(PsiReferenceBase::isSoft));
  return refs;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:JavadocHighlightingTest.java

示例13: deannotatePattern

import com.intellij.psi.PsiRecursiveElementWalkingVisitor; //导入依赖的package包/类
private void deannotatePattern() {
  for (final PsiElement patternComponent : myPattern) {
    patternComponent.accept(new PsiRecursiveElementWalkingVisitor() {
      @Override public void visitElement(PsiElement element) {
        if (element.getUserData(PARAMETER) != null) {
          element.putUserData(PARAMETER, null);
        }
      }
    });
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:SimpleDuplicatesFinder.java

示例14: annotatePattern

import com.intellij.psi.PsiRecursiveElementWalkingVisitor; //导入依赖的package包/类
private void annotatePattern() {
  for (final PsiElement patternComponent : myPattern) {
    patternComponent.accept(new PsiRecursiveElementWalkingVisitor() {
      @Override
      public void visitElement(PsiElement element) {
        super.visitElement(element);
        if (myParameters.contains(element.getText())) {
          element.putUserData(PARAMETER, element);
        }

      }
    });
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:SimpleDuplicatesFinder.java

示例15: getContentIdentsTargets

import com.intellij.psi.PsiRecursiveElementWalkingVisitor; //导入依赖的package包/类
public static Set<PsiElement> getContentIdentsTargets(final @NotNull Project project, final @NotNull VirtualFile currentFile, final @NotNull String ident) {

        final Set<PsiElement> psiElements = new HashSet<PsiElement>();

        FileBasedIndexImpl.getInstance().getFilesWithKey(OxidContentIdentIndexer.KEY, new HashSet<String>(Arrays.asList(ident)), new Processor<VirtualFile>() {
            @Override
            public boolean process(VirtualFile virtualFile) {

                if (currentFile.equals(virtualFile)) {
                    return true;
                }

                PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
                if (psiFile == null) {
                    return true;
                }

                psiFile.acceptChildren(new PsiRecursiveElementWalkingVisitor() {
                    @Override
                    public void visitElement(PsiElement element) {

                        if(SmartyPattern.getAttributeInsideTagPattern("ident", "oxcontent").accepts(element)) {
                            String content = element.getText();
                            if(StringUtils.isNotBlank(content) && content.equalsIgnoreCase(ident)) {
                                psiElements.add(element);
                            }
                        }

                        super.visitElement(element);
                    }

                });


                return true;
            }
        }, GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(project), SmartyFileType.INSTANCE));

        return psiElements;
    }
 
开发者ID:Haehnchen,项目名称:idea-php-oxid-plugin,代码行数:41,代码来源:TemplateUtil.java


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