當前位置: 首頁>>代碼示例>>Java>>正文


Java PsiElement類代碼示例

本文整理匯總了Java中com.intellij.psi.PsiElement的典型用法代碼示例。如果您正苦於以下問題:Java PsiElement類的具體用法?Java PsiElement怎麽用?Java PsiElement使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PsiElement類屬於com.intellij.psi包,在下文中一共展示了PsiElement類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: annotate

import com.intellij.psi.PsiElement; //導入依賴的package包/類
@Override
public void annotate( PsiElement element, AnnotationHolder holder )
{
  if( DumbService.getInstance( element.getProject() ).isDumb() )
  {
    // skip processing during index rebuild
    return;
  }

  PsiClass psiExtensionClass = findExtensionClass( element );

  if( psiExtensionClass != null )
  {
    // The enclosing class a @Extension class, verify usage of @This etc.

    verifyPackage( element, holder );
    verifyExtensionInterfaces( element, holder );
    verifyExtensionMethods( element, holder );
  }
  else
  {
    // The enclosing class is *not* an extension class; usage of @This or @Extension on methods are errors

    errrantThisOrExtension( element, holder );
  }
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:27,代碼來源:ExtensionClassAnnotator.java

示例2: addCompletions

import com.intellij.psi.PsiElement; //導入依賴的package包/類
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
    PsiElement caller = parameters.getPosition().getPrevSibling().getPrevSibling();
    String ns = TSUtil.getElementNamespace(caller);

    //All global functions
    Project project = parameters.getOriginalFile().getProject();
    Collection<TSFnDeclStmt> functions = TSUtil.getFunctionList(project);
    for (TSFnDeclStmt function : functions) {
        if (function.getFunctionType() == TSFunctionType.GLOBAL)
            continue;

        result.addElement(
                LookupElementBuilder.create(function.getFunctionName())
                        .withCaseSensitivity(false)
                        .withPresentableText(function.getNamespace() + "." + function.getFunctionName())
                        .withBoldness(ns != null && function.getNamespace().equalsIgnoreCase(ns))
                        .withTailText(function.getArgList())
                        .withInsertHandler(TSCaseCorrectingInsertHandler.INSTANCE)
        );
    }
}
 
開發者ID:CouleeApps,項目名稱:TS-IJ,代碼行數:23,代碼來源:TSMethodCallCompletionContributor.java

示例3: invokeAutoPopup

import com.intellij.psi.PsiElement; //導入依賴的package包/類
@Override
public boolean invokeAutoPopup(@NotNull PsiElement position, char typeChar) {
    MethodReference reference = PsiTreeUtil.getParentOfType(position, MethodReference.class);
    if (reference != null && ArrayUtil.contains(reference.getName(), ViewsUtil.renderMethods)) {
        if (typeChar == '\'' || typeChar == '"') {
            if (position instanceof LeafPsiElement && position.getText().equals("$view")) {
                return true;
            }
            if (position.getNextSibling() instanceof ParameterList) {
                return true;
            }
        }
    }

    return false;
}
 
開發者ID:nvlad,項目名稱:yii2support,代碼行數:17,代碼來源:CompletionContributor.java

示例4: findPropsNameListWithIdentityReference

import com.intellij.psi.PsiElement; //導入依賴的package包/類
@NotNull
private List<PropTypeBean>  findPropsNameListWithIdentityReference(String identity, PsiElement psiElement){
  return PsiTreeUtil.findChildrenOfType(psiElement, LeafPsiElement.class)
          .stream()
          .filter(o -> o.getText().equals(identity))
          .filter(o -> o.getElementType().toString().equals("JS:IDENTIFIER"))
          .filter(o -> {
            if(o.getParent() instanceof JSReferenceExpressionImpl){
              JSReferenceExpressionImpl parent = (JSReferenceExpressionImpl) o.getParent();
              if(parent.getTreeNext()!=null && parent.getTreeNext().getElementType().toString().equals("JS:DOT")
                      &&parent.getTreeNext().getTreeNext()!=null){
                return true;
              }
            }
            return  false;
          })
          .map(o -> ((JSReferenceExpressionImpl)o.getParent()).getTreeNext().getTreeNext().getText())
          .distinct()
          .map(o -> new PropTypeBean(o,"any", false))
          .collect(Collectors.toList());
}
 
