com.intellij.psi.PsiTypeElement Java Examples
The following examples show how to use
com.intellij.psi.PsiTypeElement.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConstructorInjectToProvidesHandler.java From dagger-intellij-plugin with Apache License 2.0 | 6 votes |
private boolean navigateToConstructorIfProvider(PsiParameter psiParameter) { PsiTypeElement declaringTypeElement = psiParameter.getTypeElement(); PsiClass classElement = JavaPsiFacade.getInstance(psiParameter.getProject()).findClass( declaringTypeElement.getType().getCanonicalText(), declaringTypeElement.getResolveScope()); if (classElement == null) { return false; } for (PsiMethod method : classElement.getConstructors()) { if (PsiConsultantImpl.hasAnnotation(method, CLASS_INJECT) && navigateToElement(method)) { return true; } } return false; }
Example #2
Source File: ProvidesLineMarkerProvider.java From dagger-intellij-plugin with Apache License 2.0 | 6 votes |
/** * @return a {@link com.intellij.codeInsight.daemon.GutterIconNavigationHandler} if the element * is a PsiMethod annotated with @Provides. */ @Nullable @Override public LineMarkerInfo getLineMarkerInfo(@NotNull final PsiElement element) { // Check methods first (includes constructors). if (element instanceof PsiMethod) { PsiMethod methodElement = (PsiMethod) element; // Does it have an @Provides? if (hasAnnotation(element, CLASS_PROVIDES)) { PsiTypeElement returnTypeElement = methodElement.getReturnTypeElement(); if (returnTypeElement != null) { return new LineMarkerInfo<PsiElement>(element, returnTypeElement.getTextRange(), ICON, UPDATE_ALL, null, new ProvidesToInjectHandler(), LEFT); } } // Is it an @Inject-able constructor? if (methodElement.isConstructor() && hasAnnotation(element, CLASS_INJECT)) { return new LineMarkerInfo<PsiElement>(element, element.getTextRange(), ICON, UPDATE_ALL, null, new ConstructorInjectToInjectionPlaceHandler(), LEFT); } } return null; }
Example #3
Source File: OttoProjectHandler.java From otto-intellij-plugin with Apache License 2.0 | 6 votes |
private void maybeAddSubscriberMethod(PsiMethod element) { PsiTypeElement methodParameter = OttoLineMarkerProvider.getMethodParameter(element); if (methodParameter != null) { String canonicalText = methodParameter.getType().getCanonicalText(); PsiFile containingFile = methodParameter.getContainingFile(); if (containingFile != null) { VirtualFile virtualFile = containingFile.getVirtualFile(); if (virtualFile != null) { synchronized (fileToEventClasses) { Set<String> eventClasses = getEventClasses(virtualFile); eventClasses.add(canonicalText); } } } } }
Example #4
Source File: OttoLineMarkerProvider.java From otto-intellij-plugin with Apache License 2.0 | 6 votes |
@Override public void navigate(final MouseEvent mouseEvent, final PsiElement psiElement) { PsiMethod subscribeMethod = (PsiMethod) psiElement; final PsiTypeElement parameterTypeElement = getMethodParameter(subscribeMethod); final SubscriberMetadata subscriberMetadata = SubscriberMetadata.getSubscriberMetadata(subscribeMethod); if ((parameterTypeElement.getType() instanceof PsiClassType) && (subscriberMetadata != null)) { final PsiClass eventClass = ((PsiClassType) parameterTypeElement.getType()).resolve(); PickAction.startPicker(subscriberMetadata.displayedTypesOnSubscriberMethods(), new RelativePoint(mouseEvent), new PickAction.Callback() { @Override public void onTypeChose(PickAction.Type type) { if (type.equals(PickAction.Type.PRODUCER)) { new ShowUsagesAction(PRODUCERS).startFindUsages(eventClass, new RelativePoint(mouseEvent), PsiUtilBase.findEditor(psiElement), MAX_USAGES); } else if (type.equals(PickAction.Type.EVENT_POST)) { PsiMethod ottoBusMethod = subscriberMetadata.getBusPostMethod(psiElement.getProject()); new ShowUsagesAction(new BusPostDecider(eventClass)).startFindUsages( ottoBusMethod, new RelativePoint(mouseEvent), PsiUtilBase.findEditor(psiElement), MAX_USAGES); } } }); } }
Example #5
Source File: StatePropCompletionContributor.java From litho with Apache License 2.0 | 5 votes |
private static CompletionProvider<CompletionParameters> typeCompletionProvider() { return new CompletionProvider<CompletionParameters>() { @Override protected void addCompletions( @NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { PsiElement element = completionParameters.getPosition(); // Method parameter type in the Spec class // PsiIdentifier -> PsiJavaCodeReferenceElement -> PsiTypeElement -> PsiMethod -> PsiClass PsiElement typeElement = PsiTreeUtil.getParentOfType(element, PsiTypeElement.class); if (typeElement == null) { return; } PsiMethod containingMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class); if (containingMethod == null) { return; } PsiClass cls = containingMethod.getContainingClass(); if (!LithoPluginUtils.isLithoSpec(cls)) { return; } // @Prop or @State annotation PsiModifierList parameterModifiers = PsiTreeUtil.getPrevSiblingOfType(typeElement, PsiModifierList.class); if (parameterModifiers == null) { return; } if (parameterModifiers.findAnnotation(Prop.class.getName()) != null) { addCompletionResult( completionResultSet, containingMethod, cls.getMethods(), LithoPluginUtils::isProp); } else if (parameterModifiers.findAnnotation(State.class.getName()) != null) { addCompletionResult( completionResultSet, containingMethod, cls.getMethods(), LithoPluginUtils::isState); } } }; }
Example #6
Source File: PsiEventDeclarationsExtractor.java From litho with Apache License 2.0 | 5 votes |
public static PsiType getReturnPsiType(@Nullable PsiClass eventClass) { return Optional.ofNullable(eventClass) .map(cls -> AnnotationUtil.findAnnotation(eventClass, Event.class.getTypeName())) .map(psiAnnotation -> psiAnnotation.findAttributeValue("returnType")) .filter(PsiClassObjectAccessExpression.class::isInstance) .map(PsiClassObjectAccessExpression.class::cast) .map(PsiClassObjectAccessExpression::getOperand) .map(PsiTypeElement::getType) .orElse(PsiType.VOID); }
Example #7
Source File: PsiJavaElementVisitor.java From KodeBeagle with Apache License 2.0 | 5 votes |
private void visitPsiDeclarationStatement(final PsiDeclarationStatement declarationStatement) { Collection<PsiTypeElement> typeElements = PsiTreeUtil.findChildrenOfType(declarationStatement, PsiTypeElement.class); for (PsiTypeElement element : typeElements) { String type = removeSpecialSymbols(element.getType().getCanonicalText()); addInMap(type, emptySet); } }
Example #8
Source File: LombokAugmentProvider.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nullable @Override protected PsiType inferType(@NotNull PsiTypeElement typeElement) { if (!valProcessor.isEnabled(typeElement.getProject())) { return null; } return valProcessor.inferType(typeElement); }
Example #9
Source File: OttoLineMarkerProvider.java From otto-intellij-plugin with Apache License 2.0 | 5 votes |
@Override public boolean shouldShow(Usage usage) { PsiElement element = ((UsageInfo2UsageAdapter) usage).getElement(); if (element instanceof PsiJavaCodeReferenceElement) { if ((element = element.getContext()) instanceof PsiTypeElement) { if ((element = element.getContext()) instanceof PsiParameter) { if ((element = element.getContext()) instanceof PsiParameterList) { if ((element = element.getContext()) instanceof PsiMethod) { return SubscriberMetadata.isAnnotatedWithSubscriber((PsiMethod) element); } } } } } return false; }
Example #10
Source File: OttoLineMarkerProvider.java From otto-intellij-plugin with Apache License 2.0 | 5 votes |
@Override public void navigate(MouseEvent mouseEvent, PsiElement psiElement) { if (psiElement instanceof PsiMethod) { PsiMethod psiMethod = (PsiMethod) psiElement; PsiTypeElement returnTypeElement = psiMethod.getReturnTypeElement(); PsiClass eventClass = ((PsiClassType) returnTypeElement.getType()).resolve(); new ShowUsagesAction(SUBSCRIBERS).startFindUsages(eventClass, new RelativePoint(mouseEvent), PsiUtilBase.findEditor(returnTypeElement), MAX_USAGES); } }
Example #11
Source File: OttoLineMarkerProvider.java From otto-intellij-plugin with Apache License 2.0 | 5 votes |
public static @Nullable PsiTypeElement getMethodParameter(PsiMethod subscribeMethod) { PsiParameterList parameterList = subscribeMethod.getParameterList(); if (parameterList.getParametersCount() != 1) { return null; } else { PsiParameter subscribeMethodParam = parameterList.getParameters()[0]; return subscribeMethodParam.getTypeElement(); } }
Example #12
Source File: SqliteMagicInspection.java From sqlitemagic with Apache License 2.0 | 4 votes |
@Override public void visitTypeElement(PsiTypeElement type) { super.visitTypeElement(type); }
Example #13
Source File: NavigationMarker.java From android-butterknife-zelezny with Apache License 2.0 | 4 votes |
@NotNull NavigationMarker build() { final PsiTypeElement typeElement = source instanceof PsiField ? ((PsiField) source).getTypeElement() : null; final TextRange textRange = typeElement != null ? typeElement.getTextRange() : source.getTextRange(); return new NavigationMarker(source, destination, textRange); }