本文整理匯總了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();
}
示例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();
}
}
示例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;
}
示例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();
}
}
示例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;
}
示例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);
}
示例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);
}
示例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");
}
示例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;
}
示例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);
}
示例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];
}
示例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;
}
示例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);
}