本文整理匯總了Java中com.intellij.psi.PsiNameIdentifierOwner類的典型用法代碼示例。如果您正苦於以下問題:Java PsiNameIdentifierOwner類的具體用法?Java PsiNameIdentifierOwner怎麽用?Java PsiNameIdentifierOwner使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PsiNameIdentifierOwner類屬於com.intellij.psi包,在下文中一共展示了PsiNameIdentifierOwner類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: tokenize
import com.intellij.psi.PsiNameIdentifierOwner; //導入依賴的package包/類
@Override
public void tokenize(@NotNull PsiNameIdentifierOwner element, TokenConsumer consumer) {
PsiElement identifier = element.getNameIdentifier();
if (identifier == null) {
return;
}
PsiElement parent = element;
final TextRange range = identifier.getTextRange();
if (range.isEmpty()) return;
int offset = range.getStartOffset() - parent.getTextRange().getStartOffset();
if(offset < 0 ) {
parent = PsiTreeUtil.findCommonParent(identifier, element);
offset = range.getStartOffset() - parent.getTextRange().getStartOffset();
}
String text = identifier.getText();
consumer.consumeToken(parent, text, true, offset, TextRange.allOf(text), IdentifierSplitter.getInstance());
}
示例2: getNameIdentifier
import com.intellij.psi.PsiNameIdentifierOwner; //導入依賴的package包/類
@Nullable
public static PsiElement getNameIdentifier(@NotNull PsiElement element) {
if (element instanceof PsiNameIdentifierOwner) {
return ((PsiNameIdentifierOwner)element).getNameIdentifier();
}
if (element.isPhysical() &&
element instanceof PsiNamedElement &&
element.getContainingFile() != null &&
element.getTextRange() != null) {
// Quite hacky way to get name identifier. Depends on getTextOffset overriden properly.
final PsiElement potentialIdentifier = element.findElementAt(element.getTextOffset() - element.getTextRange().getStartOffset());
if (potentialIdentifier != null && Comparing.equal(potentialIdentifier.getText(), ((PsiNamedElement)element).getName(), false)) {
return potentialIdentifier;
}
}
return null;
}
示例3: shouldFocusLookup
import com.intellij.psi.PsiNameIdentifierOwner; //導入依賴的package包/類
@NotNull
@Override
public ThreeState shouldFocusLookup(@NotNull CompletionParameters parameters) {
final PsiElement position = parameters.getPosition();
final PsiElement parent = position.getParent();
if (parent instanceof PsiNameIdentifierOwner) {
final PsiElement nameIdentifier = ((PsiNameIdentifierOwner)parent).getNameIdentifier();
if (nameIdentifier == position) {
return ThreeState.NO;
}
if (nameIdentifier != null && position.getTextRange().equals(nameIdentifier.getTextRange())) {
//sometimes name identifiers are non-physical (e.g. Groovy)
return ThreeState.NO;
}
}
return ThreeState.UNSURE;
}
示例4: findNameIdentifier
import com.intellij.psi.PsiNameIdentifierOwner; //導入依賴的package包/類
@Nullable
private static PsiElement findNameIdentifier(Editor editor, PsiFile file, TextRange toDuplicate) {
int nonWs = CharArrayUtil.shiftForward(editor.getDocument().getCharsSequence(), toDuplicate.getStartOffset(), "\n\t ");
PsiElement psi = file.findElementAt(nonWs);
PsiElement named = null;
while (psi != null) {
TextRange range = psi.getTextRange();
if (range == null || psi instanceof PsiFile || !toDuplicate.contains(psi.getTextRange())) {
break;
}
if (psi instanceof PsiNameIdentifierOwner) {
named = ((PsiNameIdentifierOwner)psi).getNameIdentifier();
}
psi = psi.getParent();
}
return named;
}
示例5: findTargetMember
import com.intellij.psi.PsiNameIdentifierOwner; //導入依賴的package包/類
@Nullable
private static PsiElement findTargetMember(@Nullable PsiElement element) {
if (element == null) return null;
final ChangeSignatureHandler fileHandler = getChangeSignatureHandler(element.getLanguage());
if (fileHandler != null) {
final PsiElement targetMember = fileHandler.findTargetMember(element);
if (targetMember != null) return targetMember;
}
PsiReference reference = element.getReference();
if (reference == null && element instanceof PsiNameIdentifierOwner) {
return element;
}
if (reference != null) {
return reference.resolve();
}
return null;
}
示例6: processElement
import com.intellij.psi.PsiNameIdentifierOwner; //導入依賴的package包/類
private void processElement(@NotNull PsiNameIdentifierOwner element) {
final ScopeOwner owner = ScopeUtil.getScopeOwner(element);
if (owner instanceof PyClass) {
return;
}
final String name = element.getName();
if (name != null && !myIgnoredNames.contains(name)) {
final PyBuiltinCache builtinCache = PyBuiltinCache.getInstance(element);
final PsiElement builtin = builtinCache.getByName(name);
if (builtin != null && !PyUtil.inSameFile(builtin, element)) {
final PsiElement identifier = element.getNameIdentifier();
final PsiElement problemElement = identifier != null ? identifier : element;
registerProblem(problemElement, String.format("Shadows built-in name '%s'", name),
ProblemHighlightType.WEAK_WARNING, null, new PyRenameElementQuickFix(), new PyIgnoreBuiltinQuickFix(name));
}
}
}
示例7: doFix
import com.intellij.psi.PsiNameIdentifierOwner; //導入依賴的package包/類
@Override
protected void doFix(final Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
final PsiNameIdentifierOwner owner = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), PsiVariable.class, PsiMethod.class);
if (owner == null) {
return;
}
final RefactoringActionHandler handler = JavaRefactoringActionHandlerFactory.getInstance().createInvertBooleanHandler();
final Runnable runnable = new Runnable() {
@Override
public void run() {
handler.invoke(project, new PsiElement[]{owner}, null);
}
};
if (ApplicationManager.getApplication().isUnitTestMode()) {
runnable.run();
}
else {
ApplicationManager.getApplication().invokeLater(runnable, project.getDisposed());
}
}
示例8: getElementDescription
import com.intellij.psi.PsiNameIdentifierOwner; //導入依賴的package包/類
@Nullable
@Override
public String getElementDescription(PsiElement element, ElementDescriptionLocation location) {
if (!(element instanceof BuildElement)) {
return null;
}
if (location instanceof UsageViewLongNameLocation) {
return ((BuildElement) element).getPresentableText();
}
if (location instanceof UsageViewShortNameLocation) {
if (element instanceof PsiNameIdentifierOwner) {
// this is used by rename operations, so needs to be accurate
return ((PsiNameIdentifierOwner) element).getName();
}
if (element instanceof PsiFile) {
return ((PsiFile) element).getName();
}
return ((BuildElement) element).getPresentableText();
}
return null;
}
示例9: getTokenizer
import com.intellij.psi.PsiNameIdentifierOwner; //導入依賴的package包/類
@NotNull
@Override
public Tokenizer getTokenizer(PsiElement element) {
if (element instanceof PsiWhiteSpace) {
return EMPTY_TOKENIZER;
}
if (element instanceof PsiNameIdentifierOwner) {
return new PsiIdentifierOwnerTokenizer();
}
if (element.getParent() instanceof PsiNameIdentifierOwner) {
return EMPTY_TOKENIZER;
}
if (element.getNode().getElementType() == JSGraphQLEndpointTokenTypes.IDENTIFIER) {
return IDENTIFIER_TOKENIZER;
}
if (element instanceof PsiComment) {
if (SuppressionUtil.isSuppressionComment(element)) {
return EMPTY_TOKENIZER;
}
return myCommentTokenizer;
}
return EMPTY_TOKENIZER;
}
開發者ID:jimkyndemeyer,項目名稱:js-graphql-intellij-plugin,代碼行數:24,代碼來源:JSGraphQLEndpointSpellcheckingStrategy.java
示例10: getPresentableText
import com.intellij.psi.PsiNameIdentifierOwner; //導入依賴的package包/類
@Nullable
@Override
public String getPresentableText() {
if(element instanceof JSGraphQLEndpointImportDeclaration) {
return element.getText();
}
final PsiNameIdentifierOwner identifier = PsiTreeUtil.getChildOfType(element, PsiNameIdentifierOwner.class);
if (identifier != null) {
return identifier.getText();
}
final ASTNode astIdentifier = element.getNode().getFirstChildNode();
if (astIdentifier != null && astIdentifier.getElementType() == JSGraphQLEndpointTokenTypes.IDENTIFIER) {
return astIdentifier.getText();
}
if (element instanceof PsiFile) {
return null;
}
return element.getText();
}
開發者ID:jimkyndemeyer,項目名稱:js-graphql-intellij-plugin,代碼行數:20,代碼來源:JSGraphQLEndpointStructureViewTreeElement.java
示例11: getNameWithAt
import com.intellij.psi.PsiNameIdentifierOwner; //導入依賴的package包/類
@Nullable
@RequiredReadAction
public static String getNameWithAt(@NotNull PsiNameIdentifierOwner element)
{
PsiElement nameIdentifier = element.getNameIdentifier();
if(nameIdentifier == null)
{
return null;
}
if(!(nameIdentifier instanceof CSharpIdentifier))
{
LOGGER.error("NameIdentifier is not 'CSharpIdentifier' element. Owner: " + element.getClass().getName());
return nameIdentifier.getText();
}
String value = ((CSharpIdentifier) nameIdentifier).getValue();
if(value == null)
{
return null;
}
return value;
}
示例12: getAnchor
import com.intellij.psi.PsiNameIdentifierOwner; //導入依賴的package包/類
@Nullable
@Override
@RequiredReadAction
public PsiElement getAnchor(@NotNull PsiElement element)
{
if(element instanceof MsilElementWrapper || !element.isPhysical())
{
return null;
}
if(element instanceof CSharpTypeDeclaration ||
element instanceof CSharpFieldDeclaration ||
element instanceof CSharpMethodDeclaration ||
element instanceof CSharpConstructorDeclaration ||
element instanceof CSharpIndexMethodDeclaration ||
//element instanceof CSharpConversionMethodDeclaration ||
element instanceof CSharpPropertyDeclaration ||
element instanceof CSharpEventDeclaration)
{
return ((PsiNameIdentifierOwner) element).getNameIdentifier();
}
return null;
}
示例13: checkImpl
import com.intellij.psi.PsiNameIdentifierOwner; //導入依賴的package包/類
@RequiredReadAction
@Nullable
@Override
public CompilerCheckBuilder checkImpl(@NotNull CSharpLanguageVersion languageVersion, @NotNull CSharpHighlightContext highlightContext, @NotNull DotNetVirtualImplementOwner element)
{
PsiElement nameIdentifier = ((PsiNameIdentifierOwner) element).getNameIdentifier();
if(nameIdentifier == null)
{
return null;
}
final Pair<CSharpLikeMethodDeclarationImplUtil.ResolveVirtualImplementResult, PsiElement> resultPair = CSharpLikeMethodDeclarationImplUtil.resolveVirtualImplementation(element, element);
switch(resultPair.getFirst())
{
case CANT_HAVE:
case FOUND:
default:
return null;
case NOT_FOUND:
return newBuilder(nameIdentifier, formatElement(element));
}
}
示例14: checkImpl
import com.intellij.psi.PsiNameIdentifierOwner; //導入依賴的package包/類
@RequiredReadAction
@Nullable
@Override
public HighlightInfoFactory checkImpl(@NotNull CSharpLanguageVersion languageVersion, @NotNull CSharpHighlightContext highlightContext, @NotNull DotNetQualifiedElement element)
{
PsiElement parent = element.getParent();
if(!(parent instanceof CSharpTypeDeclaration) | !(element instanceof PsiNameIdentifierOwner) || element instanceof CSharpConstructorDeclaration || element instanceof
CSharpConversionMethodDeclaration || element instanceof CSharpEnumConstantDeclaration)
{
return null;
}
if(Comparing.equal(element.getName(), ((CSharpTypeDeclaration) parent).getName()))
{
PsiElement nameIdentifier = ((PsiNameIdentifierOwner) element).getNameIdentifier();
if(nameIdentifier == null)
{
return null;
}
return newBuilder(nameIdentifier, element.getName());
}
return null;
}
示例15: checkImpl
import com.intellij.psi.PsiNameIdentifierOwner; //導入依賴的package包/類
@RequiredReadAction
@Nullable
@Override
public HighlightInfoFactory checkImpl(@NotNull CSharpLanguageVersion languageVersion, @NotNull CSharpHighlightContext highlightContext, @NotNull DotNetModifierListOwner element)
{
PsiElement parent = element.getParent();
if(parent instanceof DotNetTypeDeclaration && ((DotNetTypeDeclaration) parent).hasModifier(DotNetModifier.STATIC))
{
if(CSharpPsiUtilImpl.isTypeLikeElement(element))
{
return null;
}
if(!element.hasModifier(DotNetModifier.STATIC))
{
PsiElement nameIdentifier = ((PsiNameIdentifierOwner) element).getNameIdentifier();
return newBuilder(ObjectUtil.notNull(nameIdentifier, element), formatElement(element)).addQuickFix(new AddModifierFix
(DotNetModifier.STATIC, element));
}
}
return null;
}