開發者ID:dpzxsm,項目名稱:ReactPropTypes-Plugin,代碼行數:22,代碼來源:CommonAction.java

示例5: createFromTemplate

import com.intellij.psi.PsiElement; //導入依賴的package包/類
public static void createFromTemplate(@NotNull Project project,
                                      @NotNull PsiDirectory taskDirectory,
                                      @NotNull String name,
                                      @Nullable IdeView view,
                                      boolean open) {
  FileTemplate template = FileTemplateManager.getInstance(project).getInternalTemplate(name);
  if (template == null) {
    LOG.info("Template " + name + " wasn't found");
    return;
  }
  try {
    final PsiElement file = FileTemplateUtil.createFromTemplate(template, name, null, taskDirectory);
    if (view != null && open) {
      EditorHelper.openInEditor(file, false);
      view.selectElement(file);
    }
  }
  catch (Exception e) {
    LOG.error(e);
  }
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:22,代碼來源:StudyUtils.java

示例6: findJavaUsages

import com.intellij.psi.PsiElement; //導入依賴的package包/類
static Map<Pair<FeaturePath, PsiElement>, List<UsageInfo>> findJavaUsages( PsiElement element, List<PsiElement> javaElems )
{
  if( !(element instanceof PsiNamedElement) || javaElems.isEmpty() )
  {
    return Collections.emptyMap();
  }

  Map<Pair<FeaturePath, PsiElement>, List<UsageInfo>> allUsages = new HashMap<>();
  for( PsiElement javaElem : javaElems )
  {
    if( javaElem == null )
    {
      continue;
    }

    List<UsageInfo> usages = findUsages( javaElem, element );
    if( !usages.isEmpty() )
    {
      FeaturePath path = javaElem.getUserData( KEY_FEATURE_PATH );
      allUsages.put( new Pair<>( path, javaElem ), usages );
    }
  }

  return allUsages;
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:26,代碼來源:RenameResourceElementProcessor.java

示例7: analyzeFile

import com.intellij.psi.PsiElement; //導入依賴的package包/類
@NotNull
private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
    DotEnvPsiElementsVisitor visitor = new DotEnvPsiElementsVisitor();
    file.acceptChildren(visitor);

    ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);

    Map<String, PsiElement> existingKeys = new HashMap<>();
    Set<PsiElement> markedElements = new HashSet<>();
    for(KeyValuePsiElement keyValue : visitor.getCollectedItems()) {
        if(existingKeys.containsKey(keyValue.getKey())) {
            problemsHolder.registerProblem(keyValue.getElement(), "Duplicate key");

            PsiElement markedElement = existingKeys.get(keyValue.getKey());
            if(!markedElements.contains(markedElement)) {
                problemsHolder.registerProblem(markedElement, "Duplicate key");
                markedElements.add(markedElement);
            }
        } else {
            existingKeys.put(keyValue.getKey(), keyValue.getElement());
        }
    }

    return problemsHolder;
}
 
開發者ID:adelf,項目名稱:idea-php-dotenv-plugin,代碼行數:26,代碼來源:DuplicateKeyInspection.java

示例8: errrantThisOrExtension

