Skip to content

Commit

Permalink
test convertor done and add gif
Browse files Browse the repository at this point in the history
  • Loading branch information
LightSun committed Nov 15, 2017
1 parent 0c2755f commit 7115cb7
Show file tree
Hide file tree
Showing 55 changed files with 130 additions and 2,665 deletions.
21 changes: 0 additions & 21 deletions Data-mediator-demo/.idea/compiler.xml

This file was deleted.

3 changes: 0 additions & 3 deletions Data-mediator-demo/.idea/copyright/profiles_settings.xml

This file was deleted.

3 changes: 0 additions & 3 deletions Data-mediator-demo/.idea/dictionaries/Administrator.xml

This file was deleted.

20 changes: 0 additions & 20 deletions Data-mediator-demo/.idea/gradle.xml

This file was deleted.

10 changes: 0 additions & 10 deletions Data-mediator-demo/.idea/inspectionProfiles/Project_Default.xml

This file was deleted.

This file was deleted.

75 changes: 0 additions & 75 deletions Data-mediator-demo/.idea/misc.xml

This file was deleted.

11 changes: 0 additions & 11 deletions Data-mediator-demo/.idea/modules.xml

This file was deleted.

12 changes: 0 additions & 12 deletions Data-mediator-demo/.idea/runConfigurations.xml

This file was deleted.

6 changes: 0 additions & 6 deletions Data-mediator-demo/.idea/vcs.xml

This file was deleted.

6 changes: 0 additions & 6 deletions data-binding-test/.idea/vcs.xml

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void actionPerformed(AnActionEvent e) {
@Override
public void update(AnActionEvent e) {
PsiClass psiClass = getPsiClassFromContext(e);
e.getPresentation().setEnabled(psiClass != null && !psiClass.isInterface());
e.getPresentation().setEnabled(psiClass != null && !psiClass.isInterface() && psiClass.isWritable());
}

private PsiClass getPsiClassFromContext(AnActionEvent e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void parse(){
LinkedList<PsiClass> list = new LinkedList<>();
list.addLast(mPsiClass);
PsiClass superClass = mPsiClass.getSuperClass();
while (superClass != null){
while (superClass != null && superClass.isWritable()){
String qualifiedName = superClass.getQualifiedName();
if(qualifiedName == null || qualifiedName.startsWith("java.") || qualifiedName.startsWith("android.")){
break;
Expand All @@ -54,8 +54,10 @@ public void parse(){

private void parseInternal(PsiClass mPsiClass) {
final ClassInfo info = new ClassInfo();
if(mPsiClass.getSuperClass() != null){
info.addInterface(getSuperClassAsInterfaceName(mPsiClass.getSuperClass()));
PsiClass superClass = mPsiClass.getSuperClass();
//must writable
if(superClass != null && superClass.isWritable()){
info.addInterface(getSuperClassAsInterfaceName(superClass));
}
for(PsiClass pcs : mPsiClass.getInterfaces()){
info.addInterface(pcs.getQualifiedName());
Expand Down Expand Up @@ -149,24 +151,35 @@ private void generateInternal(PsiClass mPsiClass, ClassInfo info) {
Util.log("mPsiClass.getName() == null");
return;
}
final String name = "I" + mPsiClass.getName();
final Project project = mPsiClass.getProject();
//delete if exist
PsiClass psiClass_pre = JavaPsiFacade.getInstance(project).findClass(getSuperClassAsInterfaceName(mPsiClass),
GlobalSearchScope.projectScope(project));
if(psiClass_pre != null && psiClass_pre.isValid()){
if(!psiClass_pre.isWritable()){
Util.log("the previous PsiClass (" + psiClass_pre.getQualifiedName() + ") can write. will be ignored.");
return;
}
psiClass_pre.delete();
}

final String name = "I" + mPsiClass.getName();
JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(project);
PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);

PsiElement parent = mPsiClass.getParent();
if(parent instanceof PsiClass){
Util.log("start nested class.");
PsiClass psic = elementFactory.createInterface(name);
psic.getModifierList().addAnnotation("com.heaven7.java.data.mediator.Fields(value ={"
psic.getModifierList().addAnnotation("com.heaven7.java.data.mediator.Fields(value ={\n"
+ buildFieldAnnotations(info.getPropertyInfos())+ "\n} , generateJsonAdapter = false)");
if (!addExtendInterfaces(info, styleManager, elementFactory, psic)) {
return;
}
styleManager.shortenClassReferences(parent.addAfter(psic, mPsiClass));
}else{
PsiDirectory dir = mPsiClass.getContainingFile().getContainingDirectory();
PsiClass psiClass = createJavaFile(name, "@com.heaven7.java.data.mediator.Fields(value ={"
PsiClass psiClass = createJavaFile(name, "@com.heaven7.java.data.mediator.Fields(value ={\n"
+ buildFieldAnnotations(info.getPropertyInfos())
+ "\n}, generateJsonAdapter = false) "
+ "public interface " + name + "{}");
Expand Down

This file was deleted.

15 changes: 0 additions & 15 deletions data-mediator-intellij-plugin/.idea/compiler.xml

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions data-mediator-intellij-plugin/.idea/encodings.xml

This file was deleted.

6 changes: 0 additions & 6 deletions data-mediator-intellij-plugin/.idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions data-mediator-intellij-plugin/.idea/modules.xml

This file was deleted.

This file was deleted.

Loading

0 comments on commit 7115cb7

Please sign in to comment.