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


Java PsiWhiteSpace类代码示例

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


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

示例1: deleteFunctionParam

import com.intellij.psi.PsiWhiteSpace; //导入依赖的package包/类
public static void deleteFunctionParam(PsiElement element) {
    PsiElement next = element.getNextSibling();
    if (next != null && next.getText().equals(",")) {
        next.delete();
    } else {
        PsiElement prev = element.getPrevSibling();
        if (prev != null && prev instanceof PsiWhiteSpace) {
            prev.delete();
            prev = element.getPrevSibling();
        }
        if (prev != null && prev.getText().equals(",")) {
            prev.delete();
        }
    }
    element.delete();
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:17,代码来源:PsiUtil.java

示例2: applyFix

import com.intellij.psi.PsiWhiteSpace; //导入依赖的package包/类
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
    final PsiElement expression = descriptor.getPsiElement();
    if (expression instanceof ArrayHashElement) {
        PsiElement next = expression.getNextSibling();
        if (next instanceof PsiWhiteSpace) {
            next.delete();
        }
        next = expression.getNextSibling();
        if (null != next && PhpTokenTypes.opCOMMA == next.getNode().getElementType()) {
            next.delete();
        }
        next = expression.getNextSibling();
        if (next instanceof PsiWhiteSpace) {
            next.delete();
        }

        expression.delete();
    }
}
 
开发者ID:kalessil,项目名称:yii2inspections,代码行数:21,代码来源:UnusedTranslationsInspector.java

示例3: findByLineAndColumn

