本文整理汇总了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 );
}
}
示例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)
);
}
}
示例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;
}
示例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());
}
示例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);
}
}
示例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;
}
示例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;
}
示例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() ) ) );
}
}
}
示例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();
}
示例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);
}
}));
}
}
}
});
}
示例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();
}
示例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);
}
示例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()));
}
示例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);
}