本文整理汇总了Java中com.intellij.psi.SmartPointerManager.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java SmartPointerManager.getInstance方法的具体用法?Java SmartPointerManager.getInstance怎么用?Java SmartPointerManager.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.SmartPointerManager
的用法示例。
在下文中一共展示了SmartPointerManager.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GroovyResolveSnapshot
import com.intellij.psi.SmartPointerManager; //导入方法依赖的package包/类
public GroovyResolveSnapshot(final PsiElement scope) {
myProject = scope.getProject();
myDocument = PsiDocumentManager.getInstance(myProject).getDocument(scope.getContainingFile());
final SmartPointerManager pointerManager = SmartPointerManager.getInstance(myProject);
final Map<PsiElement, SmartPsiElementPointer> pointers = new HashMap<PsiElement, SmartPsiElementPointer>();
scope.accept(new GroovyPsiElementVisitor(new GroovyRecursiveElementVisitor() {
@Override
public void visitReferenceExpression(GrReferenceExpression refExpr) {
if (!refExpr.isQualified()) {
PsiElement resolved = refExpr.resolve();
if (resolved instanceof GrMember) {
SmartPsiElementPointer key = pointerManager.createSmartPsiElementPointer(refExpr);
SmartPsiElementPointer value = pointers.get(resolved);
if (value == null) {
value = pointerManager.createSmartPsiElementPointer(resolved);
pointers.put(resolved, value);
}
myReferencesMap.put(key, value);
}
}
super.visitReferenceExpression(refExpr);
}
}));
}
示例2: PropertyQuickFix
import com.intellij.psi.SmartPointerManager; //导入方法依赖的package包/类
public PropertyQuickFix(
@NotNull final PhpClass primaryClass,
@NotNull final String propertyName,
@NotNull final String propertyType
) {
final SmartPointerManager pointerManager = SmartPointerManager.getInstance(primaryClass.getProject());
primaryClassPointer = pointerManager.createSmartPsiElementPointer(primaryClass);
this.propertyName = propertyName;
this.propertyType = propertyType;
familyName = String.format("Declare @property $%s on %s class", propertyName, primaryClass.getName());
}
示例3: convertToSmartPointers
import com.intellij.psi.SmartPointerManager; //导入方法依赖的package包/类
@NotNull
private static List<SmartPsiElementPointer<PsiElement>> convertToSmartPointers(@NotNull PsiElement[] primaryElements) {
if (primaryElements.length == 0) return Collections.emptyList();
final SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(primaryElements[0].getProject());
return ContainerUtil.mapNotNull(primaryElements, new Function<PsiElement, SmartPsiElementPointer<PsiElement>>() {
@Override
public SmartPsiElementPointer<PsiElement> fun(final PsiElement s) {
return smartPointerManager.createSmartPsiElementPointer(s);
}
});
}
示例4: disposeSmartPointers
import com.intellij.psi.SmartPointerManager; //导入方法依赖的package包/类
private void disposeSmartPointers() {
SmartPointerManager pointerManager = SmartPointerManager.getInstance(getProject());
for (Usage usage : myUsageNodes.keySet()) {
if (usage instanceof UsageInfo2UsageAdapter) {
SmartPsiElementPointer<?> pointer = ((UsageInfo2UsageAdapter)usage).getUsageInfo().getSmartPointer();
pointerManager.removePointer(pointer);
}
}
}
示例5: calcPsiTargets
import com.intellij.psi.SmartPointerManager; //导入方法依赖的package包/类
private static <T> List<SmartPsiElementPointer> calcPsiTargets(Project project, Collection<? extends T> targets,
NotNullFunction<T, Collection<? extends PsiElement>> converter) {
SmartPointerManager manager = SmartPointerManager.getInstance(project);
Set<PsiElement> elements = new THashSet<PsiElement>();
final List<SmartPsiElementPointer> list = new ArrayList<SmartPsiElementPointer>(targets.size());
for (final T target : targets) {
for (final PsiElement psiElement : converter.fun(target)) {
if (elements.add(psiElement) && psiElement.isValid()) {
list.add(manager.createSmartPsiElementPointer(psiElement));
}
}
}
return list;
}
示例6: disposeSmartPointers
import com.intellij.psi.SmartPointerManager; //导入方法依赖的package包/类
private void disposeSmartPointers() {
SmartPointerManager pointerManager = SmartPointerManager.getInstance(getProject());
for (Usage usage : myUsageNodes.keySet()) {
if (usage instanceof UsageInfo2UsageAdapter) {
SmartPsiElementPointer<?> pointer = ((UsageInfo2UsageAdapter)usage).getUsageInfo().getSmartPointer();
if (pointer != null) {
pointerManager.removePointer(pointer);
}
}
}
}
示例7: IntroduceTempVariableFix
import com.intellij.psi.SmartPointerManager; //导入方法依赖的package包/类
public IntroduceTempVariableFix(DotNetExpression qualifier, CSharpFieldDeclaration field, DotNetExpression rightExpression, String operatorText)
{
myOperatorText = operatorText;
SmartPointerManager manager = SmartPointerManager.getInstance(qualifier.getProject());
myQualifierPointer = manager.createSmartPsiElementPointer(qualifier);
myFieldPointer = manager.createSmartPsiElementPointer(field);
myValueExpression = manager.createSmartPsiElementPointer(rightExpression);
}
示例8: convertToSmartPointers
import com.intellij.psi.SmartPointerManager; //导入方法依赖的package包/类
@Nonnull
private static List<SmartPsiElementPointer<PsiElement>> convertToSmartPointers(@Nonnull PsiElement[] primaryElements) {
if (primaryElements.length == 0) return Collections.emptyList();
final SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(primaryElements[0].getProject());
return ContainerUtil.mapNotNull(primaryElements, new Function<PsiElement, SmartPsiElementPointer<PsiElement>>() {
@Override
public SmartPsiElementPointer<PsiElement> fun(final PsiElement s) {
return smartPointerManager.createSmartPsiElementPointer(s);
}
});
}
示例9: withRange
import com.intellij.psi.SmartPointerManager; //导入方法依赖的package包/类
@Nonnull
ShredImpl withRange(@Nonnull TextRange rangeInDecodedPSI, @Nonnull TextRange rangeInHostElementPSI, @Nonnull PsiLanguageInjectionHost newHost) {
SmartPsiFileRange rangeMarker = relevantRangeInHost;
Segment oldRangeInHostElementPSI = calcRangeInsideHostElement(false);
SmartPointerManager pointerManager = SmartPointerManager.getInstance(rangeMarker.getProject());
SmartPsiElementPointer<PsiLanguageInjectionHost> newHostPointer = pointerManager.createSmartPsiElementPointer(newHost);
if (!rangeInHostElementPSI.equals(TextRange.create(oldRangeInHostElementPSI))) {
Segment hostElementRange = newHostPointer.getRange();
rangeMarker =
((SmartPointerManagerImpl)pointerManager).createSmartPsiFileRangePointer(rangeMarker.getContainingFile(), rangeInHostElementPSI.shiftRight(hostElementRange.getStartOffset()), true);
}
return new ShredImpl(rangeMarker, newHostPointer, prefix, suffix, rangeInDecodedPSI, usePsiRange, isOneLine);
}
示例10: addNewRegions
import com.intellij.psi.SmartPointerManager; //导入方法依赖的package包/类
private List<FoldRegion> addNewRegions(@NotNull EditorFoldingInfo info,
@NotNull FoldingModelEx foldingModel,
FoldingUpdate.FoldingMap elementsToFold, @NotNull Map<TextRange, Boolean> rangeToExpandStatusMap,
@NotNull Map<FoldRegion, Boolean> shouldExpand,
@NotNull Map<FoldingGroup, Boolean> groupExpand) {
List<FoldRegion> newRegions = newArrayList();
SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(myProject);
for (PsiElement element : elementsToFold.keySet()) {
ProgressManager.checkCanceled();
final Collection<FoldingDescriptor> descriptors = elementsToFold.get(element);
for (FoldingDescriptor descriptor : descriptors) {
FoldingGroup group = descriptor.getGroup();
TextRange range = descriptor.getRange();
String placeholder = descriptor.getPlaceholderText();
if (range.getEndOffset() > myEditor.getDocument().getTextLength()) {
LOG.error(String.format("Invalid folding descriptor detected (%s). It ends beyond the document range (%d)",
descriptor, myEditor.getDocument().getTextLength()));
continue;
}
FoldRegion region = foldingModel.createFoldRegion(range.getStartOffset(), range.getEndOffset(),
placeholder == null ? "..." : placeholder,
group,
descriptor.isNonExpandable());
if (region == null) continue;
PsiElement psi = descriptor.getElement().getPsi();
if (psi == null || !psi.isValid() || !foldingModel.addFoldRegion(region) || !myFile.isValid()) {
region.dispose();
continue;
}
info.addRegion(region, smartPointerManager.createSmartPsiElementPointer(psi));
newRegions.add(region);
boolean expandStatus = !descriptor.isNonExpandable() && shouldExpandNewRegion(element, range, rangeToExpandStatusMap);
if (group == null) {
shouldExpand.put(region, expandStatus);
}
else {
final Boolean alreadyExpanded = groupExpand.get(group);
groupExpand.put(group, alreadyExpanded == null ? expandStatus : alreadyExpanded.booleanValue() || expandStatus);
}
}
}
return newRegions;
}
示例11: ReferenceDiagramDataModel
import com.intellij.psi.SmartPointerManager; //导入方法依赖的package包/类
public ReferenceDiagramDataModel(Project project, PsiClass psiClass) {
super(project, ReferenceDiagramProvider.getInstance());
spManager = SmartPointerManager.getInstance(getProject());
init(psiClass);
}
示例12: addNewRegions
import com.intellij.psi.SmartPointerManager; //导入方法依赖的package包/类
private List<FoldRegion> addNewRegions(@NotNull EditorFoldingInfo info,
@NotNull FoldingModelEx foldingModel,
@NotNull Map<TextRange, Boolean> rangeToExpandStatusMap,
@NotNull Map<FoldRegion, Boolean> shouldExpand,
@NotNull Map<FoldingGroup, Boolean> groupExpand) {
List<FoldRegion> newRegions = newArrayList();
SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(myProject);
for (PsiElement element : myElementsToFoldMap.keySet()) {
ProgressManager.checkCanceled();
final Collection<FoldingDescriptor> descriptors = myElementsToFoldMap.get(element);
for (FoldingDescriptor descriptor : descriptors) {
FoldingGroup group = descriptor.getGroup();
TextRange range = descriptor.getRange();
String placeholder = descriptor.getPlaceholderText();
if (range.getEndOffset() > myEditor.getDocument().getTextLength()) {
LOG.error(String.format("Invalid folding descriptor detected (%s). It ends beyond the document range (%d)",
descriptor, myEditor.getDocument().getTextLength()));
continue;
}
FoldRegion region = foldingModel.createFoldRegion(range.getStartOffset(), range.getEndOffset(),
placeholder == null ? "..." : placeholder,
group,
descriptor.isNonExpandable());
if (region == null) continue;
PsiElement psi = descriptor.getElement().getPsi();
if (psi == null || !psi.isValid() || !foldingModel.addFoldRegion(region)) {
region.dispose();
continue;
}
info.addRegion(region, smartPointerManager.createSmartPsiElementPointer(psi, myFile));
newRegions.add(region);
boolean expandStatus = !descriptor.isNonExpandable() && shouldExpandNewRegion(element, range, rangeToExpandStatusMap);
if (group == null) {
shouldExpand.put(region, expandStatus);
}
else {
final Boolean alreadyExpanded = groupExpand.get(group);
groupExpand.put(group, alreadyExpanded == null ? expandStatus : alreadyExpanded.booleanValue() || expandStatus);
}
}
}
return newRegions;
}
示例13: createGutterIconRenderer
import com.intellij.psi.SmartPointerManager; //导入方法依赖的package包/类
private MyNavigationGutterIconRenderer createGutterIconRenderer(@NotNull Project project) {
checkBuilt();
final SmartPointerManager manager = SmartPointerManager.getInstance(project);
NotNullLazyValue<List<SmartPsiElementPointer>> pointers = new NotNullLazyValue<List<SmartPsiElementPointer>>() {
@NotNull
public List<SmartPsiElementPointer> compute() {
Set<PsiElement> elements = new THashSet<PsiElement>();
Collection<? extends T> targets = myTargets.getValue();
final List<SmartPsiElementPointer> list = new ArrayList<SmartPsiElementPointer>(targets.size());
for (final T target : targets) {
for (final PsiElement psiElement : myConverter.fun(target)) {
if (elements.add(psiElement) && psiElement.isValid()) {
list.add(manager.createSmartPsiElementPointer(psiElement));
}
}
}
return list;
}
};
final boolean empty = isEmpty();
if (myTooltipText == null && !myLazy) {
final SortedSet<String> names = new TreeSet<String>();
for (T t : myTargets.getValue()) {
final String text = myNamer.fun(t);
if (text != null) {
names.add(MessageFormat.format(PATTERN, text));
}
}
@NonNls StringBuilder sb = new StringBuilder("<html><body>");
if (myTooltipTitle != null) {
sb.append(myTooltipTitle).append("<br>");
}
for (String name : names) {
sb.append(name).append("<br>");
}
sb.append("</body></html>");
myTooltipText = sb.toString();
}
Computable<PsiElementListCellRenderer> renderer =
myCellRenderer == null ? new Computable<PsiElementListCellRenderer>() {
@Override
public PsiElementListCellRenderer compute() {
return new DefaultPsiElementCellRenderer();
}
} : myCellRenderer;
return new MyNavigationGutterIconRenderer(this, myAlignment, myIcon, myTooltipText, pointers, renderer, empty);
}
示例14: createGutterIconRenderer
import com.intellij.psi.SmartPointerManager; //导入方法依赖的package包/类
private MyNavigationGutterIconRenderer createGutterIconRenderer(@Nonnull Project project) {
checkBuilt();
final SmartPointerManager manager = SmartPointerManager.getInstance(project);
NotNullLazyValue<List<SmartPsiElementPointer>> pointers = new NotNullLazyValue<List<SmartPsiElementPointer>>() {
@Nonnull
public List<SmartPsiElementPointer> compute() {
Set<PsiElement> elements = new THashSet<PsiElement>();
Collection<? extends T> targets = myTargets.getValue();
final List<SmartPsiElementPointer> list = new ArrayList<SmartPsiElementPointer>(targets.size());
for (final T target : targets) {
for (final PsiElement psiElement : myConverter.fun(target)) {
if (elements.add(psiElement) && psiElement.isValid()) {
list.add(manager.createSmartPsiElementPointer(psiElement));
}
}
}
return list;
}
};
final boolean empty = isEmpty();
if (myTooltipText == null && !myLazy) {
final SortedSet<String> names = new TreeSet<String>();
for (T t : myTargets.getValue()) {
final String text = myNamer.fun(t);
if (text != null) {
names.add(MessageFormat.format(PATTERN, text));
}
}
@NonNls StringBuilder sb = new StringBuilder("<html><body>");
if (myTooltipTitle != null) {
sb.append(myTooltipTitle).append("<br>");
}
for (String name : names) {
sb.append(name).append("<br>");
}
sb.append("</body></html>");
myTooltipText = sb.toString();
}
Computable<PsiElementListCellRenderer> renderer =
myCellRenderer == null ? new Computable<PsiElementListCellRenderer>() {
@Override
public PsiElementListCellRenderer compute() {
return new DefaultPsiElementCellRenderer();
}
} : myCellRenderer;
return new MyNavigationGutterIconRenderer(this, myAlignment, myIcon, myTooltipText, pointers, renderer, empty);
}
示例15: addNewRegions
import com.intellij.psi.SmartPointerManager; //导入方法依赖的package包/类
private List<FoldRegion> addNewRegions(@Nonnull EditorFoldingInfo info,
@Nonnull FoldingModelEx foldingModel,
@Nonnull Map<TextRange, Boolean> rangeToExpandStatusMap,
@Nonnull Map<FoldRegion, Boolean> shouldExpand,
@Nonnull Map<FoldingGroup, Boolean> groupExpand) {
List<FoldRegion> newRegions = new ArrayList<>();
SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(myProject);
for (FoldingUpdate.RegionInfo regionInfo : myRegionInfos) {
ProgressManager.checkCanceled();
FoldingDescriptor descriptor = regionInfo.descriptor;
FoldingGroup group = descriptor.getGroup();
TextRange range = descriptor.getRange();
String placeholder = null;
try {
placeholder = descriptor.getPlaceholderText();
}
catch (IndexNotReadyException ignore) {
}
if (range.getEndOffset() > myEditor.getDocument().getTextLength()) {
LOG.error(String.format("Invalid folding descriptor detected (%s). It ends beyond the document range (%d)",
descriptor, myEditor.getDocument().getTextLength()));
continue;
}
FoldRegion region = foldingModel.createFoldRegion(range.getStartOffset(), range.getEndOffset(),
placeholder == null ? "..." : placeholder,
group,
descriptor.isNonExpandable());
if (region == null) continue;
if (descriptor.isNonExpandable()) region.putUserData(FoldingModelImpl.SELECT_REGION_ON_CARET_NEARBY, Boolean.TRUE);
PsiElement psi = descriptor.getElement().getPsi();
if (psi == null || !psi.isValid() || !myFile.isValid()) {
region.dispose();
continue;
}
if (descriptor.canBeRemovedWhenCollapsed()) region.putUserData(CAN_BE_REMOVED_WHEN_COLLAPSED, Boolean.TRUE);
region.putUserData(COLLAPSED_BY_DEFAULT, regionInfo.collapsedByDefault);
region.putUserData(SIGNATURE, regionInfo.signature);
info.addRegion(region, smartPointerManager.createSmartPsiElementPointer(psi));
newRegions.add(region);
boolean expandStatus = !descriptor.isNonExpandable() && shouldExpandNewRegion(range, rangeToExpandStatusMap,
regionInfo.collapsedByDefault);
if (group == null) {
shouldExpand.put(region, expandStatus);
}
else {
final Boolean alreadyExpanded = groupExpand.get(group);
groupExpand.put(group, alreadyExpanded == null ? expandStatus : alreadyExpanded.booleanValue() || expandStatus);
}
}
return newRegions;
}