import com.intellij.psi.PsiWhiteSpace; //导入依赖的package包/类
@Nullable
private static PsiElement findByLineAndColumn(
    @NotNull final PsiElement file,
    @Nullable final Point columnAndLine
) {
    if (columnAndLine == null) {
        return file;
    }
    final int line = columnAndLine.y - 1;
    final int column = columnAndLine.x - 1;

    PsiElement leaf = findByLineAndColumn(file, line, column);

    if (leaf instanceof PsiWhiteSpace) {
        leaf = PsiTreeUtil.prevVisibleLeaf(leaf);
    }

    final PsiElement tag = leaf instanceof XmlTag ? leaf : PsiTreeUtil.getParentOfType(leaf, XmlTag.class);
    return tag == null ? leaf : tag;
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:21,代码来源:ValidateContextImpl.java

示例4: prevElementIsUserRightsMacros

import com.intellij.psi.PsiWhiteSpace; //导入依赖的package包/类
@Nullable
@Contract(pure = true)
public static boolean prevElementIsUserRightsMacros(@NotNull final PsiElement element) {
    Validate.notNull(element);

    final Class[] skipClasses = {ImpexValueLine.class, PsiComment.class, PsiWhiteSpace.class};
    PsiElement prevElement = PsiTreeUtil.skipSiblingsBackward(element, skipClasses);

    while (null != prevElement) {
        if (isHeaderLine(prevElement)) {
            return false;
        }
        if (isUserRightsMacros(prevElement)) {
            return true;
        }
        prevElement = PsiTreeUtil.skipSiblingsBackward(prevElement, skipClasses);
    }

    return false;
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:21,代码来源:ImpexPsiUtils.java

示例5: handleNoUsageTargets

import com.intellij.psi.PsiWhiteSpace; //导入依赖的package包/类
/**
     * {@link com.intellij.codeInsight.highlighting.HighlightUsagesHandler#handleNoUsageTargets(PsiFile,
     * Editor, SelectionModel, Project)}
     */
    private static void handleNoUsageTargets(PsiFile file, @NotNull Editor editor,
            @NotNull Project project) {
        if (file.findElementAt(editor.getCaretModel().getOffset()) instanceof PsiWhiteSpace) {
            return;
        }
        final SelectionModel selectionModel = editor.getSelectionModel();
        selectionModel.selectWordAtCaret(false);
        String selection = selectionModel.getSelectedText();
//        LOG.assertTrue(selection != null);
        if (selection != null) {
            for (int i = 0; i < selection.length(); i++) {
                if (!Character.isJavaIdentifierPart(selection.charAt(i))) {
                    selectionModel.removeSelection();
                }
            }
            
            searchSelection(editor, project);
            selectionModel.removeSelection();
        }
    }
 
开发者ID:huoguangjin,项目名称:MultiHighlight,代码行数:25,代码来源:MultiHighlightHandler.java

示例6: findCall

import com.intellij.psi.PsiWhiteSpace; //导入依赖的package包/类
public static LuaPsiElement findCall(PsiFile file, int offset) {
    PsiElement func;
    int delta = 0;

    try {
        do {
            func = file.findElementAt(offset - delta++);
        } while (func instanceof PsiWhiteSpace);

        // System.out.println("Element at pos:" + func);

        do {
            if (func instanceof LuaFunctionCallExpression)
                return (LuaPsiElement) func;

            func = func.getContext();
        } while (func != null);

    } catch (Throwable ignored) {
    }

    return null;
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:24,代码来源:LuaParameterInfoHandler.java

示例7: getDescriptionElements

import com.intellij.psi.PsiWhiteSpace; //导入依赖的package包/类
@NotNull
public PsiElement[] getDescriptionElements() {
  ArrayList<PsiElement> array = new ArrayList<PsiElement>();
  for (PsiElement child = getFirstChild(); child != null; child = child.getNextSibling()) {

    if (child instanceof PsiWhiteSpace)
        continue;
    final ASTNode node = child.getNode();
    if (node == null) continue;
    final IElementType i = node.getElementType();
    if (i == LDOC_TAG) break;
    if (i == LDOC_COMMENT_DATA ) {
      array.add(child);
    }
  }
  return LuaPsiUtils.toPsiElementArray(array);
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:18,代码来源:LuaDocCommentImpl.java

示例8: getLanguageRangeAtOffset

import com.intellij.psi.PsiWhiteSpace; //导入依赖的package包/类
@NotNull
public static ItemTextRange<Language> getLanguageRangeAtOffset(@NotNull PsiFile file, int offset) {
    final PsiElement elt = file.findElementAt(offset);
    if (elt == null) return new ItemTextRange<Language>(file.getLanguage(), 0, file.getTextLength());
    if (elt instanceof PsiWhiteSpace) {
        TextRange textRange = elt.getTextRange();
        if (!textRange.contains(offset)) {
            LOG.error("PSI corrupted: in file " + file + " (" + file.getViewProvider().getVirtualFile() + ") offset=" + offset + " returned element " + elt + " with text range " + textRange);
        }
        final int decremented = textRange.getStartOffset() - 1;
        if (decremented >= 0) {
            return getLanguageRangeAtOffset(file, decremented);
        }
    }
    return findLanguageRangeFromElement(elt);
}
 
开发者ID:vsch,项目名称:MissingInActions,代码行数:17,代码来源:EditHelpers.java

示例9: isSimplifiableImplicitReturnNegated

import com.intellij.psi.PsiWhiteSpace; //导入依赖的package包/类
public static boolean isSimplifiableImplicitReturnNegated(GrIfStatement ifStatement) {
  if (ifStatement.getElseBranch() != null) {
    return false;
  }
  GrStatement thenBranch = ifStatement.getThenBranch();
  thenBranch = ConditionalUtils.stripBraces(thenBranch);

  final PsiElement nextStatement =
      PsiTreeUtil.skipSiblingsForward(ifStatement,
          PsiWhiteSpace.class);
  if (!(nextStatement instanceof GrStatement)) {
    return false;
  }
  final GrStatement elseBranch = (GrStatement) nextStatement;
  return ConditionalUtils.isReturn(thenBranch, "false")
      && ConditionalUtils.isReturn(elseBranch, "true");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:GroovyTrivialIfInspection.java

示例10: isAvailable

import com.intellij.psi.PsiWhiteSpace; //导入依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
  final int offset = editor.getCaretModel().getOffset();
  final PsiElement element = file.findElementAt(offset);
  if (element == null ||
      element instanceof PsiWhiteSpace) {
    return false;
  }

  final PsiReference reference = file.findReferenceAt(offset);
  final FileReference fileReference = reference == null ? null : FileReference.findFileReference(reference);

  if (fileReference != null) {
    final FileReferenceSet set = fileReference.getFileReferenceSet();
    final FileReference lastReference = set.getLastReference();
    return set.couldBeConvertedTo(isConvertToRelative()) && lastReference != null &&
           (!isConvertToRelative() && !set.isAbsolutePathReference() || isConvertToRelative() && set.isAbsolutePathReference()) &&
           lastReference.resolve() != null;
  }

  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ConvertAbsolutePathToRelativeIntentionAction.java

示例11: getStatementToolSuppressedIn

import com.intellij.psi.PsiWhiteSpace; //导入依赖的package包/类
@Nullable
public static PsiElement getStatementToolSuppressedIn(@NotNull PsiElement place,
                                                      @NotNull String toolId,
                                                      @NotNull Class<? extends PsiElement> statementClass,
                                                      @NotNull Pattern suppressInLineCommentPattern) {
  PsiElement statement = PsiTreeUtil.getNonStrictParentOfType(place, statementClass);
  if (statement != null) {
    PsiElement prev = PsiTreeUtil.skipSiblingsBackward(statement, PsiWhiteSpace.class);
    if (prev instanceof PsiComment) {
      String text = prev.getText();
      Matcher matcher = suppressInLineCommentPattern.matcher(text);
      if (matcher.matches() && isInspectionToolIdMentioned(matcher.group(1), toolId)) {
        return prev;
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:SuppressionUtil.java

示例12: findSuitableNavigatableForLine

import com.intellij.psi.PsiWhiteSpace; //导入依赖的package包/类
@Nullable
protected Navigatable findSuitableNavigatableForLine(@NotNull Project project, @NotNull VirtualFile file, int line) {
  // lets find first non-ws psi element
  
  final Document doc = FileDocumentManager.getInstance().getDocument(file);
  final PsiFile psi = doc == null ? null : PsiDocumentManager.getInstance(project).getPsiFile(doc);
  if (psi == null) {
    return null;
  }

  int offset = doc.getLineStartOffset(line);
  int endOffset = doc.getLineEndOffset(line);
  for (int i = offset + 1; i < endOffset; i++) {
    PsiElement el = psi.findElementAt(i);
    if (el != null && !(el instanceof PsiWhiteSpace)) {
      offset = el.getTextOffset();
      break;
    }
  }

  return new OpenFileDescriptor(project, file, offset);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:SMTRunnerConsoleProperties.java

示例13: copySpacesAndCommentsBefore

import com.intellij.psi.PsiWhiteSpace; //导入依赖的package包/类
public static PsiElement copySpacesAndCommentsBefore(PsiElement elementToReplace,
                                                        PsiElement[] patternElements,
                                                        String replacementToMake,
                                                        PsiElement elementParent) {
  int i = 0;
  while (true) {    // if it goes out of bounds then deep error happens
    if (!(patternElements[i] instanceof PsiComment || patternElements[i] instanceof PsiWhiteSpace)) {
      break;
    }
    ++i;
    if (patternElements.length == i) {
      break;
    }
  }

  if (patternElements.length == i) {
    Logger logger = Logger.getInstance(StructuralSearchProfile.class.getName());
    logger.error("Unexpected replacement structure:" + replacementToMake);
  }

  if (i != 0) {
    elementParent.addRangeBefore(patternElements[0], patternElements[i - 1], elementToReplace);
  }
  return patternElements[i];
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:ReplacerUtil.java

示例14: findElementInRange

import com.intellij.psi.PsiWhiteSpace; //导入依赖的package包/类
public static <T extends PsiElement> T findElementInRange(@NotNull PsiFile file,
                                                           int startOffset,
                                                           int endOffset,
                                                           @NotNull Class<T> klass,
                                                           @NotNull Language language) {
  PsiElement element1 = file.getViewProvider().findElementAt(startOffset, language);
  PsiElement element2 = file.getViewProvider().findElementAt(endOffset - 1, language);
  if (element1 instanceof PsiWhiteSpace) {
    startOffset = element1.getTextRange().getEndOffset();
    element1 = file.getViewProvider().findElementAt(startOffset, language);
  }
  if (element2 instanceof PsiWhiteSpace) {
    endOffset = element2.getTextRange().getStartOffset();
    element2 = file.getViewProvider().findElementAt(endOffset - 1, language);
  }
  if (element2 == null || element1 == null) return null;
  final PsiElement commonParent = PsiTreeUtil.findCommonParent(element1, element2);
  final T element =
    ReflectionUtil.isAssignable(klass, commonParent.getClass())
    ? (T)commonParent : PsiTreeUtil.getParentOfType(commonParent, klass);
  if (element == null || element.getTextRange().getStartOffset() != startOffset || element.getTextRange().getEndOffset() != endOffset) {
    return null;
  }
  return element;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:CodeInsightUtilCore.java

示例15: SimpleDuplicatesFinder

import com.intellij.psi.PsiWhiteSpace; //导入依赖的package包/类
public SimpleDuplicatesFinder(@NotNull final PsiElement statement1,
                              @NotNull final PsiElement statement2,
                              AbstractVariableData[] variableData, Collection<String> variables) {
  myOutputVariables = variables;
  myParameters = new HashSet<String>();
  for (AbstractVariableData data : variableData) {
    myParameters.add(data.getOriginalName());
  }
  myPattern = new ArrayList<PsiElement>();
  PsiElement sibling = statement1;

  do {
    myPattern.add(sibling);
    if (sibling == statement2) break;
    sibling = PsiTreeUtil.skipSiblingsForward(sibling, PsiWhiteSpace.class, PsiComment.class);
  } while (sibling != null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:SimpleDuplicatesFinder.java


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