import com.intellij.psi.PsiElement; //導入依賴的package包/類
private void errrantThisOrExtension( PsiElement element, AnnotationHolder holder )
{
  if( element instanceof PsiModifierList )
  {
    PsiModifierList mods = (PsiModifierList)element;
    PsiAnnotation annotation;
    if( (annotation = mods.findAnnotation( Extension.class.getName() )) != null ||
        (annotation = mods.findAnnotation( This.class.getName() )) != null)
    {
      TextRange range = new TextRange( annotation.getTextRange().getStartOffset(),
                                       annotation.getTextRange().getEndOffset() );
      //noinspection ConstantConditions
      holder.createErrorAnnotation( range, ExtIssueMsg.MSG_NOT_IN_EXTENSION_CLASS.get( ClassUtil.extractClassName( annotation.getQualifiedName() ) ) );
    }
  }
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:17,代碼來源:ExtensionClassAnnotator.java

示例9: getElementDescription

import com.intellij.psi.PsiElement; //導入依賴的package包/類
@Override
public String getElementDescription(@NotNull PsiElement element, @NotNull ElementDescriptionLocation location) {
    if (location == UsageViewNodeTextLocation.INSTANCE && element instanceof PsiNamedElement) {
        return getElementDescription(element, UsageViewShortNameLocation.INSTANCE);
    }

    if (location == UsageViewShortNameLocation.INSTANCE || location == UsageViewLongNameLocation.INSTANCE) {
        if (element instanceof PsiNamedElement) {
            return ((PsiNamedElement) element).getName();
        }
    }

    if (location == UsageViewTypeLocation.INSTANCE) {
        if (element instanceof PsiModuleName) {
            return "module";
        } else if (element instanceof PsiTypeName) {
            return "type";
        } else if (element instanceof PsiVarName) {
            return "let";
        }
    }

    return element.toString();
}
 
開發者ID:reasonml-editor,項目名稱:reasonml-idea-plugin,代碼行數:25,代碼來源:DescriptionProvider.java

示例10: EmojiResourceCompletionContributor

import com.intellij.psi.PsiElement; //導入依賴的package包/類
public EmojiResourceCompletionContributor() {
	extend(CompletionType.BASIC, PlatformPatterns.psiElement(PsiElement.class), new CompletionProvider<CompletionParameters>() {
		@Override
		protected void addCompletions(@NotNull CompletionParameters completionParameters,
									  ProcessingContext processingContext,
									  @NotNull CompletionResultSet completionResultSet) {
			Document document = completionParameters.getEditor().getDocument();
			int lineStart = document.getLineStartOffset(document.getLineNumber(completionParameters.getOffset()));
			String lineText = document.getText(new TextRange(lineStart, completionParameters.getOffset()));
			if (includeCount(lineText) == 1) {
				for (Map.Entry<String, Icon> iconEntry : EmojiUtil.getEmojiMap().entrySet()) {
					completionResultSet.addElement(LookupElementBuilder.create(iconEntry.getKey(), ":" + iconEntry.getKey() + ":")
							.withIcon(iconEntry.getValue())
							.withInsertHandler((insertionContext, lookupElement) -> {
								int startOffset = insertionContext.getStartOffset();
								Document insertDocument = insertionContext.getDocument();
								if (startOffset > 0 && insertDocument.getCharsSequence().charAt(startOffset - 1) == ':') {
									insertDocument.deleteString(startOffset - 1, startOffset);
								}
							}));
				}
			}
		}
	});
}
 
開發者ID:syuchan1005,項目名稱:EmojiPrefix,代碼行數:26,代碼來源:EmojiResourceCompletionContributor.java

示例11: deleteFunctionParam

import com.intellij.psi.PsiElement; //導入依賴的package包/類
public static void deleteFunctionParam(PsiElement element) {
    PsiElement next = element.getNextSibling();
    if (next != null && next.getText().equals(",")) {
        next.delete();
    } else {
        PsiElement prev = element.getPrevSibling();
        if (prev != null && prev instanceof PsiWhiteSpace) {
            prev.delete();
            prev = element.getPrevSibling();
        }
        if (prev != null && prev.getText().equals(",")) {
            prev.delete();
        }
    }
    element.delete();
}
 
開發者ID:nvlad,項目名稱:yii2support,代碼行數:17,代碼來源:PsiUtil.java

示例12: addCompletions

import com.intellij.psi.PsiElement; //導入依賴的package包/類
@Override
public void addCompletions(
    @NotNull final CompletionParameters parameters,
    final ProcessingContext context,
    @NotNull final CompletionResultSet result
) {
    Validate.notNull(parameters);
    Validate.notNull(result);

    final Project project = this.getProject(parameters);
    if (null == project) {
        return;
    }

    final PsiElement psiElementUnderCaret = parameters.getPosition();
    final ImpexHeaderTypeName headerTypeName = this.getHeaderTypeNamePsiElementOfAttribute(psiElementUnderCaret);

    if (headerTypeName != null) {
        fillDomAttributesCompletions(project, headerTypeName, result);
    }
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:22,代碼來源:ImpexHeaderItemTypeAttributeNameCompletionProvider.java

示例13: generateDoc

import com.intellij.psi.PsiElement; //導入依賴的package包/類
@Override
public String generateDoc(PsiElement element, @Nullable PsiElement originalElement) {
  if (element instanceof DocumentationProxyElement) {
    DocumentationProxyElement proxyElement = DocumentationProxyElement.class.cast(element);
    MetadataNode target = proxyElement.target;
    boolean requestedForTargetValue = proxyElement.requestedForTargetValue;
    String value = proxyElement.value;

    // Only group & leaf are expected to have documentation
    if (target != null && (target.isGroup() || target.isLeaf())) {
      if (requestedForTargetValue) {
        assert target.getProperty() != null;
        return target.getProperty().getDocumentationForValue(target, value);
      } else if (target.isGroup()) {
        assert target.getGroup() != null;
        return target.getGroup().getDocumentation(target);
      } else {
        assert target.getProperty() != null;
        return target.getProperty().getDocumentationForKey(target);
      }
    }
  }
  return super.generateDoc(element, originalElement);
}
 
開發者ID:1tontech,項目名稱:intellij-spring-assistant,代碼行數:25,代碼來源:PropertiesDocumentationProvider.java

示例14: assertLineMarker

import com.intellij.psi.PsiElement; //導入依賴的package包/類
public void assertLineMarker(@NotNull PsiElement psiElement, @NotNull LineMarker.Assert assertMatch) {

        final List<PsiElement> elements = collectPsiElementsRecursive(psiElement);

        for (LineMarkerProvider lineMarkerProvider : LineMarkerProviders.INSTANCE.allForLanguage(psiElement.getLanguage())) {
            Collection<LineMarkerInfo> lineMarkerInfos = new ArrayList<LineMarkerInfo>();
            lineMarkerProvider.collectSlowLineMarkers(elements, lineMarkerInfos);

            if(lineMarkerInfos.size() == 0) {
                continue;
            }

            for (LineMarkerInfo lineMarkerInfo : lineMarkerInfos) {
                if(assertMatch.match(lineMarkerInfo)) {
                    return;
                }
            }
        }

        fail(String.format("Fail that '%s' matches on of '%s' PsiElements", assertMatch.getClass(), elements.size()));
    }
 
開發者ID:Haehnchen,項目名稱:idea-php-behat-plugin,代碼行數:22,代碼來源:BehatLightCodeInsightFixtureTestCase.java

示例15: doTest

import com.intellij.psi.PsiElement; //導入依賴的package包/類
private void doTest(String expectedQuickNavigateInfo) {
  String filename = getTestName(false) + ".soy";
  myFixture.configureByFile(filename);
  PsiElement element = myFixture.getElementAtCaret();
  String info = (new SoyDocumentationProvider()).getQuickNavigateInfo(element, null);
  assertEquals(expectedQuickNavigateInfo, info);
}
 
開發者ID:google,項目名稱:bamboo-soy,代碼行數:8,代碼來源:SoyDocumentationProviderTest.java


注:本文中的com.intellij.psi.PsiElement類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。