Search in sources :

Example 11 with ClassEntity

use of org.gsonformat.intellij.entity.ClassEntity in project GsonFormat by zzz40500.

the class ConvertBridge method recursionInnerClass.

private void recursionInnerClass(ClassEntity classEntity) {
    PsiClass[] innerClassArray = classEntity.getPsiClass().getAllInnerClasses();
    for (PsiClass psiClass : innerClassArray) {
        ClassEntity item = new ClassEntity();
        item.setLock(true);
        if (declareClass.containsKey(psiClass.getQualifiedName())) {
            return;
        }
        declareClass.put(psiClass.getQualifiedName(), item);
        CheckUtil.getInstant().addDeclareClassName(psiClass.getQualifiedName());
        item.setClassName(psiClass.getName());
        item.addAllFields(collectDeclareFields(psiClass));
        item.setPsiClass(psiClass);
        item.setPackName(getPackName(psiClass));
        recursionInnerClass(item);
    }
}
Also used : ClassEntity(org.gsonformat.intellij.entity.ClassEntity)

Example 12 with ClassEntity

use of org.gsonformat.intellij.entity.ClassEntity in project GsonFormat by zzz40500.

the class ConvertBridge method typeByValue.

private FieldEntity typeByValue(ClassEntity parentClass, String key, Object type) {
    FieldEntity result;
    if (type instanceof JSONObject) {
        ClassEntity classEntity = existDeclareClass((JSONObject) type);
        if (classEntity == null) {
            FieldEntity fieldEntity = new FieldEntity();
            ClassEntity innerClassEntity = createInnerClass(createSubClassName(key, type), (JSONObject) type, parentClass);
            fieldEntity.setKey(key);
            fieldEntity.setTargetClass(innerClassEntity);
            result = fieldEntity;
        } else {
            FieldEntity fieldEntity = new FieldEntity();
            fieldEntity.setKey(key);
            fieldEntity.setTargetClass(classEntity);
            result = fieldEntity;
        }
    } else if (type instanceof JSONArray) {
        result = handleJSONArray(parentClass, (JSONArray) type, key, 1);
    } else {
        FieldEntity fieldEntity = new FieldEntity();
        fieldEntity.setKey(key);
        fieldEntity.setType(DataType.typeOfObject(type).getValue());
        result = fieldEntity;
        if (type != null) {
            result.setValue(type.toString());
        }
    }
    result.setKey(key);
    return result;
}
Also used : ClassEntity(org.gsonformat.intellij.entity.ClassEntity) JSONObject(org.json.JSONObject) FieldEntity(org.gsonformat.intellij.entity.FieldEntity) IterableFieldEntity(org.gsonformat.intellij.entity.IterableFieldEntity) JSONArray(org.json.JSONArray)

Example 13 with ClassEntity

use of org.gsonformat.intellij.entity.ClassEntity in project GsonFormat by zzz40500.

the class ConvertBridge method handleClassReferenceType.

private void handleClassReferenceType(FieldEntity fieldEntity, PsiClass psi) {
    if (psi == null || psi.getQualifiedName() == null) {
        return;
    }
    switch(psi.getQualifiedName()) {
        case "java.lang.String":
            fieldEntity.setType("String");
            break;
        case "java.lang.Boolean":
            fieldEntity.setType("Boolean");
            break;
        case "java.lang.Integer":
            fieldEntity.setType("Integer");
            break;
        case "java.lang.Double":
            fieldEntity.setType("Double");
            break;
        case "java.lang.Long":
            fieldEntity.setType("Long");
            break;
        default:
            ClassEntity classEntity = declareClass.get(psi.getQualifiedName());
            if (classEntity == null) {
                classEntity = collectClassAttribute(psi, true);
            }
            fieldEntity.setTargetClass(classEntity);
            break;
    }
}
Also used : ClassEntity(org.gsonformat.intellij.entity.ClassEntity)

Aggregations

ClassEntity (org.gsonformat.intellij.entity.ClassEntity)13 FieldEntity (org.gsonformat.intellij.entity.FieldEntity)9 IterableFieldEntity (org.gsonformat.intellij.entity.IterableFieldEntity)5 JSONObject (org.json.JSONObject)4 DefaultMutableTreeTableNode (org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode)2 JSONArray (org.json.JSONArray)2 PsiClass (com.intellij.psi.PsiClass)1 PsiElementFactory (com.intellij.psi.PsiElementFactory)1 BorderLayout (java.awt.BorderLayout)1 JTree (javax.swing.JTree)1 TreePath (javax.swing.tree.TreePath)1 ClassProcessor (org.gsonformat.intellij.process.ClassProcessor)1 IProcessor (org.gsonformat.intellij.process.IProcessor)1