Java 类com.intellij.psi.SmartPointerManager 实例源码

项目:intellij-ce-playground    文件:LocalQuickFixOnPsiElement.java   
public LocalQuickFixOnPsiElement(PsiElement startElement, PsiElement endElement) {
  if (startElement == null || endElement == null) {
    myStartElement = myEndElement = null;
    return;
  }
  LOG.assertTrue(startElement.isValid());
  PsiFile startContainingFile = startElement.getContainingFile();
  PsiFile endContainingFile = startElement == endElement ? startContainingFile : endElement.getContainingFile();
  if (startElement != endElement) {
    LOG.assertTrue(endElement.isValid());
    LOG.assertTrue(startContainingFile == endContainingFile, "Both elements must be from the same file");
  }
  Project project = startContainingFile == null ? startElement.getProject() : startContainingFile.getProject(); // containingFile can be null for a directory
  myStartElement = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(startElement, startContainingFile);
  myEndElement = endElement == startElement ? null : SmartPointerManager.getInstance(project).createSmartPsiElementPointer(endElement, endContainingFile);
}
项目:intellij-ce-playground    文件:DocumentationComponent.java   
public void setData(PsiElement _element, String text, final boolean clearHistory, String effectiveExternalUrl, String ref) {
  myEffectiveExternalUrl = effectiveExternalUrl;
  if (myElement != null) {
    myBackStack.push(saveContext());
    myForwardStack.clear();
  }

  final SmartPsiElementPointer element = _element != null && _element.isValid()
                                         ? SmartPointerManager.getInstance(_element.getProject()).createSmartPsiElementPointer(_element)
                                         : null;

  if (element != null) {
    setElement(element);
  }

  myIsEmpty = false;
  updateControlState();
  setDataInternal(element, text, new Rectangle(0, 0), ref);

  if (clearHistory) clearHistory();
}
项目:intellij-ce-playground    文件:PsiTreeAnchorizer.java   
@Override
public Object createAnchor(Object element) {
  if (element instanceof PsiElement) {
    final PsiElement psiElement = (PsiElement)element;

    return ApplicationManager.getApplication().runReadAction(new Computable<Object>() {
      @Override
      public Object compute() {
        SmartPointerWrapper pointer = psiElement.getUserData(PSI_ANCHORIZER_POINTER);
        if (!psiElement.isValid()) {
          return pointer != null ? pointer : psiElement;
        }

        if (pointer == null || pointer.myPointer.getElement() != psiElement) {
          Project project = psiElement.getProject();
          SmartPsiElementPointer<PsiElement> psiElementPointer = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(psiElement);
          pointer = new SmartPointerWrapper(psiElementPointer);
          psiElement.putUserData(PSI_ANCHORIZER_POINTER, pointer);
        }
        return pointer;
      }
    });
  }
  return super.createAnchor(element);
}
项目:intellij-ce-playground    文件:UsageHolder.java   
public UsageHolder(PsiElement element, UsageInfo[] usageInfos) {
  Project project = element.getProject();
  myElementPointer = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(element);

  GeneratedSourcesFilter[] filters = GeneratedSourcesFilter.EP_NAME.getExtensions();
  for (UsageInfo usageInfo : usageInfos) {
    if (!(usageInfo instanceof SafeDeleteReferenceUsageInfo)) continue;
    final SafeDeleteReferenceUsageInfo usage = (SafeDeleteReferenceUsageInfo)usageInfo;
    if (usage.getReferencedElement() != element) continue;

    if (!usage.isSafeDelete()) {
      myUnsafeUsages++;
      if (usage.isNonCodeUsage || isInGeneratedCode(usage, project, filters)) {
        myNonCodeUnsafeUsages++;
      }
    }
  }
}
项目:intellij-ce-playground    文件:GroovyResolveSnapshot.java   
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);
    }
  }));
}
项目:tools-idea    文件:LocalQuickFixOnPsiElement.java   
public LocalQuickFixOnPsiElement(PsiElement startElement, PsiElement endElement) {
  if (startElement == null || endElement == null) {
    myStartElement = myEndElement = null;
    return;
  }
  LOG.assertTrue(startElement.isValid());
  PsiFile startContainingFile = startElement.getContainingFile();
  PsiFile endContainingFile = startElement == endElement ? startContainingFile : endElement.getContainingFile();
  if (startElement != endElement) {
    LOG.assertTrue(endElement.isValid());
    LOG.assertTrue(startContainingFile == endContainingFile, "Both elements must be from the same file");
  }
  Project project = startContainingFile == null ? startElement.getProject() : startContainingFile.getProject(); // containingFile can be null for a directory
  myStartElement = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(startElement, startContainingFile);
  myEndElement = endElement == startElement ? null : SmartPointerManager.getInstance(project).createSmartPsiElementPointer(endElement, endContainingFile);
}
项目:tools-idea    文件:DocumentationComponent.java   
public void setData(PsiElement _element, String text, final boolean clearHistory) {
  if (myElement != null) {
    myBackStack.push(saveContext());
    myForwardStack.clear();
  }

  final SmartPsiElementPointer element = _element != null && _element.isValid()
                                         ? SmartPointerManager.getInstance(_element.getProject()).createSmartPsiElementPointer(_element)
                                         : null;

  if (element != null) {
    myElement = element;
  }

  myIsEmpty = false;
  updateControlState();
  setDataInternal(element, text, new Rectangle(0, 0));

  if (clearHistory) clearHistory();
}
项目:tools-idea    文件:GroovyResolveSnapshot.java   
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);
    }
  }));
}
项目:consulo    文件:LocalQuickFixOnPsiElement.java   
public LocalQuickFixOnPsiElement(PsiElement startElement, PsiElement endElement) {
  if (startElement == null || endElement == null) {
    myStartElement = myEndElement = null;
    return;
  }
  LOG.assertTrue(startElement.isValid());
  PsiFile startContainingFile = startElement.getContainingFile();
  PsiFile endContainingFile = startElement == endElement ? startContainingFile : endElement.getContainingFile();
  if (startElement != endElement) {
    LOG.assertTrue(endElement.isValid());
    LOG.assertTrue(startContainingFile == endContainingFile, "Both elements must be from the same file");
  }
  Project project = startContainingFile == null ? startElement.getProject() : startContainingFile.getProject(); // containingFile can be null for a directory
  myStartElement = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(startElement, startContainingFile);
  myEndElement = endElement == startElement ? null : SmartPointerManager.getInstance(project).createSmartPsiElementPointer(endElement, endContainingFile);
}
项目:consulo    文件:LineMarkerInfo.java   
/**
 * Creates a line marker info for the element.
 * @param element         the element for which the line marker is created.
 * @param range     the range (relative to beginning of file) with which the marker is associated
 * @param icon            the icon to show in the gutter for the line marker
 * @param updatePass      the ID of the daemon pass during which the marker should be recalculated
 * @param tooltipProvider the callback to calculate the tooltip for the gutter icon
 * @param navHandler      the handler executed when the gutter icon is clicked
 */
