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


Java SmartPsiElementPointer类代码示例

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


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

示例1: getPsiElement

import com.intellij.psi.SmartPsiElementPointer; //导入依赖的package包/类
@Nullable
public PsiElement getPsiElement() {
  Object o = getObject();
  if (o instanceof PsiElement) {
    return (PsiElement)o;
  }
  if (o instanceof ResolveResult) {
    return ((ResolveResult)o).getElement();
  }
  if (o instanceof PsiElementNavigationItem) {
    return ((PsiElementNavigationItem)o).getTargetElement();
  }
  if (o instanceof SmartPsiElementPointer) {
    return ((SmartPsiElementPointer)o).getElement();
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:LookupElement.java

示例2: setData

import com.intellij.psi.SmartPsiElementPointer; //导入依赖的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: setDataInternal

import com.intellij.psi.SmartPsiElementPointer; //导入依赖的package包/类
private void setDataInternal(SmartPsiElementPointer element, String text, final Rectangle viewRect, final String ref) {
  setElement(element);
  
  highlightLink(-1);

  myEditorPane.setText(text);
  applyFontSize();
  
  if (!myIsShown && myHint != null && !ApplicationManager.getApplication().isUnitTestMode()) {
    myManager.showHint(myHint);
    myIsShown = true;
  }

  myText = text;

  //noinspection SSBasedInspection
  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
      myEditorPane.scrollRectToVisible(viewRect); // if ref is defined but is not found in document, this provides a default location
      if (ref != null) {
        myEditorPane.scrollToReference(ref);
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:DocumentationComponent.java

示例4: findSmartFirstLevelNodeByElement

import com.intellij.psi.SmartPsiElementPointer; //导入依赖的package包/类
@Nullable
DefaultMutableTreeNode findSmartFirstLevelNodeByElement(final Object element) {
  for (Object child : getRoot().getChildren()) {
    AbstractTreeNode favorite = (AbstractTreeNode)child;
    Object currentValue = favorite.getValue();
    if (currentValue instanceof SmartPsiElementPointer) {
      currentValue = ((SmartPsiElementPointer)favorite.getValue()).getElement();
    }
     /*else if (currentValue instanceof PsiJavaFile) {
      final PsiClass[] classes = ((PsiJavaFile)currentValue).getClasses();
      if (classes.length > 0) {
        currentValue = classes[0];
      }
    }*/
    if (Comparing.equal(element, currentValue)) {
      final DefaultMutableTreeNode nodeWithObject =
        findFirstLevelNodeWithObject((DefaultMutableTreeNode)getTree().getModel().getRoot(), favorite);
      if (nodeWithObject != null) {
        return nodeWithObject;
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:FavoritesViewTreeBuilder.java

示例5: createAnchor

import com.intellij.psi.SmartPsiElementPointer; //导入依赖的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

示例6: createPointersThunk

import com.intellij.psi.SmartPsiElementPointer; //导入依赖的package包/类
private static <T> NotNullLazyValue<List<SmartPsiElementPointer>> createPointersThunk(boolean lazy,
                                                                                      final Project project,
                                                                                      final Factory<Collection<T>> targets,
                                                                                      final NotNullFunction<T, Collection<? extends PsiElement>> converter) {
  if (!lazy) {
    return NotNullLazyValue.createConstantValue(calcPsiTargets(project, targets.create(), converter));
  }

  return new NotNullLazyValue<List<SmartPsiElementPointer>>() {
    @Override
    @NotNull
    public List<SmartPsiElementPointer> compute() {
      return calcPsiTargets(project, targets.create(), converter);
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:NavigationGutterIconBuilder.java

示例7: getDeclaration

import com.intellij.psi.SmartPsiElementPointer; //导入依赖的package包/类
@Override
@Nullable
public PsiElement getDeclaration(final Project project) {
  DomElement domDeclaration = getDomDeclaration();
  if (domDeclaration != null) {
    final DomTarget target = DomTarget.getTarget(domDeclaration);
    if (target != null) {
      return PomService.convertToPsi(target);
    }
    return domDeclaration.getXmlElement();
  }
  final DomAnchor anchor = getUserData(DomExtensionImpl.KEY_DOM_DECLARATION);
  if (anchor != null) {
    return anchor.getContainingFile();
  }
  final SmartPsiElementPointer<?> pointer = getUserData(DomExtensionImpl.DECLARING_ELEMENT_KEY);
  if (pointer != null) {
    final PsiElement element = pointer.getElement();
    if (element != null) {
      return element;
    }
  }

  return PomService.convertToPsi(project, this);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:AbstractDomChildDescriptionImpl.java

示例8: GroovyResolveSnapshot

import com.intellij.psi.SmartPsiElementPointer; //导入依赖的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

示例9: isAvailable

import com.intellij.psi.SmartPsiElementPointer; //导入依赖的package包/类
@Override
public boolean isAvailable(@NotNull final Project project,
                           final Editor editor,
                           @NotNull final PsiElement psiElement) {
    final boolean isDataSetFile;
    if (editor instanceof EditorWindowImpl) {
        isDataSetFile = ((EditorWindowImpl) editor).getDelegate()
                                                   .getDocument()
                                                   .getText()
                                                   .startsWith("<dataset>");
    } else {
        isDataSetFile = editor.getDocument().getText().startsWith("<dataset>");
    }
    SmartPsiElementPointer<SqlSelectStatement> pointer = getNearestPointer(project, psiElement);
    final String selectedText = editor.getSelectionModel().getSelectedText();
    final boolean hasSelectedQuery = editor.getSelectionModel().hasSelection() && selectedText.trim().toUpperCase().startsWith("SELECT");
    return isDataSetFile && (hasSelectedQuery || pointer != null);
}
 
开发者ID:kTT,项目名称:dbunit-extractor,代码行数:19,代码来源:QueryToXMLConverter.java

示例10: setData

import com.intellij.psi.SmartPsiElementPointer; //导入依赖的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

示例11: getDeclaration

import com.intellij.psi.SmartPsiElementPointer; //导入依赖的package包/类
@Nullable
public PsiElement getDeclaration(final Project project) {
  DomElement domDeclaration = getDomDeclaration();
  if (domDeclaration != null) {
    final DomTarget target = DomTarget.getTarget(domDeclaration);
    if (target != null) {
      return PomService.convertToPsi(target);
    }
    return domDeclaration.getXmlElement();
  }
  final DomAnchor anchor = getUserData(DomExtensionImpl.KEY_DOM_DECLARATION);
  if (anchor != null) {
    return anchor.getContainingFile();
  }
  final SmartPsiElementPointer<?> pointer = getUserData(DomExtensionImpl.DECLARING_ELEMENT_KEY);
  if (pointer != null) {
    final PsiElement element = pointer.getElement();
    if (element != null) {
      return element;
    }
  }

  return PomService.convertToPsi(project, this);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:AbstractDomChildDescriptionImpl.java

示例12: tryCreate

import com.intellij.psi.SmartPsiElementPointer; //导入依赖的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

示例13: setData

import com.intellij.psi.SmartPsiElementPointer; //导入依赖的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

示例14: setDataInternal

import com.intellij.psi.SmartPsiElementPointer; //导入依赖的package包/类
private void setDataInternal(SmartPsiElementPointer element, String text, final Rectangle viewRect, final String ref) {
  setElement(element);

  highlightLink(-1);

  myEditorPane.setText(text);
  applyFontProps();

  if (!myIsShown && myHint != null && !ApplicationManager.getApplication().isUnitTestMode()) {
    myManager.showHint(myHint);
    myIsShown = true;
  }

  myText = text;

  //noinspection SSBasedInspection
  SwingUtilities.invokeLater(() -> {
    myEditorPane.scrollRectToVisible(viewRect); // if ref is defined but is not found in document, this provides a default location
    if (ref != null) {
      myEditorPane.scrollToReference(ref);
    }
    else if (ScreenReader.isActive()) {
      myEditorPane.setCaretPosition(0);
    }
  });
}
 
开发者ID:consulo,项目名称:consulo,代码行数:27,代码来源:DocumentationComponent.java

示例15: ShredImpl

import com.intellij.psi.SmartPsiElementPointer; //导入依赖的package包/类
ShredImpl(@Nonnull SmartPsiFileRange relevantRangeInHost,
          @Nonnull SmartPsiElementPointer<PsiLanguageInjectionHost> hostElementPointer,
          @Nonnull String prefix,
          @Nonnull String suffix,
          @Nonnull TextRange rangeInDecodedPSI,
          boolean usePsiRange,
          boolean isOneLine) {
  this.hostElementPointer = hostElementPointer;
  this.relevantRangeInHost = relevantRangeInHost;
  this.prefix = prefix;
  this.suffix = suffix;
  this.rangeInDecodedPSI = rangeInDecodedPSI;
  this.usePsiRange = usePsiRange;
  this.isOneLine = isOneLine;

  assertValid();
}
 
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:ShredImpl.java


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