当前位置: 首页>>代码示例>>Java>>正文


Java Language类代码示例

本文整理汇总了Java中org.intellij.lang.annotations.Language的典型用法代码示例。如果您正苦于以下问题:Java Language类的具体用法?Java Language怎么用?Java Language使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Language类属于org.intellij.lang.annotations包,在下文中一共展示了Language类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 ? "(&nbsp;)&nbsp;" : "");
  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>" : "") +
          "&nbsp;</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


注:本文中的org.intellij.lang.annotations.Language类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。