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


Java Context.report方法代码示例

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


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

示例1: afterCheckProject

import com.android.tools.lint.detector.api.Context; //导入方法依赖的package包/类
@Override
public void afterCheckProject(@NonNull Context context) {

    // if it's not a library, it's an application
    if (context.getProject() == context.getMainProject() && !context.getMainProject().isLibrary() && mApplicationTagLocation != null) {

        if (!mHasActivity) {
            context.report(ISSUE_MISSING_LAUNCHER, mApplicationTagLocation,
                    "Expecting " + ANDROID_MANIFEST_XML + " to have an <" + TAG_ACTIVITY + "> tag.");
        } else if (!mHasLauncherActivity) {
            context.report(ISSUE_MISSING_LAUNCHER, mApplicationTagLocation,
                    "Expecting " + ANDROID_MANIFEST_XML + " to have an activity with a launcher intent.");
        }

    }
}
 
开发者ID:inaka,项目名称:lewis,代码行数:17,代码来源:LauncherActivityDetector.java

示例2: report

import com.android.tools.lint.detector.api.Context; //导入方法依赖的package包/类
private void report(@NonNull Context context, @NonNull Object cookie, @NonNull Issue issue,
        @NonNull String message) {
    if (context.isEnabled(issue)) {
        // Suppressed?
        // Temporarily unconditionally checking for suppress comments in Gradle files
        // since Studio insists on an AndroidLint id prefix
        boolean checkComments = /*context.getClient().checkForSuppressComments()
                &&*/ context.containsCommentSuppress();
        if (checkComments) {
            int startOffset = getStartOffset(context, cookie);
            if (startOffset >= 0 && context.isSuppressedWithComment(startOffset, issue)) {
                return;
            }
        }

        context.report(issue, createLocation(context, cookie), message);
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:GradleDetector.java

示例3: beforeCheckFile

import com.android.tools.lint.detector.api.Context; //导入方法依赖的package包/类
@Override
public void beforeCheckFile(@NonNull Context context) {
    if (mPrefix != null && context instanceof XmlContext) {
        XmlContext xmlContext = (XmlContext) context;
        ResourceFolderType folderType = xmlContext.getResourceFolderType();
        if (folderType != null && folderType != ResourceFolderType.VALUES) {
            String name = LintUtils.getBaseName(context.file.getName());
            if (!name.startsWith(mPrefix)) {
                // Attempt to report the error on the root tag of the associated
                // document to make suppressing the error with a tools:suppress
                // attribute etc possible
                if (xmlContext.document != null) {
                    Element root = xmlContext.document.getDocumentElement();
                    if (root != null) {
                        xmlContext.report(ISSUE, root, xmlContext.getLocation(root),
                                getErrorMessage(name));
                        return;
                    }
                }
                context.report(ISSUE, Location.create(context.file),
                        getErrorMessage(name));
            }
        }
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:ResourcePrefixDetector.java

示例4: afterCheckProject

import com.android.tools.lint.detector.api.Context; //导入方法依赖的package包/类
@Override
public void afterCheckProject(@NonNull Context context) {
    if (mPending != null && mWhitelistedLayouts != null) {
        // Process all the root FrameLayouts that are eligible, and generate
        // suggestions for <merge> replacements for any layouts that are included
        // from other layouts
        for (Pair<String, Handle> pair : mPending) {
            String layout = pair.getFirst();
            if (mWhitelistedLayouts.contains(layout)) {
                Handle handle = pair.getSecond();

                Object clientData = handle.getClientData();
                if (clientData instanceof Node) {
                    if (context.getDriver().isSuppressed(null, ISSUE, (Node) clientData)) {
                        return;
                    }
                }

                Location location = handle.resolve();
                context.report(ISSUE, location,
                        "This `<FrameLayout>` can be replaced with a `<merge>` tag");
            }
        }
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:MergeRootFrameLayoutDetector.java

示例5: run

import com.android.tools.lint.detector.api.Context; //导入方法依赖的package包/类
@Override
public void run(@NonNull Context context) {
    if (!context.getProject().getReportIssues()) {
        // If this is a library project not being analyzed, ignore it
        return;
    }

    File file = context.file;
    if (isPrivateKeyFile(file)) {
        String fileName = file.getParentFile().getName() + File.separator
            + file.getName();
        String message = String.format(
            "The `%1$s` file seems to be a private key file. " +
            "Please make sure not to embed this in your APK file.", fileName);
        context.report(ISSUE, Location.create(file), message);
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PrivateKeyDetector.java

示例6: reportMap

import com.android.tools.lint.detector.api.Context; //导入方法依赖的package包/类
private void reportMap(Context context, Issue issue, Map<String, Location> map) {
    if (map != null) {
        for (Map.Entry<String, Location> entry : map.entrySet()) {
            Location location = entry.getValue();
            String name = entry.getKey();
            String message = mDescriptions.get(name);

            if (location == null) {
                location = Location.create(context.getProject().getDir());
            }

            // We were prepending locations, but we want to prefer the base folders
            location = Location.reverse(location);

            context.report(issue, location, message);
        }
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:TranslationDetector.java

示例7: afterCheckClass

import com.android.tools.lint.detector.api.Context; //导入方法依赖的package包/类
public void afterCheckClass(Context context) {

        if (mMethods.size() == 0) return;

        JavaContext javaContext = (JavaContext) context;
        JavaEvaluator evaluator = javaContext.getEvaluator();
        if (evaluator == null) return;

        StringBuilder sb = new StringBuilder();

        boolean methodInDataAdapter = false;
        for (PsiMethod method : mMethods) {
            PsiClass pc = method.getContainingClass();
            boolean isSubclass = evaluator.implementsInterface(pc, CLASS_DATA_ADAPTER, false);

            methodInDataAdapter = methodInDataAdapter || isSubclass;

            if (!isSubclass) {
                sb.append(method.getName())
                        .append(",");
            }
        }

        if (!methodInDataAdapter) {
            context.report(ISSUE_VIEW_GROUP, Location.create(context.file), "the Custom ViewGroup with data bind should extend DataAdapter,method names:" + sb.toString());
        }
    }
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:28,代码来源:AutoPointCustomViewGroupDetector.java

示例8: afterCheckProject

import com.android.tools.lint.detector.api.Context; //导入方法依赖的package包/类
@Override
public void afterCheckProject(Context context) {
    super.afterCheckProject(context);

    File dir = context.getMainProject().getDir();
    File parentDir = dir.getParentFile();
    boolean gradleExists = new File(parentDir, SdkConstants.FN_BUILD_GRADLE).exists();
    if (!gradleExists) {
        return;
    }

    File file = new File(parentDir, "file.properties");
    if (!file.exists()) {
        context.report(ISSUE_NO_FILE, Location.create(context.file),
                "no file in project reference dir '" + parentDir.getAbsolutePath() + "'");
        return;
    }

    try {
        FileInputStream fis = new FileInputStream(file);
        Properties properties = new Properties();
        properties.load(fis);

        Iterator<String> itr = mSet.iterator();
        while (itr.hasNext()) {
            String key = itr.next();

            String value = properties.getProperty(key);
            if (value == null || value.isEmpty()) {
                context.report(ISSUE_UN_REGISTER_VIEW, Location.create(context.file),
                        "unregister view(" + key + ") at project " + context.getProject().getName());
            }

        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:40,代码来源:AutoPointRegisteredCustomViewDetector.java

示例9: visitBuildScript

import com.android.tools.lint.detector.api.Context; //导入方法依赖的package包/类
@Override
public void visitBuildScript(@NonNull Context context, Map<String, Object> sharedData) {
    int lineNum = 0;
    Scanner scanner = new Scanner(context.getContents());
    while (scanner.hasNextLine()) {
        lineNum++;
        String line = scanner.nextLine();
        String lineTrim = line.trim();
        int firstWhileSpaceIndex = lineTrim.indexOf(" ");

        if (firstWhileSpaceIndex != -1) {
            String optionKey = lineTrim.substring(0, firstWhileSpaceIndex);
            if (optionKey.endsWith("Version")) {
                String optionValue = lineTrim.substring(firstWhileSpaceIndex).trim();
                if (optionValue.startsWith("\"") && optionValue.endsWith("\"")) {
                    optionValue = optionValue.substring(1, optionValue.length() - 1);
                }
                char valueFirstChar = optionValue.charAt(0);
                if (valueFirstChar >= '0' && valueFirstChar <= '9') {

                    // Value of lineNum shows correct in Log info while debuging, but incorrect in lint report ( error of 1).
                    // So we decrease it by 1.
                    Location issueLocation = Location.create(context.file, context.getContents(), lineNum-1);

                    context.report(ISSUE,
                            issueLocation,
                            "In build.gradle file, version info should refer to gradle-wrapper.properties. ");

                }


            }
        }

    }
    scanner.close();

}
 
开发者ID:ljfxyj2008,项目名称:CustomLintDemo,代码行数:39,代码来源:BuildGradleVersionDetector.java

示例10: afterCheckProject

import com.android.tools.lint.detector.api.Context; //导入方法依赖的package包/类
@Override
public void afterCheckProject(@NonNull Context context) {

    // if it's a library
    if (context.getProject() == context.getMainProject() && context.getMainProject().isLibrary()) {
        for (int i = 0; i < mIconAttributesLocations.size(); i++) {
            context.report(ISSUE_ICON_IN_LIBRARY, mIconAttributesLocations.get(i),
                    "Expecting " + ANDROID_MANIFEST_XML + " not to have an icon inside <" + TAG_APPLICATION + "> tag");
        }
    }
}
 
开发者ID:inaka,项目名称:lewis,代码行数:12,代码来源:IconInLibraryDetector.java

示例11: afterCheckProject

import com.android.tools.lint.detector.api.Context; //导入方法依赖的package包/类
@Override
public void afterCheckProject(@NonNull Context context) {

    // if it is a library
    if (context.getProject() == context.getMainProject() && context.getMainProject().isLibrary()) {
        for (Location location : mPermissionTagsLocations) {
            context.report(ISSUE_PERMISSION_USAGE_IN_LIBRARY, location,
                    "Expecting " + ANDROID_MANIFEST_XML + " not to have a <" + TAG_USES_PERMISSION + "> tag invocation");
        }
    }
}
 
开发者ID:inaka,项目名称:lewis,代码行数:12,代码来源:PermissionsInLibraryDetector.java

示例12: report

import com.android.tools.lint.detector.api.Context; //导入方法依赖的package包/类
private static void report(Context context, Issue issue, Handle handle, String message) {
    Location location = handle.resolve();
    Object clientData = handle.getClientData();
    if (clientData instanceof Node) {
        if (context.getDriver().isSuppressed(null, issue, (Node) clientData)) {
            return;
        }
    }

    context.report(issue, location, message);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:WrongIdDetector.java

示例13: afterCheckProject

import com.android.tools.lint.detector.api.Context; //导入方法依赖的package包/类
@Override
public void afterCheckProject(@NonNull Context context) {
    if (mRootAttributes != null) {
        for (Pair<Location, String> pair : mRootAttributes) {
            Location location = pair.getFirst();

            Object clientData = location.getClientData();
            if (clientData instanceof Node) {
                if (context.getDriver().isSuppressed(null, ISSUE, (Node) clientData)) {
                    return;
                }
            }

            String layoutName = location.getFile().getName();
            if (endsWith(layoutName, DOT_XML)) {
                layoutName = layoutName.substring(0, layoutName.length() - DOT_XML.length());
            }

            String theme = getTheme(context, layoutName);
            if (theme == null || !isBlankTheme(theme)) {
                String drawable = pair.getSecond();
                String message = String.format(
                        "Possible overdraw: Root element paints background `%1$s` with " +
                        "a theme that also paints a background (inferred theme is `%2$s`)",
                        drawable, theme);
                // TODO: Compute applicable scope node
                context.report(ISSUE, location, message);
            }
        }
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:OverdrawDetector.java

示例14: beforeCheckProject

import com.android.tools.lint.detector.api.Context; //导入方法依赖的package包/类
@Override
public void beforeCheckProject(@NonNull Context context) {
    mApiDatabase = ApiLookup.get(context.getClient());
    // We can't look up the minimum API required by the project here:
    // The manifest file hasn't been processed yet in the -before- project hook.
    // For now it's initialized lazily in getMinSdk(Context), but the
    // lint infrastructure should be fixed to parse manifest file up front.

    if (mApiDatabase == null && !mWarnedMissingDb) {
        mWarnedMissingDb = true;
        context.report(IssueRegistry.LINT_ERROR, Location.create(context.file),
                    "Can't find API database; API check not performed");
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ApiDetector.java

示例15: afterCheckProject

import com.android.tools.lint.detector.api.Context; //导入方法依赖的package包/类
@Override
public void afterCheckProject(@NonNull Context context) {
    if (mPendingFields != null) {
        for (List<Pair<String, Location>> list : mPendingFields.values()) {
            for (Pair<String, Location> pair : list) {
                String message = pair.getFirst();
                Location location = pair.getSecond();
                context.report(INLINED, location, message);
            }
        }
    }

    super.afterCheckProject(context);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ApiDetector.java


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