Skip to content

Commit

Permalink
feat: ExplicitElement containClass&defineClass (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
tangcent committed Sep 12, 2021
1 parent 4a81299 commit 4c55d4e
Show file tree
Hide file tree
Showing 15 changed files with 6,219 additions and 28 deletions.
Expand Up @@ -28,7 +28,6 @@ import com.itangcent.intellij.jvm.dev.DevEnv
import com.itangcent.intellij.logger.Logger
import com.itangcent.intellij.psi.DefaultPsiClassHelper
import com.itangcent.mock.PrintLogger
import org.junit.jupiter.api.condition.OS
import org.mockito.Mockito
import java.io.File
import java.net.URL
Expand Down Expand Up @@ -146,6 +145,9 @@ abstract class ContextLightCodeInsightFixtureTestCase : LightCodeInsightFixtureT
return myFixture.configureFromTempProjectFile(file)
}

/**
* load source of the class to current project
*/
protected fun loadSource(cls: KClass<*>): PsiClass? {
return loadSource(cls.java)
}
Expand Down Expand Up @@ -191,7 +193,11 @@ abstract class ContextLightCodeInsightFixtureTestCase : LightCodeInsightFixtureT
return readSourceFile(location, cls)
}

val path = cls.name.replace('.', '/') + ".java"
val qualifiedName = cls.name
if (!qualifiedName.contains('.')) {
LOG.warn("Load [$qualifiedName] may be not meet expectation")
}
val path = qualifiedName.replace('.', '/') + ".java"

//try load from resource/jdk
ResourceUtils.readResource("jdk/${cls.simpleName}.fava")
Expand Down Expand Up @@ -283,4 +289,7 @@ abstract class ContextLightCodeInsightFixtureTestCase : LightCodeInsightFixtureT

protected open val JDK
get() = "https://raw.githubusercontent.com/openjdk/jdk/jdk8-b120/jdk"
}
}

//background idea log
private val LOG = org.apache.log4j.Logger.getLogger(ContextLightCodeInsightFixtureTestCase::class.java)

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions intellij-idea/src/test/resources/api/GenericCtrl.java
@@ -0,0 +1,23 @@
package com.itangcent.api;

import com.itangcent.common.annotation.Public;
import com.itangcent.model.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* generic apis
*/
@RestController
@RequestMapping(value = "generic")
public class GenericCtrl<T> {

/**
* result
*/
@Public
@RequestMapping(value = "/result")
public Result<T> result(T t) {
return Result.success(t);
}
}
26 changes: 26 additions & 0 deletions intellij-idea/src/test/resources/api/UserDetailCtrl.java
@@ -0,0 +1,26 @@
package com.itangcent.api;

import com.itangcent.api.GenericCtrl;
import com.itangcent.common.annotation.Public;
import com.itangcent.model.UserInfoDetail;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* generic apis
*/
@RestController
@RequestMapping(value = "/user/detail")
public class UserDetailCtrl extends GenericCtrl<UserInfoDetail> {

/**
* say hello
* not update anything
*/
@Public
@RequestMapping(value = "/greeting")
public String greeting() {
return "hello world";
}

}

0 comments on commit 4c55d4e

Please sign in to comment.