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


Java SmartPointerManager类代码示例

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


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

示例1: LocalQuickFixOnPsiElement

import com.intellij.psi.SmartPointerManager; //导入依赖的package包/类
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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:LocalQuickFixOnPsiElement.java

示例2: setData

import com.intellij.psi.SmartPointerManager; //导入依赖的package包/类
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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:DocumentationComponent.java

示例3: createAnchor

import com.intellij.psi.SmartPointerManager; //导入依赖的package包/类
@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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:PsiTreeAnchorizer.java

示例4: UsageHolder

import com.intellij.psi.SmartPointerManager; //导入依赖的package包/类
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++;
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:UsageHolder.java

示例5: 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);
    }
  }));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:GroovyResolveSnapshot.java

示例6: setData

import com.intellij.psi.SmartPointerManager; //导入依赖的package包/类
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();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:DocumentationComponent.java

示例7: LineMarkerInfo

import com.intellij.psi.SmartPointerManager; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:LineMarkerInfo.java

示例8: tryCreate

import com.intellij.psi.SmartPointerManager; //导入依赖的package包/类
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);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:ElementCreator.java

示例9: setData

import com.intellij.psi.SmartPointerManager; //导入依赖的package包/类
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();
}
 
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:DocumentationComponent.java

示例10: cacheParticularEntity

import com.intellij.psi.SmartPointerManager; //导入依赖的package包/类
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));
	}
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:25,代码来源:XmlEntityCache.java

示例11: doFix

import com.intellij.psi.SmartPointerManager; //导入依赖的package包/类
@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;
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:24,代码来源:XmlUnusedNamespaceInspection.java

示例12: tryToInit

import com.intellij.psi.SmartPointerManager; //导入依赖的package包/类
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);
		}
	});
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:22,代码来源:DescriptionByAnotherPsiElementService.java

示例13: search

import com.intellij.psi.SmartPointerManager; //导入依赖的package包/类
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);
				}
			});
		}
	});
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:ClassInheritorsSearch.java

示例14: compareTo

import com.intellij.psi.SmartPointerManager; //导入依赖的package包/类
@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);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:20,代码来源:MethodGroupingRule.java

示例15: 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());
}
 
开发者ID:rentalhost,项目名称:laravel-insight,代码行数:13,代码来源:PropertyQuickFix.java


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