本文整理汇总了Java中org.intellij.lang.annotations.Language类的典型用法代码示例。如果您正苦于以下问题:Java Language类的具体用法?Java Language怎么用?Java Language使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Language类属于org.intellij.lang.annotations包,在下文中一共展示了Language类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testNoArgConstructor
import org.intellij.lang.annotations.Language; //导入依赖的package包/类
public void testNoArgConstructor() throws Exception {
@Language("JAVA") final String SOURCE = ""
+ "package test.pkg;\n"
+ "public class NoArgConstructorTestObject {\n"
+ " public NoArgConstructorTestObject() {\n"
+ " System.out.println(\"This is a no argument constructor\");\n"
+ " }\n"
+ "}";
lint()
.files(java(SOURCE))
.allowMissingSdk(true)
.run()
.expect("No warnings.")
.expectFixDiffs("");
}
开发者ID:siruozhao,项目名称:android-custom-lint,代码行数:17,代码来源:JavaConstructorDetectorTest.java
示例2: testUnusedCall
import org.intellij.lang.annotations.Language; //导入依赖的package包/类
public void testUnusedCall() throws Exception {
@Language("JAVA")
final String source = "package com.example;\n" +
"\n" +
"public class TestClient {\n" +
" public void callFoo(ApiInterface apiInterface) {\n" +
" apiInterface.foo();\n" +
" }\n" +
"}\n";
final String expected = "src/com/example/TestClient.java:5: Error: Call object was created but never used. [UnusedCallObject]\n" +
" apiInterface.foo();\n" +
" ~~~~~~~~~~~~~~~~~~\n" +
"1 errors, 0 warnings\n";
final String result = lintProject(
java("src/retrofit2/Call.java", RETROFIT_CALL_SOURCE),
java("src/retrofit2/http/GET.java", RETROFIT_GET_SOURCE),
java("src/com/example/ApiInterface.java", API_INTERFACE_SOURCE),
java("src/com/example/TestClient.java", source));
assertEquals(expected, result);
}
开发者ID:technoir3,项目名称:retrofit2-lint,代码行数:21,代码来源:UnusedCallObjectDetectorTest.java
示例3: testExecute
import org.intellij.lang.annotations.Language; //导入依赖的package包/类
public void testExecute() throws Exception {
@Language("JAVA")
final String source = "package com.example;\n" +
"\n" +
"public class TestClient {\n" +
" public void callFoo(ApiInterface apiInterface) {\n" +
" apiInterface.foo().execute();\n" +
" }\n" +
"}\n";
final String expected = "No warnings.";
final String result = lintProject(
java("src/retrofit2/Call.java", RETROFIT_CALL_SOURCE),
java("src/retrofit2/http/GET.java", RETROFIT_GET_SOURCE),
java("src/com/example/ApiInterface.java", API_INTERFACE_SOURCE),
java("src/com/example/TestClient.java", source));
assertEquals(expected, result);
}
开发者ID:technoir3,项目名称:retrofit2-lint,代码行数:18,代码来源:UnusedCallObjectDetectorTest.java
示例4: testAssignToVariable
import org.intellij.lang.annotations.Language; //导入依赖的package包/类
public void testAssignToVariable() throws Exception {
@Language("JAVA")
final String source = "package com.example;\n" +
"\n" +
"import retrofit2.Call;\n" +
"\n" +
"public class TestClient {\n" +
" public void callFoo(ApiInterface apiInterface) {\n" +
" Call<Void> call = apiInterface.foo();\n" +
" }\n" +
"}\n";
final String expected = "No warnings.";
final String result = lintProject(
java("src/retrofit2/Call.java", RETROFIT_CALL_SOURCE),
java("src/retrofit2/http/GET.java", RETROFIT_GET_SOURCE),
java("src/com/example/ApiInterface.java", API_INTERFACE_SOURCE),
java("src/com/example/TestClient.java", source));
assertEquals(expected, result);
}
开发者ID:technoir3,项目名称:retrofit2-lint,代码行数:20,代码来源:UnusedCallObjectDetectorTest.java
示例5: testReturn
import org.intellij.lang.annotations.Language; //导入依赖的package包/类
public void testReturn() throws Exception {
@Language("JAVA")
final String source = "package com.example;\n" +
"\n" +
"import retrofit2.Call;\n" +
"\n" +
"public class TestClient {\n" +
" public Call<Void> callFoo(ApiInterface apiInterface) {\n" +
" return apiInterface.foo();\n" +
" }\n" +
"}\n";
final String expected = "No warnings.";
final String result = lintProject(
java("src/retrofit2/Call.java", RETROFIT_CALL_SOURCE),
java("src/retrofit2/http/GET.java", RETROFIT_GET_SOURCE),
java("src/com/example/ApiInterface.java", API_INTERFACE_SOURCE),
java("src/com/example/TestClient.java", source));
assertEquals(expected, result);
}
开发者ID:technoir3,项目名称:retrofit2-lint,代码行数:20,代码来源:UnusedCallObjectDetectorTest.java
示例6: testPassParameter
import org.intellij.lang.annotations.Language; //导入依赖的package包/类
public void testPassParameter() throws Exception {
@Language("JAVA")
final String source = "package com.example;\n" +
"\n" +
"import retrofit2.Call;\n" +
"\n" +
"public class TestClient {\n" +
" public void callFoo(ApiInterface apiInterface) {\n" +
" bar(apiInterface.foo());\n" +
" }\n" +
" \n" +
" private void bar(Call<Void> call) {\n" +
" }\n" +
"}\n";
final String expected = "No warnings.";
final String result = lintProject(
java("src/retrofit2/Call.java", RETROFIT_CALL_SOURCE),
java("src/retrofit2/http/GET.java", RETROFIT_GET_SOURCE),
java("src/com/example/ApiInterface.java", API_INTERFACE_SOURCE),
java("src/com/example/TestClient.java", source));
assertEquals(expected, result);
}
开发者ID:technoir3,项目名称:retrofit2-lint,代码行数:23,代码来源:UnusedCallObjectDetectorTest.java
示例7: createAmbiguousMethodHtmlTooltipMethodRow
import org.intellij.lang.annotations.Language; //导入依赖的package包/类
@Language("HTML")
private static String createAmbiguousMethodHtmlTooltipMethodRow(final MethodCandidateInfo methodCandidate) {
PsiMethod method = methodCandidate.getElement();
PsiParameter[] parameters = method.getParameterList().getParameters();
PsiSubstitutor substitutor = methodCandidate.getSubstitutor();
@NonNls @Language("HTML") String ms = "<td><b>" + method.getName() + "</b></td>";
for (int j = 0; j < parameters.length; j++) {
PsiParameter parameter = parameters[j];
PsiType type = substitutor.substitute(parameter.getType());
ms += "<td><b>" + (j == 0 ? "(" : "") +
XmlStringUtil.escapeString(type.getPresentableText())
+ (j == parameters.length - 1 ? ")" : ",") + "</b></td>";
}
if (parameters.length == 0) {
ms += "<td><b>()</b></td>";
}
return ms;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:HighlightMethodUtil.java
示例8: createShortMismatchedArgumentsHtmlTooltip
import org.intellij.lang.annotations.Language; //导入依赖的package包/类
private static String createShortMismatchedArgumentsHtmlTooltip(PsiExpressionList list,
PsiParameter[] parameters,
String methodName,
PsiSubstitutor substitutor,
PsiClass aClass) {
PsiExpression[] expressions = list.getExpressions();
int cols = Math.max(parameters.length, expressions.length);
@Language("HTML")
@NonNls String parensizedName = methodName + (parameters.length == 0 ? "( ) " : "");
final String errorMessage = InferenceSession.getInferenceErrorMessage(list.getParent());
return JavaErrorMessages.message(
"argument.mismatch.html.tooltip",
Integer.valueOf(cols - parameters.length + 1), parensizedName,
HighlightUtil.formatClass(aClass, false),
createMismatchedArgsHtmlTooltipParamsRow(parameters, substitutor, expressions),
createMismatchedArgsHtmlTooltipArgumentsRow(expressions, parameters, substitutor, cols),
errorMessage != null ? "<br/>reason: " + XmlStringUtil.escapeString(errorMessage).replaceAll("\n", "<br/>") : ""
);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:HighlightMethodUtil.java
示例9: createMismatchedArgsHtmlTooltipArgumentsRow
import org.intellij.lang.annotations.Language; //导入依赖的package包/类
@SuppressWarnings("StringContatenationInLoop")
@Language("HTML")
private static String createMismatchedArgsHtmlTooltipArgumentsRow(final PsiExpression[] expressions, final PsiParameter[] parameters,
final PsiSubstitutor substitutor, final int cols) {
@Language("HTML")
@NonNls String ms = "";
for (int i = 0; i < expressions.length; i++) {
PsiExpression expression = expressions[i];
PsiType type = expression.getType();
boolean showShort = showShortType(i, parameters, expressions, substitutor);
@NonNls String mismatchColor = showShort ? null : MISMATCH_COLOR;
ms += "<td> " + "<b><nobr>" + (i == 0 ? "(" : "")
+ "<font " + (showShort ? "" : "color=" + mismatchColor) + ">" +
XmlStringUtil.escapeString(showShort ? type.getPresentableText() : JavaHighlightUtil.formatType(type))
+ "</font>"
+ (i == expressions.length - 1 ? ")" : ",") + "</nobr></b></td>";
}
for (int i = expressions.length; i < cols + 1; i++) {
ms += "<td>" + (i == 0 ? "<b>()</b>" : "") +
" </td>";
}
return ms;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:HighlightMethodUtil.java
示例10: createMismatchedArgsHtmlTooltipParamsRow
import org.intellij.lang.annotations.Language; //导入依赖的package包/类
@SuppressWarnings("StringContatenationInLoop")
@Language("HTML")
private static String createMismatchedArgsHtmlTooltipParamsRow(final PsiParameter[] parameters,
final PsiSubstitutor substitutor,
final PsiExpression[] expressions) {
@NonNls String ms = "";
for (int i = 0; i < parameters.length; i++) {
PsiParameter parameter = parameters[i];
PsiType type = substitutor.substitute(parameter.getType());
ms += "<td><b><nobr>" + (i == 0 ? "(" : "") +
XmlStringUtil.escapeString(showShortType(i, parameters, expressions, substitutor)
? type.getPresentableText()
: JavaHighlightUtil.formatType(type))
+ (i == parameters.length - 1 ? ")" : ",") + "</nobr></b></td>";
}
return ms;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:HighlightMethodUtil.java
示例11: getCssFontDeclaration
import org.intellij.lang.annotations.Language; //导入依赖的package包/类
@Language("HTML")
public static String getCssFontDeclaration(@NotNull Font font, @Nullable Color fgColor, @Nullable Color linkColor, @Nullable String liImg) {
StringBuilder builder = new StringBuilder().append("<style>\n");
String familyAndSize = "font-family:'" + font.getFamily() + "'; font-size:" + font.getSize() + "pt;";
builder.append("body, div, td, p {").append(familyAndSize);
if (fgColor != null) builder.append(" color:#").append(ColorUtil.toHex(fgColor)).append(';');
builder.append("}\n");
builder.append("a {").append(familyAndSize);
if (linkColor != null) builder.append(" color:#").append(ColorUtil.toHex(linkColor)).append(';');
builder.append("}\n");
builder.append("code {font-size:").append(font.getSize()).append("pt;}\n");
URL resource = liImg != null ? SystemInfo.class.getResource(liImg) : null;
if (resource != null) {
builder.append("ul {list-style-image:url('").append(StringUtil.escapeCharCharacters(resource.toExternalForm())).append("');}\n");
}
return builder.append("</style>").toString();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:UIUtil.java
示例12: doCheck
import org.intellij.lang.annotations.Language; //导入依赖的package包/类
protected final void doCheck(@Language("JAVA") @NotNull @NonNls String classText) {
@NonNls final StringBuilder newText = new StringBuilder();
int start = 0;
int end = classText.indexOf("/*");
while (end >= 0) {
newText.append(classText, start, end);
start = end + 2;
end = classText.indexOf("*/", end);
if (end < 0) {
throw new IllegalArgumentException("invalid class text");
}
final String warning = classText.substring(start, end);
if (warning.isEmpty()) {
newText.append("</error>");
}
else {
newText.append("<error descr=\"").append(warning).append("\">");
}
start = end + 2;
end = classText.indexOf("/*", end + 1);
}
newText.append(classText, start, classText.length());
// Now delegate to the real test implementation (it won't find comments to replace with <warning>)
super.doTest(newText.toString());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:ResourceTypeInspectionTest.java
示例13: testColorInt
import org.intellij.lang.annotations.Language; //导入依赖的package包/类
public void testColorInt() {
@Language("JAVA")
String text = "package p1.p2;\n" +
"\n" +
"public class Foo {\n" +
" @android.support.annotation.ColorInt int mColor;\n" +
" \n" +
" public void setColor(@android.support.annotation.ColorInt int c) {\n" +
" mColor = <caret>c;\n" +
" }\n" +
"}\n";
PsiElement element = getPsiElement(text);
assertNotNull(element);
PsiAnnotation annotation = AndroidResolveHelper.getAnnotationForLocal(element, "c");
assertNotNull(annotation);
assertEquals(SupportAnnotationDetector.COLOR_INT_ANNOTATION, annotation.getQualifiedName());
annotation = AndroidResolveHelper.getAnnotationForField(element, "p1.p2.Foo", "mColor");
assertNotNull(annotation);
assertEquals(SupportAnnotationDetector.COLOR_INT_ANNOTATION, annotation.getQualifiedName());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:AndroidResolveHelperTest.java
示例14: testAnnotationInferenceFromMethod
import org.intellij.lang.annotations.Language; //导入依赖的package包/类
public void testAnnotationInferenceFromMethod() {
@Language("JAVA")
String text = "package p1.p2;\n" +
"\n" +
"class Foo {\n" +
" @android.support.annotation.ColorInt int getColor() {\n" +
" return 0x11223344;\n" +
" }\n" +
"\n" +
" private void check() {\n" +
" int color;\n" +
" <caret>color = getColor();\n" +
" }\n" +
"}";
testResolution(text);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AndroidResolveHelperTest.java
示例15: testAnnotationInferenceFromInitializerCall
import org.intellij.lang.annotations.Language; //导入依赖的package包/类
public void testAnnotationInferenceFromInitializerCall() {
@Language("JAVA")
String text = "package p1.p2;\n" +
"\n" +
"class Foo {\n" +
" @android.support.annotation.ColorInt int getColor() {\n" +
" return 0x11223344;\n" +
" }\n" +
"\n" +
" private void check() {\n" +
" int color = getColor();\n" +
" int x = <caret>color;\n" +
" }\n" +
"}";
testResolution(text);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AndroidResolveHelperTest.java
示例16: createIssueViaRestApi
import org.intellij.lang.annotations.Language; //导入依赖的package包/类
private String createIssueViaRestApi(@NotNull String project, @NotNull String summary) throws Exception {
final HttpClient client = myRepository.getHttpClient();
final PostMethod method = new PostMethod(myRepository.getUrl() + "/rest/api/latest/issue");
try {
// For simplicity assume that project, summary and username don't contain illegal characters
@Language("JSON")
final String json = "{\"fields\": {\n" +
" \"project\": {\n" +
" \"key\": \"" + project + "\"\n" +
" },\n" +
" \"issuetype\": {\n" +
" \"name\": \"Bug\"\n" +
" },\n" +
" \"assignee\": {\n" +
" \"name\": \"" + myRepository.getUsername() + "\"\n" +
" },\n" +
" \"summary\": \"" + summary + "\"\n" +
"}}";
method.setRequestEntity(new StringRequestEntity(json, "application/json", "utf-8"));
client.executeMethod(method);
return new Gson().fromJson(method.getResponseBodyAsString(), JsonObject.class).get("id").getAsString();
}
finally {
method.releaseConnection();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:JiraIntegrationTest.java
示例17: noNeedsPermissionAnnotationNoErrors
import org.intellij.lang.annotations.Language; //导入依赖的package包/类
@Test
public void noNeedsPermissionAnnotationNoErrors() throws Exception {
@Language("JAVA") String onNeeds = getOnNeedsPermission();
@Language("JAVA") String onShow = getOnRationaleAnnotation();
@Language("JAVA") String foo = ""
+ PACKAGE
+ "public class Foo {\n"
+ "@NeedsPermission(\"Camera\")\n"
+ "public void showCamera() {\n"
+ "}\n"
+ "@OnShowRationale(\"Camera\")\n"
+ "public void someMethod() {\n"
+ "}\n"
+ "}";
lint()
.files(
java(SOURCE_PATH + "NeedsPermission.java", onNeeds),
java(SOURCE_PATH + "OnShowRationale.java", onShow),
java(SOURCE_PATH + "Foo.java", foo))
.issues(NoCorrespondingNeedsPermissionDetector.ISSUE)
.run()
.expectClean();
}
开发者ID:permissions-dispatcher,项目名称:PermissionsDispatcher,代码行数:27,代码来源:NoCorrespondingNeedsPermissionDetectorTest.java
示例18: testStartCalledInApplicationOutsideOnCreate
import org.intellij.lang.annotations.Language; //导入依赖的package包/类
@Test
public void testStartCalledInApplicationOutsideOnCreate() throws Exception {
@Language("JAVA") String source =
"package com.mparticle.lints;\n" +
"import android.util.Log;\n" +
"import com.mparticle.MParticle;\n" +
"import android.app.Application;\n" +
"public class HasProperCall extends Application {\n" +
" public void onResume() {\n" +
" super.start();\n" +
" MParticle.start();\n" +
" }\n" +
"}";
assertThat(lintProject(java(source), mParticleStub, mApplicationStub))
.contains(MpApiDetector.MESSAGE_START_CALLED_IN_WRONG_PLACE)
.contains(MpApiDetector.MESSAGE_NO_START_CALL_AT_ALL)
.contains(Constants.getErrorWarningMessageString(0,2));
}
开发者ID:mParticle,项目名称:mparticle-android-sdk,代码行数:19,代码来源:MpApiDetectorTest.java
示例19: select
import org.intellij.lang.annotations.Language; //导入依赖的package包/类
private List<List<Object>> select(@Language("SQL") String sql)
throws SQLException
{
return dbi.withHandle(handle -> handle.createQuery(sql)
.map((index, rs, context) -> {
int count = rs.getMetaData().getColumnCount();
List<Object> row = new ArrayList<>(count);
for (int i = 1; i <= count; i++) {
Object value = rs.getObject(i);
if (value instanceof byte[]) {
value = uuidFromBytes((byte[]) value);
}
row.add(value);
}
return row;
})
.list());
}
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:TestShardCleaner.java
示例20: assertUpdate
import org.intellij.lang.annotations.Language; //导入依赖的package包/类
public static void assertUpdate(QueryRunner queryRunner, Session session, @Language("SQL") String sql, OptionalLong count)
{
long start = System.nanoTime();
MaterializedResult results = queryRunner.execute(session, sql);
log.info("FINISHED in presto: %s", nanosSince(start));
if (!results.getUpdateType().isPresent()) {
fail("update type is not set");
}
if (results.getUpdateCount().isPresent()) {
if (!count.isPresent()) {
fail("update count should not be present");
}
assertEquals(results.getUpdateCount().isPresent(), count.isPresent(), "update count");
}
else if (count.isPresent()) {
fail("update count is not present");
}
}
开发者ID:y-lan,项目名称:presto,代码行数:21,代码来源:QueryAssertions.java
注:本文中的org.intellij.lang.annotations.Language类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论