Extending code completion to support internal orm

已回答

As said in the tittle, i need to extend code completion to support a internal ORM.


It's something like ActiveRecords. Ex.:

 

@TableName("ONE_MODEL")
public class OneModel extends BaseModel {

}

...
OneModel oneModel = OneModel.getById(1);
Object value = oneModel.get("COLUMN_NAME");
...



So, when using smart completion when caret between quotation marks inside de .get method, for example, i need to show parameters options based on the table columns.

Something like that it's possible to be made with Intellij Plugins?

Edit:
I was reading about CompletionContributor, but really need to know if it's possible to identify the class whose method is being called, it's super class, and it's annotations values.



0
正式评论

Yes, it's surely possible. In the completion contributor you have CompletionParameters#getPosition, which would a token inside PsiLiteralExpression. Traversing the PSI tree up you'd find PsiMethodCallExpression, whose #resolveMethod() would return you a PsiMethod "get". Its getContainingClass and then getModifierList().findAnnotation() would return the annotation. The super class can be obtained using com.intellij.psi.PsiClass#getSuperClass.

Thank you, i resolved the main problem.

Now i need to extract information from database objects.
Maybe Database Tools Plugin can do this?Can I integrate it with my plugin? Any tips, examples or links?

0

请先登录再写评论。