public LineMarkerInfo(@Nonnull T element,
                      @Nonnull TextRange range,
                      Icon icon,
                      int updatePass,
                      @Nullable Function<? super T, String> tooltipProvider,
                      @Nullable GutterIconNavigationHandler<T> navHandler,
                      @Nonnull GutterIconRenderer.Alignment alignment) {
  myIcon = icon;
  myTooltipProvider = tooltipProvider;
  myIconAlignment = alignment;
  elementRef = SmartPointerManager.getInstance(element.getProject()).createSmartPsiElementPointer(element);
  myNavigationHandler = navHandler;
  startOffset = range.getStartOffset();
  endOffset = range.getEndOffset();
  this.updatePass = 11; //Pass.LINE_MARKERS;
}
项目:consulo    文件:ElementCreator.java   
public PsiElement[] tryCreate(@Nonnull final String inputString) {
  if (inputString.length() == 0) {
    Messages.showMessageDialog(myProject, IdeBundle.message("error.name.should.be.specified"), CommonBundle.getErrorTitle(), Messages.getErrorIcon());
    return PsiElement.EMPTY_ARRAY;
  }

  Ref<List<SmartPsiElementPointer>> createdElements = Ref.create();
  Exception exception = executeCommand(getActionName(inputString), () -> {
    PsiElement[] psiElements = create(inputString);
    SmartPointerManager manager = SmartPointerManager.getInstance(myProject);
    createdElements.set(ContainerUtil.map(psiElements, manager::createSmartPsiElementPointer));
  });
  if (exception != null) {
    handleException(exception);
    return PsiElement.EMPTY_ARRAY;
  }

  return ContainerUtil.mapNotNull(createdElements.get(), SmartPsiElementPointer::getElement).toArray(PsiElement.EMPTY_ARRAY);
}
项目:consulo    文件:DocumentationComponent.java   
public void setData(PsiElement _element, String text, final boolean clearHistory, String effectiveExternalUrl, String ref) {
  if (myElement != null) {
    myBackStack.push(saveContext());
    myForwardStack.clear();
  }
  myEffectiveExternalUrl = effectiveExternalUrl;

  final SmartPsiElementPointer element = _element != null && _element.isValid() ? SmartPointerManager.getInstance(_element.getProject()).createSmartPsiElementPointer(_element) : null;

  if (element != null) {
    setElement(element);
  }

  myIsEmpty = false;
  updateControlState();
  setDataInternal(element, text, new Rectangle(0, 0), ref);

  if (clearHistory) clearHistory();
}
项目:consulo    文件:UsageHolder.java   
public UsageHolder(PsiElement element, UsageInfo[] usageInfos) {
  Project project = element.getProject();
  myElementPointer = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(element);

  GeneratedSourcesFilter[] filters = GeneratedSourcesFilter.EP_NAME.getExtensions();
  for (UsageInfo usageInfo : usageInfos) {
    if (!(usageInfo instanceof SafeDeleteReferenceUsageInfo)) continue;
    final SafeDeleteReferenceUsageInfo usage = (SafeDeleteReferenceUsageInfo)usageInfo;
    if (usage.getReferencedElement() != element) continue;

    if (!usage.isSafeDelete()) {
      myUnsafeUsages++;
      if (usage.isNonCodeUsage || isInGeneratedCode(usage, project, filters)) {
        myNonCodeUnsafeUsages++;
      }
    }
  }
}
项目:consulo-xml    文件:XmlEntityCache.java   
public static void cacheParticularEntity(PsiFile file, XmlEntityDecl decl)
{
    synchronized(LOCK)
    {
        final Map<String, CachedValue<XmlEntityDecl>> cachingMap = getCachingMap(file);
        final String name = decl.getName();
        if(cachingMap.containsKey(name))
        {
            return;
        }
        final SmartPsiElementPointer declPointer = SmartPointerManager.getInstance(file.getProject()).createSmartPsiElementPointer(decl);

        cachingMap.put(name, CachedValuesManager.getManager(file.getProject()).createCachedValue(() ->
        {
            PsiElement declElement = declPointer.getElement();
            if(declElement instanceof XmlEntityDecl && declElement.isValid() && name.equals(((XmlEntityDecl) declElement).getName()))
            {
                return new CachedValueProvider.Result<>((XmlEntityDecl) declElement, declElement);
            }
            cachingMap.put(name, null);
            return new CachedValueProvider.Result<>(null, ModificationTracker.NEVER_CHANGED);
        }, false));
    }
}
项目:consulo-xml    文件:XmlUnusedNamespaceInspection.java   
@Nullable
public SmartPsiElementPointer<XmlTag> doFix(Project project, ProblemDescriptor descriptor, boolean reformat) {
  PsiElement element = descriptor.getPsiElement();
  if (element instanceof XmlAttributeValue) {
    element = element.getParent();
  }
  else if (!(element instanceof XmlAttribute)) {
    return null;
  }
  XmlAttribute attribute = (XmlAttribute)element;
  XmlTag parent = attribute.getParent();

  if (!FileModificationService.getInstance().prepareFileForWrite(parent.getContainingFile())) return null;

  SmartPsiElementPointer<XmlTag> pointer = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(parent);

  doRemove(project, attribute, parent);

  if (reformat) {
    reformatStartTag(project, pointer);
  }
  return pointer;
}
项目:consulo-javascript    文件:DescriptionByAnotherPsiElementService.java   
public void tryToInit()
{
    if(myProvider == null || myElementPointer != null)
    {
        return;
    }

    ApplicationManager.getApplication().runReadAction(new Runnable()
    {
        @Override
        public void run()
        {
            PsiElement psiElementById = myProvider.getPsiElementById(myPsiElementId, myProject);
            if(psiElementById == null)
            {
                return;
            }
            myElementPointer = SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(psiElementById);
        }
    });
}
项目:consulo-java    文件:ClassInheritorsSearch.java   
public static Query<PsiClass> search(@NotNull SearchParameters parameters)
{
    return INSTANCE.createUniqueResultsQuery(parameters, ContainerUtil.<SmartPsiElementPointer<PsiClass>>canonicalStrategy(), new Function<PsiClass, SmartPsiElementPointer<PsiClass>>()
    {
        @Override
        public SmartPsiElementPointer<PsiClass> fun(final PsiClass psiClass)
        {
            return ApplicationManager.getApplication().runReadAction(new Computable<SmartPsiElementPointer<PsiClass>>()
            {
                @Override
                public SmartPsiElementPointer<PsiClass> compute()
                {
                    return SmartPointerManager.getInstance(psiClass.getProject()).createSmartPsiElementPointer(psiClass);
                }
            });
        }
    });
}
项目:consulo-java    文件:MethodGroupingRule.java   
@Override
public int compareTo(UsageGroup usageGroup) {
  if (!(usageGroup instanceof MethodUsageGroup)) {
    LOG.error("MethodUsageGroup expected but " + usageGroup.getClass() + " found");
  }
  MethodUsageGroup other = (MethodUsageGroup)usageGroup;
  if (SmartPointerManager.getInstance(myProject).pointToTheSameElement(myMethodPointer, other.myMethodPointer)) {
    return 0;
  }
  if (!UsageViewSettings.getInstance().IS_SORT_MEMBERS_ALPHABETICALLY) {
    Segment segment1 = myMethodPointer.getRange();
    Segment segment2 = other.myMethodPointer.getRange();
    if (segment1 != null && segment2 != null) {
      return segment1.getStartOffset() - segment2.getStartOffset();
    }
  }

  return myName.compareToIgnoreCase(other.myName);
}
项目:laravel-insight    文件:PropertyQuickFix.java   
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());
}
项目:intellij-ce-playground    文件:ClassInheritorsSearch.java   
public static Query<PsiClass> search(@NotNull SearchParameters parameters) {
  return INSTANCE.createUniqueResultsQuery(parameters, ContainerUtil.<SmartPsiElementPointer<PsiClass>>canonicalStrategy(), new Function<PsiClass, SmartPsiElementPointer<PsiClass>>() {
    @Override
    public SmartPsiElementPointer<PsiClass> fun(final PsiClass psiClass) {
      return ApplicationManager.getApplication().runReadAction(new Computable<SmartPsiElementPointer<PsiClass>>() {
        @Override
        public SmartPsiElementPointer<PsiClass> compute() {
          return SmartPointerManager.getInstance(psiClass.getProject()).createSmartPsiElementPointer(psiClass);
        }
      });
    }
  });
}
项目:intellij-ce-playground    文件:PsiElementUsageGroupBase.java   
public PsiElementUsageGroupBase(@NotNull T element, Icon icon) {
  String myName = element.getName();
  if (myName == null) myName = "<anonymous>";
  this.myName = myName;
  myElementPointer = SmartPointerManager.getInstance(element.getProject()).createSmartPsiElementPointer(element);

  myIcon = icon;
}
项目:intellij-ce-playground    文件:UsageInfoToUsageConverter.java   
@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);
          }
        });
}
项目:intellij-ce-playground    文件:UsageViewImpl.java   
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);
    }
  }
}
项目:intellij-ce-playground    文件:ElementBase.java   
@Nullable
public PsiElement getElement() {
  if (myPointer.getProject().isDisposed()) return null;
  PsiElement element = myPointer.getElement();
  SmartPointerManager.getInstance(myPointer.getProject()).removePointer(myPointer);
  return element;
}
项目:intellij-ce-playground    文件:CoreProjectEnvironment.java   
public CoreProjectEnvironment(@NotNull Disposable parentDisposable, @NotNull CoreApplicationEnvironment applicationEnvironment) {
  myParentDisposable = parentDisposable;
  myEnvironment = applicationEnvironment;
  myProject = createProject(myEnvironment.getApplication().getPicoContainer(), myParentDisposable);

  preregisterServices();

  myFileIndexFacade = createFileIndexFacade();
  myMessageBus = MessageBusFactory.newMessageBus("CoreProjectEnvironment");

  PsiModificationTrackerImpl modificationTracker = new PsiModificationTrackerImpl(myProject);
  myProject.registerService(PsiModificationTracker.class, modificationTracker);
  myProject.registerService(FileIndexFacade.class, myFileIndexFacade);
  myProject.registerService(ResolveCache.class, new ResolveCache(myMessageBus));

  myPsiManager = new PsiManagerImpl(myProject, null, null, myFileIndexFacade, myMessageBus, modificationTracker);
  ((FileManagerImpl) myPsiManager.getFileManager()).markInitialized();
  registerProjectComponent(PsiManager.class, myPsiManager);
  myProject.registerService(SmartPointerManager.class, SmartPointerManagerImpl.class);
  registerProjectComponent(PsiDocumentManager.class, new CorePsiDocumentManager(myProject, myPsiManager,
                                                                                myMessageBus,
                                                                                new MockDocumentCommitProcessor()));

  myProject.registerService(ResolveScopeManager.class, createResolveScopeManager(myPsiManager));

  myProject.registerService(PsiFileFactory.class, new PsiFileFactoryImpl(myPsiManager));
  myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager)));
  myProject.registerService(PsiDirectoryFactory.class, new PsiDirectoryFactoryImpl(myPsiManager));
  myProject.registerService(ProjectScopeBuilder.class, createProjectScopeBuilder());
  myProject.registerService(DumbService.class, new MockDumbService(myProject));
  myProject.registerService(CoreEncodingProjectManager.class, CoreEncodingProjectManager.class);
}
项目:intellij-ce-playground    文件:BasePsiNode.java   
public BasePsiNode(final T element) {
  super(element.getProject());
  if (element.isValid()) {
    myPsiElementPointer = SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(element);
  }
  else {
    myPsiElementPointer = null;
  }
}
项目:intellij-ce-playground    文件:InplaceVariableIntroducer.java   
public MyIntroduceLookupExpression(final String initialName,
                                   final LinkedHashSet<String> names,
                                   final PsiNamedElement elementToRename,
                                   final boolean shouldSelectAll,
                                   final String advertisementText) {
  super(initialName, names, elementToRename, elementToRename, shouldSelectAll, advertisementText);
  myPointer = SmartPointerManager.getInstance(elementToRename.getProject()).createSmartPsiElementPointer(elementToRename);
}
项目:intellij-ce-playground    文件:DocstringQuickFix.java   
public DocstringQuickFix(@Nullable PyNamedParameter missing, @Nullable  String unexpectedParamName) {
  if (missing != null) {
    myMissingParam = SmartPointerManager.getInstance(missing.getProject()).createSmartPsiElementPointer(missing);
  }
  else {
    myMissingParam = null;
  }
  myUnexpectedParamName = unexpectedParamName;
}
项目:intellij-ce-playground    文件:NavigationGutterIconBuilder.java   
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;
}
项目:intellij-ce-playground    文件:GrClassReferenceTypePointer.java   
public GrClassReferenceTypePointer(GrClassReferenceType type, Project project) {
  super(type);

  myProject = project;
  final GrReferenceElement reference = type.getReference();
  mySmartPsiElementPointer = SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(reference);
  myReferenceText = reference.getText();
}
项目:epigraph    文件:SchemaTypeParentsSearch.java   
public static Query<SchemaTypeDef> search(@NotNull final SearchParameters parameters) {
  final Project project = parameters.schemaTypeDef.getProject();
  return INSTANCE.createUniqueResultsQuery(parameters, ContainerUtil.canonicalStrategy(),
      schemaTypeDef ->
          schemaTypeDef == null ? null :
          ApplicationManager.getApplication().runReadAction(
          (Computable<SmartPsiElementPointer<SchemaTypeDef>>) () ->
              SmartPointerManager.getInstance(project).createSmartPsiElementPointer(schemaTypeDef)
      )
  );
}
项目:epigraph    文件:SchemaTypeInheritorsSearch.java   
public static Query<SchemaTypeDef> search(@NotNull final SearchParameters parameters) {
  return INSTANCE.createUniqueResultsQuery(parameters, ContainerUtil.canonicalStrategy(),
      schemaTypeDef -> ApplicationManager.getApplication().runReadAction(
          (Computable<SmartPsiElementPointer<SchemaTypeDef>>) () ->
              SmartPointerManager.getInstance(schemaTypeDef.getProject()).createSmartPsiElementPointer(schemaTypeDef)
      )
  );
}
项目:dbunit-extractor    文件:QueryToXMLConverter.java   
@Nullable
private SmartPsiElementPointer<SqlSelectStatement> getStatementPointer(final @NotNull Project project,
                                                                       final @NotNull PsiElement psiElement) {
    final SqlSelectStatement sqlSelectStatement =
            PsiTreeUtil.getParentOfType(psiElement.getContainingFile().findElementAt(psiElement.getTextOffset()),
                                        SqlSelectStatement.class);
    SmartPsiElementPointer<SqlSelectStatement> pointer = null;
    if (sqlSelectStatement != null) {
        pointer = SmartPointerManager.getInstance(project)
                                     .createSmartPsiElementPointer(sqlSelectStatement);
    }
    return pointer;
}
项目:tools-idea    文件:UsageInfoToUsageConverter.java   
@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);
          }
        });
}
项目:tools-idea    文件:UsageViewImpl.java   
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);
      }
    }
  }
}
项目:tools-idea    文件:PsiNamedElementUsageGroupBase.java   
public PsiNamedElementUsageGroupBase(@NotNull T element, Icon icon) {
  String myName = element.getName();
  if (myName == null) myName = "<anonymous>";
  this.myName = myName;
  myElementPointer = SmartPointerManager.getInstance(element.getProject()).createSmartPsiElementPointer(element);

  myIcon = icon;
}
项目:tools-idea    文件:ElementBase.java   
@Nullable
public PsiElement getElement() {
  if (myPointer.getProject().isDisposed()) return null;
  PsiElement element = myPointer.getElement();
  SmartPointerManager.getInstance(myPointer.getProject()).removePointer(myPointer);
  return element;
}
项目:tools-idea    文件:BasePsiNode.java   
public BasePsiNode(final T element) {
  super(element.getProject());
  if (element.isValid()) {
    myPsiElementPointer = SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(element);
  }
  else {
    myPsiElementPointer = null;
  }
}
项目:tools-idea    文件:InplaceVariableIntroducer.java   
public MyIntroduceLookupExpression(final String initialName,
                                   final LinkedHashSet<String> names,
                                   final PsiNamedElement elementToRename,
                                   final boolean shouldSelectAll,
                                   final String advertisementText) {
  super(initialName, names, elementToRename, elementToRename, shouldSelectAll, advertisementText);
  myPointer = SmartPointerManager.getInstance(elementToRename.getProject()).createSmartPsiElementPointer(elementToRename);
}
项目:tools-idea    文件:UsageHolder.java   
public UsageHolder(PsiElement element, UsageInfo[] usageInfos) {
  myElementPointer = SmartPointerManager.getInstance(element.getProject()).createSmartPsiElementPointer(element);

  ArrayList<SafeDeleteReferenceUsageInfo> elementUsages = new ArrayList<SafeDeleteReferenceUsageInfo>();
  for (UsageInfo usageInfo : usageInfos) {
    if (usageInfo instanceof SafeDeleteReferenceUsageInfo) {
      final SafeDeleteReferenceUsageInfo referenceUsageInfo = (SafeDeleteReferenceUsageInfo)usageInfo;
      if (referenceUsageInfo.getReferencedElement() == element) {
        elementUsages.add(referenceUsageInfo);
      }
    }
  }
  myUsages =
  elementUsages.toArray(new SafeDeleteReferenceUsageInfo[elementUsages.size()]);
}