本文整理汇总了Java中com.intellij.psi.util.PsiUtilCore.toPsiElementArray方法的典型用法代码示例。如果您正苦于以下问题:Java PsiUtilCore.toPsiElementArray方法的具体用法?Java PsiUtilCore.toPsiElementArray怎么用?Java PsiUtilCore.toPsiElementArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.PsiUtilCore
的用法示例。
在下文中一共展示了PsiUtilCore.toPsiElementArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteElement
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
@Override
public void deleteElement(@NotNull DataContext dataContext) {
List<PsiElement> allElements = Arrays.asList(getSelectedPsiElements());
ArrayList<PsiElement> validElements = new ArrayList<PsiElement>();
for (PsiElement psiElement : allElements) {
if (psiElement != null && psiElement.isValid()) validElements.add(psiElement);
}
final PsiElement[] elements = PsiUtilCore.toPsiElementArray(validElements);
LocalHistoryAction a = LocalHistory.getInstance().startAction(IdeBundle.message("progress.deleting"));
try {
DeleteHandler.deletePsiElement(elements, myProject);
}
finally {
a.finish();
}
}
示例2: showSideEffectsWarning
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
public static RemoveUnusedVariableUtil.RemoveMode showSideEffectsWarning(List<PsiElement> sideEffects,
PsiVariable variable,
Editor editor,
boolean canCopeWithSideEffects,
@NonNls String beforeText,
@NonNls String afterText) {
if (sideEffects.isEmpty()) return RemoveUnusedVariableUtil.RemoveMode.DELETE_ALL;
if (ApplicationManager.getApplication().isUnitTestMode()) {
return canCopeWithSideEffects
? RemoveUnusedVariableUtil.RemoveMode.MAKE_STATEMENT
: RemoveUnusedVariableUtil.RemoveMode.DELETE_ALL;
}
Project project = editor.getProject();
HighlightManager highlightManager = HighlightManager.getInstance(project);
PsiElement[] elements = PsiUtilCore.toPsiElementArray(sideEffects);
EditorColorsManager manager = EditorColorsManager.getInstance();
TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
highlightManager.addOccurrenceHighlights(editor, elements, attributes, true, null);
SideEffectWarningDialog dialog = new SideEffectWarningDialog(project, false, variable, beforeText, afterText, canCopeWithSideEffects);
dialog.show();
int code = dialog.getExitCode();
return RemoveUnusedVariableUtil.RemoveMode.values()[code];
}
示例3: processOccurrences
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
private PsiElement[] processOccurrences() {
List<PsiElement> result = ContainerUtil.newArrayList();
GrReferenceExpression templateRef =
GroovyPsiElementFactory.getInstance(myContext.getProject()).createReferenceExpressionFromText(mySettings.getName());
for (PsiElement occurrence : myOccurrences) {
if (!(occurrence instanceof GrExpression)) {
throw new IncorrectOperationException("Expression occurrence to be replaced is not instance of GroovyPsiElement");
}
final GrExpression replaced = ((GrExpression)occurrence).replaceWithExpression(templateRef, true);
result.add(replaced);
}
return PsiUtilCore.toPsiElementArray(result);
}
示例4: LocalSearchScope
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
public LocalSearchScope(@NotNull PsiElement[] scope, @Nullable final String displayName, final boolean ignoreInjectedPsi) {
myIgnoreInjectedPsi = ignoreInjectedPsi;
myDisplayName = displayName;
Set<PsiElement> localScope = new LinkedHashSet<PsiElement>(scope.length);
for (final PsiElement element : scope) {
LOG.assertTrue(element != null, "null element");
LOG.assertTrue(element.getContainingFile() != null, element.getClass().getName());
if (element instanceof PsiFile) {
for (PsiFile file : ((PsiFile)element).getViewProvider().getAllFiles()) {
if (file == null) throw new IllegalArgumentException("file "+element+" returned null in its getAllFiles()");
localScope.add(file);
}
}
else if (element instanceof StubBasedPsiElement || element.getTextRange() != null){
localScope.add(element);
}
}
myScope = PsiUtilCore.toPsiElementArray(localScope);
}
示例5: getChildren
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
private static PsiElement[] getChildren(PsiElement element) {
PsiElement psiChild = element.getFirstChild();
if (psiChild == null) return PsiElement.EMPTY_ARRAY;
List<PsiElement> result = new ArrayList<>();
while (psiChild != null) {
result.add(psiChild);
psiChild = psiChild.getNextSibling();
}
return PsiUtilCore.toPsiElementArray(result);
}
示例6: getChildren
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
@Override
@NotNull
public PsiElement[] getChildren() {
List<PsiElement> children = ContainerUtil.newArrayList();
ContainerUtil.addAll(children, getChildren(getDocComment(), getModifierList(), getNameIdentifier(), getExtendsList(), getImplementsList()));
ContainerUtil.addAll(children, getOwnFields());
ContainerUtil.addAll(children, getOwnMethods());
ContainerUtil.addAll(children, getOwnInnerClasses());
return PsiUtilCore.toPsiElementArray(children);
}
示例7: getChildren
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
private static PsiElement[] getChildren(PsiElement element) {
PsiElement psiChild = element.getFirstChild();
if (psiChild == null) return new PsiElement[0];
List<PsiElement> result = new ArrayList<PsiElement>();
while (psiChild != null) {
result.add(psiChild);
psiChild = psiChild.getNextSibling();
}
return PsiUtilCore.toPsiElementArray(result);
}
示例8: PyChangeSignatureUsageViewDescriptor
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
public PyChangeSignatureUsageViewDescriptor(UsageInfo[] usages) {
final Collection<PsiElement> declarationsElements = new ArrayList<PsiElement>();
for (UsageInfo info : usages) {
declarationsElements.add(info.getElement());
}
myDeclarationsElements = PsiUtilCore.toPsiElementArray(declarationsElements);
}
示例9: restoreOccurrences
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
@NotNull
protected PsiElement[] restoreOccurrences() {
List<PsiElement> result = ContainerUtil.map(getOccurrenceMarkers(), new Function<RangeMarker, PsiElement>() {
@Override
public PsiElement fun(RangeMarker marker) {
return PsiImplUtil.findElementInRange(myFile, marker.getStartOffset(), marker.getEndOffset(), GrExpression.class);
}
});
return PsiUtilCore.toPsiElementArray(result);
}
示例10: collectFormPsiElements
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
private static PsiElement[] collectFormPsiElements(Collection<AbstractTreeNode> selected) {
Set<PsiElement> result = new HashSet<PsiElement>();
for(AbstractTreeNode node: selected) {
if (node.getValue() instanceof Form) {
Form form = (Form)node.getValue();
result.add(form.getClassToBind());
ContainerUtil.addAll(result, form.getFormFiles());
}
else if (node.getValue() instanceof PsiElement) {
result.add((PsiElement) node.getValue());
}
}
return PsiUtilCore.toPsiElementArray(result);
}
示例11: getElementsIntersectingRange
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
private static PsiElement[] getElementsIntersectingRange(PsiFile file, final int startOffset, final int endOffset) {
final FileViewProvider viewProvider = file.getViewProvider();
final Set<PsiElement> result = new LinkedHashSet<PsiElement>();
for (Language language : viewProvider.getLanguages()) {
final PsiFile psiRoot = viewProvider.getPsi(language);
if (HighlightingLevelManager.getInstance(file.getProject()).shouldInspect(psiRoot)) {
result.addAll(CollectHighlightsUtil.getElementsInRange(psiRoot, startOffset, endOffset, true));
}
}
return PsiUtilCore.toPsiElementArray(result);
}
示例12: collectNonBinaryElements
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
private PsiElement[] collectNonBinaryElements() {
List<PsiElement> result = new ArrayList<PsiElement>();
for (PsiElement element : myElements) {
if (!(element instanceof PsiBinaryFile)) {
result.add(element);
}
}
return PsiUtilCore.toPsiElementArray(result);
}
示例13: MoveClassesOrPackagesProcessor
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
public MoveClassesOrPackagesProcessor(Project project,
PsiElement[] elements,
@NotNull final MoveDestination moveDestination,
boolean searchInComments,
boolean searchInNonJavaFiles,
MoveCallback moveCallback) {
super(project);
final Set<PsiElement> toMove = new LinkedHashSet<PsiElement>();
for (PsiElement element : elements) {
if (element instanceof PsiClassOwner) {
Collections.addAll(toMove, ((PsiClassOwner)element).getClasses());
} else {
toMove.add(element);
}
}
myElementsToMove = PsiUtilCore.toPsiElementArray(toMove);
Arrays.sort(myElementsToMove, new Comparator<PsiElement>() {
@Override
public int compare(PsiElement o1, PsiElement o2) {
if (o1 instanceof PsiClass && o2 instanceof PsiClass) {
final PsiFile containingFile = o1.getContainingFile();
if (Comparing.equal(containingFile, o2.getContainingFile())) {
final VirtualFile virtualFile = containingFile.getVirtualFile();
if (virtualFile != null) {
final String fileName = virtualFile.getNameWithoutExtension();
if (Comparing.strEqual(fileName, ((PsiClass)o1).getName())) return -1;
if (Comparing.strEqual(fileName, ((PsiClass)o2).getName())) return 1;
}
}
}
return 0;
}
});
myMoveDestination = moveDestination;
myTargetPackage = myMoveDestination.getTargetPackage();
mySearchInComments = searchInComments;
mySearchInNonJavaFiles = searchInNonJavaFiles;
myMoveCallback = moveCallback;
}
示例14: getFilteredChildren
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
public static PsiElement[] getFilteredChildren(@NotNull final PsiElement element,
@Nullable Condition<PsiElement> isElementSignificantCondition,
boolean areCommentsSignificant) {
ASTNode[] children1 = element.getNode().getChildren(null);
ArrayList<PsiElement> array = new ArrayList<PsiElement>();
for (ASTNode node : children1) {
final PsiElement child = node.getPsi();
if (!(child instanceof PsiWhiteSpace) && (areCommentsSignificant || !(child instanceof PsiComment)) &&
(isElementSignificantCondition == null || isElementSignificantCondition.value(child))) {
array.add(child);
}
}
return PsiUtilCore.toPsiElementArray(array);
}
示例15: filterInvalidElements
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
@Nullable
private static PsiElement[] filterInvalidElements(final PsiElement[] elements) {
if (elements == null || elements.length == 0) {
return null;
}
final List<PsiElement> validElements = new ArrayList<PsiElement>(elements.length);
for (final PsiElement element : elements) {
if (element.isValid()) {
validElements.add(element);
}
}
return validElements.size() == elements.length ? elements : PsiUtilCore.toPsiElementArray(validElements);
}