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


Java Severity.WARNING属性代码示例

本文整理汇总了Java中com.android.tools.lint.detector.api.Severity.WARNING属性的典型用法代码示例。如果您正苦于以下问题:Java Severity.WARNING属性的具体用法?Java Severity.WARNING怎么用?Java Severity.WARNING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.android.tools.lint.detector.api.Severity的用法示例。


在下文中一共展示了Severity.WARNING属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSeverity

@NonNull
@Override
public Severity getSeverity(@NonNull Issue issue) {
    Severity severity = computeSeverity(issue);

    if (mFatalOnly && severity != Severity.FATAL) {
        return Severity.IGNORE;
    }

    if (mFlags.isWarningsAsErrors() && severity == Severity.WARNING) {
        severity = Severity.ERROR;
    }

    if (mFlags.isIgnoreWarnings() && severity == Severity.WARNING) {
        severity = Severity.IGNORE;
    }

    return severity;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:LintCliClient.java

示例2: getDefaultSeverity

@Override
@NonNull
protected Severity getDefaultSeverity(@NonNull Issue issue) {
    // In unit tests, include issues that are ignored by default
    Severity severity = super.getDefaultSeverity(issue);
    if (severity == Severity.IGNORE) {
        if (issue.getDefaultSeverity() != Severity.IGNORE) {
            return issue.getDefaultSeverity();
        }
        return Severity.WARNING;
    }
    return severity;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:LintDetectorTest.java

示例3: computeSeverity

private Severity computeSeverity(@NonNull Issue issue) {
    Severity severity = super.getSeverity(issue);

    String id = issue.getId();
    Set<String> suppress = mFlags.getSuppressedIds();
    if (suppress.contains(id)) {
        return Severity.IGNORE;
    }

    Severity manual = mFlags.getSeverityOverrides().get(id);
    if (manual != null) {
        return manual;
    }

    Set<String> enabled = mFlags.getEnabledIds();
    Set<String> check = mFlags.getExactCheckedIds();
    if (enabled.contains(id) || (check != null && check.contains(id))) {
        // Overriding default
        // Detectors shouldn't be returning ignore as a default severity,
        // but in case they do, force it up to warning here to ensure that
        // it's run
        if (severity == Severity.IGNORE) {
            severity = issue.getDefaultSeverity();
            if (severity == Severity.IGNORE) {
                severity = Severity.WARNING;
            }
        }

        return severity;
    }

    if (check != null && issue != LINT_ERROR && issue != PARSER_ERROR) {
        return Severity.IGNORE;
    }

    return severity;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:LintCliClient.java

示例4: testNonPrintableChars

public void testNonPrintableChars() throws Exception {
    // See https://code.google.com/p/android/issues/detail?id=56205
    File file = new File(getTargetDir(), "report");
    try {
        LintCliClient client = new LintCliClient() {
            @Override
            String getRevision() {
                return "unittest"; // Hardcode version to keep unit test output stable
            }
        };
        //noinspection ResultOfMethodCallIgnored
        file.getParentFile().mkdirs();
        XmlReporter reporter = new XmlReporter(client, file);
        Project project = Project.create(client, new File("/foo/bar/Foo"),
                new File("/foo/bar/Foo"));

        Warning warning1 = new Warning(TypographyDetector.FRACTIONS,
                String.format("Use fraction character %1$c (%2$s) instead of %3$s ?",
                        '\u00BC', "&#188;", "1/4"), Severity.WARNING, project);
        warning1.line = 592;
        warning1.file = new File("/foo/bar/Foo/AndroidManifest.xml");
        warning1.errorLine =
                "        <string name=\"user_registration_name3_3\">Register 3/3</string>\n" +
                "                                             ^";
        warning1.path = "res/values-en/common_strings.xml";
        warning1.location = Location.create(warning1.file,
                new DefaultPosition(592, 46, -1), null);

        List<Warning> warnings = new ArrayList<Warning>();
        warnings.add(warning1);

        reporter.write(0, 2, warnings);

        String report = Files.toString(file, Charsets.UTF_8);
        assertEquals(""
                + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                + "<issues format=\"4\" by=\"lint unittest\">\n"
                + "\n"
                + "    <issue\n"
                + "        id=\"TypographyFractions\"\n"
                + "        severity=\"Warning\"\n"
                + "        message=\"Use fraction character ¼ (&amp;#188;) instead of 1/4 ?\"\n"
                + "        category=\"Usability:Typography\"\n"
                + "        priority=\"5\"\n"
                + "        summary=\"Fraction string can be replaced with fraction character\"\n"
                + "        explanation=\"You can replace certain strings, such as 1/2, and 1/4, with dedicated characters for these, such as ½ (&amp;#189;) and ¼ (&amp;#188;). This can help make the text more readable.\"\n"
                + "        url=\"http://en.wikipedia.org/wiki/Number_Forms\"\n"
                + "        urls=\"http://en.wikipedia.org/wiki/Number_Forms\">\n"
                + "        <location\n"
                + "            file=\"AndroidManifest.xml\"\n"
                + "            line=\"593\"\n"
                + "            column=\"47\"/>\n"
                + "    </issue>\n"
                + "\n"
                + "</issues>\n",
                report);

        // Make sure the XML is valid
        Document document = PositionXmlParser.parse(report);
        assertNotNull(document);
        assertEquals(1, document.getElementsByTagName("issue").getLength());
        String explanation =  ((Element)document.getElementsByTagName("issue").item(0)).
                getAttribute("explanation");
        assertEquals(TypographyDetector.FRACTIONS.getExplanation(TextFormat.RAW),
                explanation);
    } finally {
        //noinspection ResultOfMethodCallIgnored
        file.delete();
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:70,代码来源:XmlReporterTest.java

示例5: test

public void test() throws Exception {
    File file = new File(getTargetDir(), "report");
    try {
        LintCliClient client = new LintCliClient() {
            @Override
            String getRevision() {
                return "unittest"; // Hardcode version to keep unit test output stable
            }
        };
        //noinspection ResultOfMethodCallIgnored
        file.getParentFile().mkdirs();
        FileWriter writer = new FileWriter(file);
        TextReporter reporter = new TextReporter(client, client.mFlags, file, writer, true);
        Project project = Project.create(client, new File("/foo/bar/Foo"),
                new File("/foo/bar/Foo"));
        client.mFlags.setShowEverything(true);

        Warning warning1 = new Warning(ManifestDetector.USES_SDK,
                "<uses-sdk> tag should specify a target API level (the highest verified " +
                        "version; when running on later versions, compatibility behaviors may " +
                        "be enabled) with android:targetSdkVersion=\"?\"",
                Severity.WARNING, project);
        warning1.line = 6;
        warning1.file = new File("/foo/bar/Foo/AndroidManifest.xml");
        warning1.errorLine = "    <uses-sdk android:minSdkVersion=\"8\" />\n    ^\n";
        warning1.path = "AndroidManifest.xml";
        warning1.location = Location.create(warning1.file,
                new DefaultPosition(6, 4, 198), new DefaultPosition(6, 42, 236));
        Location secondary = Location.create(warning1.file,
                new DefaultPosition(7, 4, 198), new DefaultPosition(7, 42, 236));
        secondary.setMessage("Secondary location");
        warning1.location.setSecondary(secondary);

        Warning warning2 = new Warning(HardcodedValuesDetector.ISSUE,
                "[I18N] Hardcoded string \"Fooo\", should use @string resource",
                Severity.WARNING, project);
        warning2.line = 11;
        warning2.file = new File("/foo/bar/Foo/res/layout/main.xml");
        warning2.errorLine = "        android:text=\"Fooo\" />\n" +
                "        ~~~~~~~~~~~~~~~~~~~\n";
        warning2.path = "res/layout/main.xml";
        warning2.location = Location.create(warning2.file,
                new DefaultPosition(11, 8, 377), new DefaultPosition(11, 27, 396));
        secondary = Location.create(warning1.file,
                new DefaultPosition(7, 4, 198), new DefaultPosition(7, 42, 236));
        secondary.setMessage("Secondary location");
        warning2.location.setSecondary(secondary);
        Location tertiary = Location.create(warning2.file,
                new DefaultPosition(5, 4, 198), new DefaultPosition(5, 42, 236));
        secondary.setSecondary(tertiary);

        List<Warning> warnings = new ArrayList<Warning>();
        warnings.add(warning1);
        warnings.add(warning2);
        Collections.sort(warnings);

        reporter.write(0, 2, warnings);

        String report = Files.toString(file, Charsets.UTF_8);
        assertEquals(""
                + "AndroidManifest.xml:7: Warning: <uses-sdk> tag should specify a target API level (the highest verified version; when running on later versions, compatibility behaviors may be enabled) with android:targetSdkVersion=\"?\" [UsesMinSdkAttributes]\n"
                + "    <uses-sdk android:minSdkVersion=\"8\" />\n"
                + "    ^\n"
                + "    AndroidManifest.xml:8: Secondary location\n"
                + "res/layout/main.xml:12: Warning: [I18N] Hardcoded string \"Fooo\", should use @string resource [HardcodedText]\n"
                + "        android:text=\"Fooo\" />\n"
                + "        ~~~~~~~~~~~~~~~~~~~\n"
                + "    AndroidManifest.xml:8: Secondary location\n"
                + "Also affects: res/layout/main.xml:6\n"
                + "0 errors, 2 warnings\n",
                report);
    } finally {
        //noinspection ResultOfMethodCallIgnored
        file.delete();
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:76,代码来源:TextReporterTest.java


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