Last active
August 29, 2015 14:16
-
-
Save rvillars/921880f15d43721d0d6c to your computer and use it in GitHub Desktop.
Intellij Plugin Code Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
finalAsyncResult<DataContext>dataContext=DataManager.getInstance().getDataContextFromFocus(); | |
finalProjectproject=DataKeys.PROJECT.getData(dataContext.getResult()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PsiClassaggregateClass=JavaPsiFacade.getInstance(project).findClass("my.full.qualified.Class",GlobalSearchScope.allScope(project)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PsiFilepsiFile=PsiManager.getInstance(project).findFile((VirtualFile)o); | |
if(!(psiFileinstanceofPsiJavaFile)){ | |
returnfalse; | |
} | |
PsiJavaFilepsiJavaFile=(PsiJavaFile)psiFile; | |
PsiClass[]psiClasses=psiJavaFile.getClasses(); | |
PsiClasspsiClass=psiClasses[0]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private List<PsiClass> getSuperClasses(PsiClass psiClass) { | |
final ArrayList<PsiClass> superClasses = new ArrayList<PsiClass>(); | |
while (!"java.lang.Object".equals(psiClass.getQualifiedName())) { | |
final PsiClass psiClass1 = psiClass; | |
final PsiClass[] superTypes = psiClass1.getSupers(); | |
PsiClass superType = null; | |
for (int i = 0; i < superTypes.length; i++) { | |
final PsiClass type = superTypes[i]; | |
if (!type.isInterface()) { | |
superType = type; | |
break; | |
} | |
} | |
if (superType == null) break; | |
if (superClasses.contains(superType)) break; | |
superClasses.add(superType); | |
psiClass = superType; | |
} | |
return superClasses; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment