Package com.intellij.psi

Examples of com.intellij.psi.PsiFile


  @Override
  public String getDescription(@NotNull final String sonarIssueKey, @NotNull final Editor editor) {
    // retrieve sonar issue data
    final Project project = editor.getProject();
    if (project == null || project.isDisposed()) return null;
    final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
    if (psiFile == null) return null;
    final Optional<IssuesByFileIndexProjectComponent> indexComponent = IssuesByFileIndexProjectComponent.getInstance(project);
    if (!indexComponent.isPresent()) return null;
    final IssuesByFileIndexProjectComponent state = indexComponent.get().getState();
    if (state == null) return null;
    final Map<String, Set<SonarIssue>> index = state.getIndex();
    final String path = psiFile.getVirtualFile().getPath();
    final Set<SonarIssue> issues = index.get(path);
    final Optional<SonarIssue> issue = FluentIterable.from(issues).firstMatch(new Predicate<SonarIssue>() {
      @Override
      public boolean apply(SonarIssue sonarIssue) {
        return sonarIssueKey.equals(sonarIssue.getKey());
      }
    });
    if (!issue.isPresent()) return null;

    // try to get desc from already fetched rules
    final Optional<SonarRules> sonarRules = SonarRules.getInstance(project);
    if (sonarRules.isPresent()) {
      final SonarRules sonarRulesState = sonarRules.get().getState();
      if (sonarRulesState != null) {
        final Rule rule = sonarRulesState.getSonarRulesByRuleKey().get(issue.get().getRuleKey());
        if (rule != null && !rule.isEmpty()) return rule.getDesc();
      }
    }

    // fetch and persist rule
    Settings settings;
    final Module moduleForFile = ModuleUtil.findModuleForFile(psiFile.getVirtualFile(), project);
    if (moduleForFile != null) {
      settings = ModuleSettings.getInstance(moduleForFile).getState();
      settings = SettingsUtil.process(project, settings);
    } else {
      settings = ProjectSettings.getInstance(project).getState();
View Full Code Here


    doTest(new PsiFile[]{file}, expectedSize);
  }

  protected void doTest(PsiFile[] files, int expectedSize) {
    assertNotNull(files);
    final PsiFile myFile = files[0];
    assertNotNull(myFile);
    final TargetElementUtilBase util = TargetElementUtilBase.getInstance();
    assertNotNull(util);

    final Collection<PsiElement> elements = util.getTargetCandidates(myFile.findReferenceAt(myFixture.getCaretOffset()));
    assertNotNull(elements);
    assertEquals(expectedSize, elements.size());
  }
View Full Code Here

            @NotNull
            @Override
            public Map<String, Void> map(@NotNull FileContent inputData) {
                final Map<String, Void> map = new THashMap<String, Void>();

                PsiFile psiFile = inputData.getPsiFile();
                if(!(psiFile instanceof PhpFile)) {
                    return map;
                }

                if(!AnnotationUtil.isValidForIndex(inputData)) {
                    return map;
                }

                psiFile.accept(new PsiRecursiveElementWalkingVisitor() {
                    @Override
                    public void visitElement(PsiElement element) {
                        if ((element instanceof PhpClass)) {
                            visitPhpClass((PhpClass) element);
                        }
View Full Code Here

    @NotNull
    @Override
    public PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder, boolean isOnTheFly) {

        PsiFile psiFile = holder.getFile();

        if(psiFile instanceof PhpFile) {
            psiFile.acceptChildren(new PsiRecursiveElementWalkingVisitor() {
                @Override
                public void visitElement(PsiElement element) {
                    if(element instanceof PhpDocTag && AnnotationUtil.isAnnotationPhpDocTag((PhpDocTag) element)) {
                        visitAnnotationDocTag((PhpDocTag) element, holder);
                    }
View Full Code Here

    protected void addCompletions(@NotNull com.intellij.codeInsight.completion.CompletionParameters completionParameters,
                                  ProcessingContext processingContext,
                                  @NotNull CompletionResultSet completionResultSet) {

        ArrayList<String> translatingParams = this.getRenderParams(completionParameters);
        PsiFile psiContainingFile = completionParameters.getPosition().getContainingFile();
        String cleanText = CommonHelper.cleanCompleterSearchString(completionParameters.getPosition().getText());
        String searchString = cleanText;
        int linkType = _getLinkType(searchString);
        VirtualFile originalFile = psiContainingFile.getOriginalFile().getVirtualFile();

        if (originalFile != null) {

            String controllerName = getControllerName(psiContainingFile);
            String path;
View Full Code Here

    protected void addCompletions(@NotNull com.intellij.codeInsight.completion.CompletionParameters completionParameters,
                                  ProcessingContext processingContext,
                                  @NotNull CompletionResultSet completionResultSet) {

        PsiFile currentFile = completionParameters.getPosition().getContainingFile();
        Project project = currentFile.getProject();
        ConfigParser config = YiiStormProjectComponent.getInstance(project).getYiiConfig();
        if (config != null) {
            HashMap<String, String> classMap = config.getComponentsClassMap();
            if (classMap != null && classMap.size() > 0) {
                for (String componentName : classMap.keySet()) {
View Full Code Here

    protected void addCompletions(@NotNull com.intellij.codeInsight.completion.CompletionParameters completionParameters,
                                  ProcessingContext processingContext,
                                  @NotNull CompletionResultSet completionResultSet) {

        PsiFile currentFile = completionParameters.getPosition().getContainingFile();
        Project project = currentFile.getProject();
        String lang = I18NHelper.getLang(project);
        if (currentFile.getOriginalFile().getVirtualFile() != null) {

            String searchString = CommonHelper.cleanCompleterSearchString(completionParameters.getPosition().getText());

            String subpathAlias = "";
            String path = CommonHelper.getFilePath(currentFile);
View Full Code Here

    protected void addCompletions(@NotNull com.intellij.codeInsight.completion.CompletionParameters completionParameters,
                                  ProcessingContext processingContext,
                                  @NotNull CompletionResultSet completionResultSet) {

        PsiFile currentFile = completionParameters.getPosition().getContainingFile();
        Project project = currentFile.getProject();

        String lang = I18NHelper.getLang(project);

        PsiElement position = completionParameters.getPosition();
        PsiElement list = (ParameterList) position.getParent().getParent();
        PsiElement[] children = list.getChildren();
        if (children.length < 2) {
            return;
        }
        if (!children[0].toString().equals("String") || children[1] != position.getParent()) {
            return;
        }
        String fileName = CommonHelper.rmQuotes(children[0].getFirstChild().getText());
        String searchString = CommonHelper.cleanCompleterSearchString(completionParameters.getPosition().getText());
        VirtualFile originalFile = currentFile.getOriginalFile().getVirtualFile();

        Boolean identMatch = false;
        if (originalFile != null) {

            String path = CommonHelper.getFilePath(currentFile);
View Full Code Here

            ProviderType2 = ProviderType2;
        }    */
        if (elname.endsWith("StringLiteralExpressionImpl")) {

            try {
                PsiFile file = element.getContainingFile();
                VirtualFile vfile = file.getVirtualFile();
                if (vfile != null) {
                    String path = vfile.getPath();
                    String basePath = project.getBasePath();
                    if (basePath != null) {
                        projectPath = basePath.replace("\\", "/");
View Full Code Here

        return PsiFileFactory.getInstance(project)
                .createFileFromText("x", PhpFileType.INSTANCE, CharSequenceFromFile(path));
    }

    public static HashMap<String, String> parsePhpArrayConfig(Project project, String filePath) {
        PsiFile pf = CommonHelper.getPsiFile(project, filePath);
        HashMap<String, String> hashx = new HashMap<String, String>();
        if (pf != null) {
            PsiElement groupStatement = pf.getFirstChild();
            if (groupStatement != null) {
                for (PsiElement pl : groupStatement.getChildren()) {
                    if (pl.toString().equals("Return")) {
                        PsiElement[] pl2 = pl.getChildren();
                        if (pl2.length > 0 && pl2[0].toString().equals("Array creation expression")) {
View Full Code Here

TOP

Related Classes of com.intellij.psi.PsiFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.