com.intellij.psi.PsiType Java Examples
The following examples show how to use
com.intellij.psi.PsiType.
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: CamelDocumentationProvider.java From camel-idea-plugin with Apache License 2.0 | 6 votes |
private boolean isPsiMethodCamelLanguage(PsiMethod method) { PsiType type = method.getReturnType(); if (type != null && type instanceof PsiClassReferenceType) { PsiClassReferenceType clazz = (PsiClassReferenceType) type; PsiClass resolved = clazz.resolve(); if (resolved != null) { boolean language = getCamelIdeaUtils().isCamelExpressionOrLanguage(resolved); // try parent using some weird/nasty stub stuff which is how complex IDEA AST // is when its parsing the Camel route builder if (!language) { PsiElement elem = resolved.getParent(); if (elem instanceof PsiTypeParameterList) { elem = elem.getParent(); } if (elem instanceof PsiClass) { language = getCamelIdeaUtils().isCamelExpressionOrLanguage((PsiClass) elem); } } return language; } } return false; }
Example #2
Source File: PsiJavaElementVisitor.java From KodeBeagle with Apache License 2.0 | 6 votes |
private void visitPsiFields(final PsiField psiField) { if (!ClassUtils.isPrimitive(psiField.getType())) { String type = removeSpecialSymbols(psiField.getType().getCanonicalText()); if (psiField.getInitializer() != null) { PsiExpression psiExpression = psiField.getInitializer(); if (psiExpression != null) { PsiType psiType = psiExpression.getType(); if (psiType != null && !ClassUtils.isPrimitive(psiType)) { String psiFieldInitializer = removeSpecialSymbols(psiType.getCanonicalText()); addInMap(psiFieldInitializer, emptySet); } } } addInMap(type, emptySet); } }
Example #3
Source File: SingularGuavaTableHandler.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public String renderBuildCode(@NotNull PsiVariable psiVariable, @NotNull String fieldName, @NotNull String builderVariable) { final PsiManager psiManager = psiVariable.getManager(); final PsiType psiFieldType = psiVariable.getType(); final PsiType rowKeyType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, COM_GOOGLE_COMMON_COLLECT_TABLE, 0); final PsiType columnKeyType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, COM_GOOGLE_COMMON_COLLECT_TABLE, 1); final PsiType valueType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, COM_GOOGLE_COMMON_COLLECT_TABLE, 2); return MessageFormat.format( "{4}<{1}, {2}, {3}> {0} = " + "{5}.{0} == null ? " + "{4}.<{1}, {2}, {3}>of() : " + "{5}.{0}.build();\n", fieldName, rowKeyType.getCanonicalText(false), columnKeyType.getCanonicalText(false), valueType.getCanonicalText(false), collectionQualifiedName, builderVariable); }
Example #4
Source File: LombokLightParameter.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } LombokLightParameter that = (LombokLightParameter) o; final PsiType thisType = getType(); final PsiType thatType = that.getType(); if (thisType.isValid() != thatType.isValid()) { return false; } return thisType.getCanonicalText().equals(thatType.getCanonicalText()); }
Example #5
Source File: GetterFieldProcessor.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 6 votes |
private boolean validateExistingMethods(@NotNull PsiField psiField, @NotNull ProblemBuilder builder) { boolean result = true; final PsiClass psiClass = psiField.getContainingClass(); if (null != psiClass) { final boolean isBoolean = PsiType.BOOLEAN.equals(psiField.getType()); final AccessorsInfo accessorsInfo = AccessorsInfo.build(psiField); final Collection<String> methodNames = LombokUtils.toAllGetterNames(accessorsInfo, psiField.getName(), isBoolean); final Collection<PsiMethod> classMethods = PsiClassUtil.collectClassMethodsIntern(psiClass); filterToleratedElements(classMethods); for (String methodName : methodNames) { if (PsiMethodUtil.hasSimilarMethod(classMethods, methodName, 0)) { final String setterMethodName = LombokUtils.getGetterName(psiField); builder.addWarning("Not generated '%s'(): A method with similar name '%s' already exists", setterMethodName, methodName); result = false; } } } return result; }
Example #6
Source File: PsiUtils.java From data-mediator with Apache License 2.0 | 6 votes |
/** * Resolves generics on the given type and returns them (if any) or null if there are none */ public static List<PsiType> getResolvedGenerics(PsiType type) { List<PsiType> psiTypes = null; if (type instanceof PsiClassType) { PsiClassType pct = (PsiClassType) type; psiTypes = new ArrayList<PsiType>(pct.resolveGenerics().getSubstitutor().getSubstitutionMap().values()); } return psiTypes; }
Example #7
Source File: SpringConfigurationMetadataHintValue.java From intellij-spring-assistant with MIT License | 6 votes |
@NotNull public Suggestion buildSuggestionForValue(FileType fileType, List<? extends SuggestionNode> matchesRootTillLeaf, @Nullable String defaultValue, @Nullable PsiType valueType) { Suggestion.SuggestionBuilder builder = Suggestion.builder().suggestionToDisplay(toString()).description(description).forValue(true) .matchesTopFirst(matchesRootTillLeaf).numOfAncestors(matchesRootTillLeaf.size()); if (valueType != null) { builder.shortType(shortenedType(valueType.getCanonicalText())); builder.icon(SuggestionNodeType.ENUM.getIcon()); } builder.representingDefaultValue(toString().equals(defaultValue)); return builder.fileType(fileType).build(); }
Example #8
Source File: DummyClassMetadata.java From intellij-spring-assistant with MIT License | 6 votes |
@NotNull @Override public String getDocumentationForKey(Module module, String nodeNavigationPathDotDelimited) { /* * <p><b>a.b.c</b> ({@link com.acme.Generic}<{@link com.acme.Class1}, {@link com.acme.Class2}>)</p> * <p>Long description</p> */ StringBuilder builder = new StringBuilder().append("<b>").append(nodeNavigationPathDotDelimited).append("</b>"); PsiType psiType = getPsiType(module); if (psiType != null) { String classFqn = toClassFqn(psiType); StringBuilder linkBuilder = new StringBuilder(); createHyperlink(linkBuilder, classFqn, classFqn, false); builder.append(" (").append(linkBuilder.toString()).append(")"); } return builder.toString(); }
Example #9
Source File: ValModifierTest.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void testValModifiersEditing() { PsiFile file = myFixture.configureByText("a.java", "import lombok.val;\nclass Foo { {val o = <caret>;} }"); PsiLocalVariable var = PsiTreeUtil.getParentOfType(file.findElementAt(myFixture.getCaretOffset()), PsiLocalVariable.class); assertNotNull(var); PsiType type1 = var.getType(); assertNotNull(type1); assertEquals("lombok.val", type1.getCanonicalText(false)); myFixture.type('1'); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); assertTrue(var.isValid()); assertNotNull(var.getModifierList()); assertTrue("val should make variable final", var.getModifierList().hasModifierProperty(PsiModifier.FINAL)); }
Example #10
Source File: PsiCustomUtil.java From intellij-spring-assistant with MIT License | 6 votes |
@Nullable public static PsiType safeGetValidType(@NotNull Module module, @NotNull String fqn) { try { // Intellij expects inner classes to be referred via `.` instead of `$` PsiType type = JavaPsiFacade.getInstance(module.getProject()).getParserFacade() .createTypeFromText(fqn.replaceAll("\\$", "."), null); boolean typeValid = isValidType(type); if (typeValid) { if (type instanceof PsiClassType) { return PsiClassType.class.cast(type); } else if (type instanceof PsiArrayType) { return PsiArrayType.class.cast(type); } } return null; } catch (IncorrectOperationException e) { debug(() -> log.debug("Unable to find class fqn " + fqn)); return null; } }
Example #11
Source File: ClassSuggestionNodeFactory.java From intellij-spring-assistant with MIT License | 6 votes |
@NotNull public static MetadataProxy newMetadataProxy(Module module, @NotNull PsiType type) { if (type instanceof PsiArrayType) { return new ArrayMetadataProxy(module, (PsiArrayType) type); } else if (type instanceof PsiPrimitiveType) { PsiPrimitiveType primitiveType = (PsiPrimitiveType) type; type = getBoxedTypeFromPrimitiveType(module, primitiveType); } if (type instanceof PsiClassType) { SuggestionNodeType suggestionNodeType = getSuggestionNodeType(type); if (suggestionNodeType == SuggestionNodeType.MAP) { return new MapClassMetadataProxy((PsiClassType) type); } else { return new ClassMetadataProxy((PsiClassType) type); } } throw new IllegalAccessError( "Supports only PsiArrayType, PsiPrimitiveType & PsiClassType types"); }
Example #12
Source File: SetterFieldProcessor.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 6 votes |
private boolean validateExistingMethods(@NotNull PsiField psiField, @NotNull ProblemBuilder builder) { boolean result = true; final PsiClass psiClass = psiField.getContainingClass(); if (null != psiClass) { final Collection<PsiMethod> classMethods = PsiClassUtil.collectClassMethodsIntern(psiClass); filterToleratedElements(classMethods); final boolean isBoolean = PsiType.BOOLEAN.equals(psiField.getType()); final Collection<String> methodNames = getAllSetterNames(psiField, isBoolean); for (String methodName : methodNames) { if (PsiMethodUtil.hasSimilarMethod(classMethods, methodName, 1)) { final String setterMethodName = getSetterName(psiField, isBoolean); builder.addWarning("Not generated '%s'(): A method with similar name '%s' already exists", setterMethodName, methodName); result = false; } } } return result; }
Example #13
Source File: BooleanClassMetadata.java From intellij-spring-assistant with MIT License | 6 votes |
@Nullable @Override protected String doGetDocumentationForValue(Module module, String nodeNavigationPathDotDelimited, String originalValue) { // Format for the documentation is as follows /* * <p><b>a.b.c</b> ({@link com.acme.Generic}<{@link com.acme.Class1}, {@link com.acme.Class2}>)</p> * <p>Long description</p> * or of this type * <p><b>Type</b> {@link com.acme.Array}[]</p> * <p><b>Declared at</b>{@link com.acme.GenericRemovedClass#method}></p> <-- only for groups with method info */ StringBuilder builder = new StringBuilder().append("<b>").append(nodeNavigationPathDotDelimited).append("</b>"); String classFqn = PsiType.BOOLEAN.getBoxedTypeName(); StringBuilder linkBuilder = new StringBuilder(); createHyperlink(linkBuilder, classFqn, classFqn, false); builder.append(" (").append(linkBuilder.toString()).append(")"); builder.append("<p>").append(originalValue).append("</p>"); return builder.toString(); }
Example #14
Source File: PsiCustomUtil.java From intellij-spring-assistant with MIT License | 6 votes |
public static boolean isValidType(@NotNull PsiType type) { if (!type.isValid()) { TimeoutUtil.sleep( 1); // to see if processing in another thread suddenly makes the type valid again (which is a bug) if (!type.isValid()) { return false; } } if (type instanceof PsiArrayType) { return isValidType(PsiArrayType.class.cast(type).getComponentType()); } else if (type instanceof PsiWildcardType) { PsiType bound = ((PsiWildcardType) type).getBound(); return bound != null && isValidType(bound); } else if (type instanceof PsiCapturedWildcardType) { PsiType lowerBound = ((PsiCapturedWildcardType) type).getLowerBound(); type = (lowerBound != NULL ? lowerBound : ((PsiCapturedWildcardType) type).getUpperBound()); return type != NULL && isValidType(type); } else if (type instanceof PsiClassType) { PsiClassType.ClassResolveResult classResolveResult = ((PsiClassType) type).resolveGenerics(); return classResolveResult.isValidResult() && isValidElement( requireNonNull(classResolveResult.getElement())) && !hasUnresolvedComponents(type); } return true; }
Example #15
Source File: PsiUtils.java From android-parcelable-intellij-plugin with Apache License 2.0 | 5 votes |
/** * Checks that the given type is an implementer of the given canonicalName with the given typed parameters * * @param type what we're checking against * @param canonicalName the type must extend/implement this generic * @param canonicalParamNames the type that the generic(s) must be (in this order) * @return */ public static boolean isTypedClass(PsiType type, String canonicalName, String... canonicalParamNames) { PsiClass parameterClass = PsiTypesUtil.getPsiClass(type); if (parameterClass == null) { return false; } // This is a safe cast, for if parameterClass != null, the type was checked in PsiTypesUtil#getPsiClass(...) PsiClassType pct = (PsiClassType) type; // Main class name doesn't match; exit early if (!canonicalName.equals(parameterClass.getQualifiedName())) { return false; } List<PsiType> psiTypes = new ArrayList<PsiType>(pct.resolveGenerics().getSubstitutor().getSubstitutionMap().values()); for (int i = 0; i < canonicalParamNames.length; i++) { if (!isOfType(psiTypes.get(i), canonicalParamNames[i])) { return false; } } // Passed all screenings; must be a match! return true; }
Example #16
Source File: ValTest.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void verifyLocalVariableType(final String expectedType) { final PsiElement elementAtCaret = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); assertTrue(elementAtCaret instanceof PsiIdentifier); final PsiElement localVariable = elementAtCaret.getParent(); assertTrue(localVariable.toString(), localVariable instanceof PsiLocalVariable); final PsiType type = ((PsiLocalVariable) localVariable).getType(); assertNotNull(localVariable.toString(), type); assertTrue(type.getCanonicalText(), type.equalsToText(expectedType)); }
Example #17
Source File: NoDelegateOnResumeDetector.java From PermissionsDispatcher with Apache License 2.0 | 5 votes |
/** * @return return true if visiting end (if lint does not visit inside the method), false otherwise */ @Override public boolean visitMethod(UMethod node) { super.visitMethod(node); return !"onResume".equalsIgnoreCase(node.getName()) || node.getReturnType() != PsiType.VOID || node.getUastParameters().size() != 0 || !isPublicOrProtected(node); }
Example #18
Source File: SingularMapHandler.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public String renderBuildCode(@NotNull PsiVariable psiVariable, @NotNull String fieldName, @NotNull String builderVariable) { final PsiManager psiManager = psiVariable.getManager(); final PsiType psiFieldType = psiVariable.getType(); final PsiType keyType = getKeyType(psiManager, psiFieldType); final PsiType valueType = getValueType(psiManager, psiFieldType); final String selectedFormat; if (collectionQualifiedName.equals(SingularCollectionClassNames.JAVA_UTIL_SORTED_MAP)) { selectedFormat = "java.util.SortedMap<{1}, {2}> {0} = new java.util.TreeMap<{1}, {2}>();\n" + " if ({3}.{0}$key != null) for (int $i = 0; $i < ({3}.{0}$key == null ? 0 : {3}.{0}$key.size()); $i++) {0}.put({3}.{0}$key.get($i), ({2}){3}.{0}$value.get($i));\n" + " {0} = java.util.Collections.unmodifiableSortedMap({0});\n"; } else if (collectionQualifiedName.equals(SingularCollectionClassNames.JAVA_UTIL_NAVIGABLE_MAP)) { selectedFormat = "java.util.NavigableMap<{1}, {2}> {0} = new java.util.TreeMap<{1}, {2}>();\n" + " if ({3}.{0}$key != null) for (int $i = 0; $i < ({3}.{0}$key == null ? 0 : {3}.{0}$key.size()); $i++) {0}.put({3}.{0}$key.get($i), ({2}){3}.{0}$value.get($i));\n" + " {0} = java.util.Collections.unmodifiableNavigableMap({0});\n"; } else { selectedFormat = "java.util.Map<{1}, {2}> {0};\n" + " switch ({3}.{0}$key == null ? 0 : {3}.{0}$key.size()) '{'\n" + " case 0:\n" + " {0} = java.util.Collections.emptyMap();\n" + " break;\n" + " case 1:\n" + " {0} = java.util.Collections.singletonMap({3}.{0}$key.get(0), {3}.{0}$value.get(0));\n" + " break;\n" + " default:\n" + " {0} = new java.util.LinkedHashMap<{1}, {2}>({3}.{0}$key.size() < 1073741824 ? 1 + {3}.{0}$key.size() + ({3}.{0}$key.size() - 3) / 3 : java.lang.Integer.MAX_VALUE);\n" + " for (int $i = 0; $i < {3}.{0}$key.size(); $i++) {0}.put({3}.{0}$key.get($i), ({2}){3}.{0}$value.get($i));\n" + " {0} = java.util.Collections.unmodifiableMap({0});\n" + " '}'\n"; } return MessageFormat.format(selectedFormat, fieldName, keyType.getCanonicalText(false), valueType.getCanonicalText(false), builderVariable); }
Example #19
Source File: PsiTypeUtil.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
@NotNull public static PsiType createCollectionType(@NotNull PsiManager psiManager, final String collectionQualifiedName, @NotNull PsiType... psiTypes) { final Project project = psiManager.getProject(); final GlobalSearchScope globalsearchscope = GlobalSearchScope.allScope(project); final JavaPsiFacade facade = JavaPsiFacade.getInstance(project); final PsiClass genericClass = facade.findClass(collectionQualifiedName, globalsearchscope); if (null != genericClass) { return JavaPsiFacade.getElementFactory(project).createType(genericClass, psiTypes); } else { return getJavaLangObject(psiManager); } }
Example #20
Source File: LombokEqualsAndHashcodeHandler.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected void processClass(@NotNull PsiClass psiClass) { final PsiMethod equalsMethod = findPublicNonStaticMethod(psiClass, "equals", PsiType.BOOLEAN, PsiType.getJavaLangObject(psiClass.getManager(), psiClass.getResolveScope())); if (null != equalsMethod) { equalsMethod.delete(); } final PsiMethod hashCodeMethod = findPublicNonStaticMethod(psiClass, "hashCode", PsiType.INT); if (null != hashCodeMethod) { hashCodeMethod.delete(); } addAnnotation(psiClass, EqualsAndHashCode.class); }
Example #21
Source File: IntroduceLombokVariableHandler.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
private IntroduceVariableSettings getIntroduceVariableSettings(Project project, IntroduceVariableSettings variableSettings) { final PsiClassType psiClassType = PsiType.getTypeByName(selectedTypeFQN, project, GlobalSearchScope.projectScope(project)); if (null != psiClassType) { return new IntroduceVariableSettingsDelegate(variableSettings, psiClassType); } else { return variableSettings; } }
Example #22
Source File: PsiTypeConverterTest.java From json2java4idea with Apache License 2.0 | 5 votes |
@Test public void apply() throws Exception { // exercise final PsiType actual = underTest.apply(typeName); // verify assertThat(actual) .isEqualTo(expected); }
Example #23
Source File: ClassSuggestionNodeFactory.java From intellij-spring-assistant with MIT License | 5 votes |
static ClassMetadata newClassMetadata(@NotNull PsiType type) { SuggestionNodeType nodeType = getSuggestionNodeType(type); switch (nodeType) { case BOOLEAN: return new BooleanClassMetadata(); case BYTE: case SHORT: case INT: case LONG: case FLOAT: case DOUBLE: case CHAR: case STRING: return new DummyClassMetadata(nodeType); case ENUM: return new EnumClassMetadata((PsiClassType) type); case ITERABLE: return new IterableClassMetadata((PsiClassType) type); case MAP: return new MapClassMetadata((PsiClassType) type); case KNOWN_CLASS: return new GenericClassMetadata((PsiClassType) type); case UNKNOWN_CLASS: return new DummyClassMetadata(nodeType); default: throw new IllegalStateException( "Class suggestion node for the specified class " + type + " is undefined"); } }
Example #24
Source File: SingularGuavaTableHandler.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
@NotNull protected PsiType getBuilderFieldType(@NotNull PsiType psiFieldType, @NotNull Project project) { final PsiManager psiManager = PsiManager.getInstance(project); final PsiType rowKeyType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, COM_GOOGLE_COMMON_COLLECT_TABLE, 0); final PsiType columnKeyType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, COM_GOOGLE_COMMON_COLLECT_TABLE, 1); final PsiType valueType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, COM_GOOGLE_COMMON_COLLECT_TABLE, 2); return PsiTypeUtil.createCollectionType(psiManager, collectionQualifiedName + ".Builder", rowKeyType, columnKeyType, valueType); }
Example #25
Source File: PsiJavaElementVisitor.java From KodeBeagle with Apache License 2.0 | 5 votes |
private void visitPsiCatchSection(final PsiCatchSection element) { PsiType catchType = element.getCatchType(); if (catchType != null) { String qualifiedName = removeSpecialSymbols(catchType.getCanonicalText()); addInMap(qualifiedName, emptySet); } }
Example #26
Source File: SynchronizedProcessor.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
@NotNull @Override public Collection<LombokProblem> verifyAnnotation(@NotNull PsiAnnotation psiAnnotation) { final ProblemNewBuilder problemNewBuilder = new ProblemNewBuilder(2); PsiMethod psiMethod = PsiTreeUtil.getParentOfType(psiAnnotation, PsiMethod.class); if (null != psiMethod) { if (psiMethod.hasModifierProperty(PsiModifier.ABSTRACT)) { problemNewBuilder.addError("'@Synchronized' is legal only on concrete methods.", PsiQuickFixFactory.createModifierListFix(psiMethod, PsiModifier.ABSTRACT, false, false) ); } final String lockFieldName = PsiAnnotationUtil.getStringAnnotationValue(psiAnnotation, "value"); if (StringUtil.isNotEmpty(lockFieldName)) { final PsiClass containingClass = psiMethod.getContainingClass(); if (null != containingClass) { final PsiField lockField = containingClass.findFieldByName(lockFieldName, true); if (null != lockField) { if (!lockField.hasModifierProperty(PsiModifier.FINAL)) { problemNewBuilder.addWarning(String.format("Synchronization on a non-final field %s.", lockFieldName), PsiQuickFixFactory.createModifierListFix(lockField, PsiModifier.FINAL, true, false)); } } else { final PsiClassType javaLangObjectType = PsiType.getJavaLangObject(containingClass.getManager(), containingClass.getResolveScope()); problemNewBuilder.addError(String.format("The field %s does not exist.", lockFieldName), PsiQuickFixFactory.createNewFieldFix(containingClass, lockFieldName, javaLangObjectType, "new Object()", PsiModifier.PRIVATE, PsiModifier.FINAL)); } } } } else { problemNewBuilder.addError("'@Synchronized' is legal only on methods."); } return problemNewBuilder.getProblems(); }
Example #27
Source File: SingularGuavaMapHandler.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
@NotNull protected PsiType getBuilderFieldType(@NotNull PsiType psiFieldType, @NotNull Project project) { final PsiManager psiManager = PsiManager.getInstance(project); final PsiType keyType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, CommonClassNames.JAVA_UTIL_MAP, 0); final PsiType valueType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, CommonClassNames.JAVA_UTIL_MAP, 1); return PsiTypeUtil.createCollectionType(psiManager, collectionQualifiedName + ".Builder", keyType, valueType); }
Example #28
Source File: BeanReferenceCompletionExtension.java From camel-idea-plugin with Apache License 2.0 | 5 votes |
private List<ReferenceableBeanId> findTargets(PsiElement element, String query) { Module module = ModuleUtilCore.findModuleForPsiElement(element); if (module == null) { return Collections.emptyList(); } PsiType expectedType = getExpectedType(element); Predicate<String> beanIdPredicate = b -> b.startsWith(query); if (expectedType != null) { return BeanUtils.getService().findReferenceableBeanIdsByType(module, beanIdPredicate, expectedType); } else { return BeanUtils.getService().findReferenceableBeanIds(module, beanIdPredicate); } }
Example #29
Source File: JavaCamelIdeaUtils.java From camel-idea-plugin with Apache License 2.0 | 5 votes |
private String getStaticBeanName(PsiJavaCodeReferenceElement referenceElement, String beanName) { final PsiType type = ((PsiReferenceExpression) referenceElement).getType(); if (type != null && JAVA_LANG_STRING.equals(type.getCanonicalText())) { beanName = StringUtils.stripDoubleQuotes(PsiTreeUtil.getChildOfAnyType(referenceElement.getReference().resolve(), PsiLiteralExpression.class).getText()); } return beanName; }
Example #30
Source File: DateSerializerFactory.java From android-parcelable-intellij-plugin with Apache License 2.0 | 5 votes |
@Override public TypeSerializer getSerializer(PsiType psiType) { if ("java.util.Date".equals(psiType.getCanonicalText())) { return mSerializer; } return null; }