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


Java Scope类代码示例

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


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

示例1: getIssuesForScope

import com.android.tools.lint.detector.api.Scope; //导入依赖的package包/类
/**
 * Returns all available issues of a given scope (regardless of whether
 * they are actually enabled for a given configuration etc)
 *
 * @param scope the applicable scope set
 * @return a list of issues
 */
@NonNull
protected List<Issue> getIssuesForScope(@NonNull EnumSet<Scope> scope) {
    List<Issue> list = sScopeIssues.get(scope);
    if (list == null) {
        List<Issue> issues = getIssues();
        if (scope.equals(Scope.ALL)) {
            list = issues;
        } else {
            list = new ArrayList<Issue>(getIssueCapacity(scope));
            for (Issue issue : issues) {
                // Determine if the scope matches
                if (issue.getImplementation().isAdequate(scope)) {
                    list.add(issue);
                }
            }
        }
        sScopeIssues.put(scope, list);
    }

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

示例2: checkBuildScripts

import com.android.tools.lint.detector.api.Scope; //导入依赖的package包/类
private void checkBuildScripts(Project project, Project main) {
    List<Detector> detectors = mScopeDetectors.get(Scope.GRADLE_FILE);
    if (detectors != null) {
        List<File> files = project.getSubset();
        if (files == null) {
            files = project.getGradleBuildScripts();
        }
        for (File file : files) {
            Context context = new Context(this, project, main, file);
            fireEvent(EventType.SCANNING_FILE, context);
            for (Detector detector : detectors) {
                if (detector.appliesTo(context, file)) {
                    detector.beforeCheckFile(context);
                    detector.visitBuildScript(context, Maps.<String, Object>newHashMap());
                    detector.afterCheckFile(context);
                }
            }
        }
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:LintDriver.java

示例3: checkProGuard

import com.android.tools.lint.detector.api.Scope; //导入依赖的package包/类
private void checkProGuard(Project project, Project main) {
    List<Detector> detectors = mScopeDetectors.get(Scope.PROGUARD_FILE);
    if (detectors != null) {
        List<File> files = project.getProguardFiles();
        for (File file : files) {
            Context context = new Context(this, project, main, file);
            fireEvent(EventType.SCANNING_FILE, context);
            for (Detector detector : detectors) {
                if (detector.appliesTo(context, file)) {
                    detector.beforeCheckFile(context);
                    detector.run(context);
                    detector.afterCheckFile(context);
                }
            }
        }
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:LintDriver.java

示例4: checkIndividualClassFiles

import com.android.tools.lint.detector.api.Scope; //导入依赖的package包/类
private void checkIndividualClassFiles(
        @NonNull Project project,
        @Nullable Project main,
        @NonNull List<File> files) {
    List<File> classFiles = Lists.newArrayListWithExpectedSize(files.size());
    List<File> classFolders = project.getJavaClassFolders();
    if (!classFolders.isEmpty()) {
        for (File file : files) {
            String path = file.getPath();
            if (file.isFile() && path.endsWith(DOT_CLASS)) {
                classFiles.add(file);
            }
        }
    }

    List<ClassEntry> entries = ClassEntry.fromClassFiles(mClient, classFiles, classFolders,
            true);
    if (!entries.isEmpty()) {
        Collections.sort(entries);
        runClassDetectors(Scope.CLASS_FILE, entries, project, main);
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:LintDriver.java

示例5: requestRepeat

import com.android.tools.lint.detector.api.Scope; //导入依赖的package包/类
/**
 * Requests another pass through the data for the given detector. This is
 * typically done when a detector needs to do more expensive computation,
 * but it only wants to do this once it <b>knows</b> that an error is
 * present, or once it knows more specifically what to check for.
 *
 * @param detector the detector that should be included in the next pass.
 *            Note that the lint runner may refuse to run more than a couple
 *            of runs.
 * @param scope the scope to be revisited. This must be a subset of the
 *       current scope ({@link #getScope()}, and it is just a performance hint;
 *       in particular, the detector should be prepared to be called on other
 *       scopes as well (since they may have been requested by other detectors).
 *       You can pall null to indicate "all".
 */
public void requestRepeat(@NonNull Detector detector, @Nullable EnumSet<Scope> scope) {
    if (mRepeatingDetectors == null) {
        mRepeatingDetectors = new ArrayList<Detector>();
    }
    mRepeatingDetectors.add(detector);

    if (scope != null) {
        if (mRepeatScope == null) {
            mRepeatScope = scope;
        } else {
            mRepeatScope = EnumSet.copyOf(mRepeatScope);
            mRepeatScope.addAll(scope);
        }
    } else {
        mRepeatScope = Scope.ALL;
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:LintDriver.java

示例6: getIssueCapacity

import com.android.tools.lint.detector.api.Scope; //导入依赖的package包/类
@Override
protected int getIssueCapacity(@NonNull EnumSet<Scope> scope) {
    if (scope.equals(Scope.ALL)) {
        return getIssues().size();
    } else {
        int initialSize = 12;
        if (scope.contains(Scope.RESOURCE_FILE)) {
            initialSize += 75;
        } else if (scope.contains(Scope.ALL_RESOURCE_FILES)) {
            initialSize += 10;
        }

        if (scope.contains(Scope.JAVA_FILE)) {
            initialSize += 55;
        } else if (scope.contains(Scope.CLASS_FILE)) {
            initialSize += 15;
        } else if (scope.contains(Scope.MANIFEST)) {
            initialSize += 30;
        } else if (scope.contains(Scope.GRADLE_FILE)) {
            initialSize += 5;
        }
        return initialSize;
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:BuiltinIssueRegistry.java

示例7: testFragments

import com.android.tools.lint.detector.api.Scope; //导入依赖的package包/类
public void testFragments() throws Exception {
    mScopes = Scope.MANIFEST_SCOPE;
    mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS);

    // Ensure that we don't do instantiation checks here since they are handled by
    // the FragmentDetector
    assertEquals(
            "No warnings.",

            lintProject(
                    "bytecode/FragmentTest$Fragment1.class.data=>bin/classes/test/pkg/FragmentTest$Fragment1.class",
                    "bytecode/FragmentTest$Fragment2.class.data=>bin/classes/test/pkg/FragmentTest$Fragment2.class",
                    "bytecode/FragmentTest$Fragment3.class.data=>bin/classes/test/pkg/FragmentTest$Fragment3.class",
                    "bytecode/FragmentTest$Fragment4.class.data=>bin/classes/test/pkg/FragmentTest$Fragment4.class",
                    "bytecode/FragmentTest$Fragment5.class.data=>bin/classes/test/pkg/FragmentTest$Fragment5.class",
                    "bytecode/FragmentTest$Fragment6.class.data=>bin/classes/test/pkg/FragmentTest$Fragment6.class",
                    "bytecode/FragmentTest$NotAFragment.class.data=>bin/classes/test/pkg/FragmentTest$NotAFragment.class",
                    "bytecode/FragmentTest.java.txt=>src/test/pkg/FragmentTest.java"));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:MissingClassDetectorTest.java

示例8: getScope

import com.android.tools.lint.detector.api.Scope; //导入依赖的package包/类
@Nullable
@Override
public EnumSet<Scope> getScope() {
  if (mScope == null) {
    Collection<com.android.tools.lint.detector.api.Project> projects = getProjects();
    if (projects != null) {
      mScope = Scope.infer(projects);

      //noinspection ConstantConditions
      if (!IntellijLintProject.SUPPORT_CLASS_FILES && (mScope.contains(Scope.CLASS_FILE) || mScope.contains(Scope.ALL_CLASS_FILES)
                                                       || mScope.contains(Scope.JAVA_LIBRARIES))) {
        mScope = EnumSet.copyOf(mScope); // make mutable
        // Can't run class file based checks
        mScope.remove(Scope.CLASS_FILE);
        mScope.remove(Scope.ALL_CLASS_FILES);
        mScope.remove(Scope.JAVA_LIBRARIES);
      }
    }
  }

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

示例9: computeDetectors

import com.android.tools.lint.detector.api.Scope; //导入依赖的package包/类
private void computeDetectors(@NonNull Project project) {
    // Ensure that the current visitor is recomputed
    mCurrentFolderType = null;
    mCurrentVisitor = null;

    Configuration configuration = project.getConfiguration();
    mScopeDetectors = new EnumMap<Scope, List<Detector>>(Scope.class);
    mApplicableDetectors = mRegistry.createDetectors(mClient, configuration,
            mScope, mScopeDetectors);

    validateScopeList();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:LintDriver.java

示例10: checkProperties

import com.android.tools.lint.detector.api.Scope; //导入依赖的package包/类
private void checkProperties(Project project, Project main) {
    List<Detector> detectors = mScopeDetectors.get(Scope.PROPERTY_FILE);
    if (detectors != null) {
        checkPropertyFile(project, main, detectors, FN_LOCAL_PROPERTIES);
        checkPropertyFile(project, main, detectors, FD_GRADLE_WRAPPER + separator +
                FN_GRADLE_WRAPPER_PROPERTIES);
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:LintDriver.java

示例11: afterCheckProject

import com.android.tools.lint.detector.api.Scope; //导入依赖的package包/类
@Override
public void afterCheckProject(@NonNull Context context) {
    // Process checks in two phases:
    // Phase 1: Gather styles and includes (styles are encountered after the layouts
    // so we can't do it in a single phase, and includes can be affected by includes from
    // layouts we haven't seen yet)
    // Phase 2: Process layouts, using gathered style and include data, and mark layouts
    // not known.
    //
    if (context.getPhase() == 1) {
        checkSizeSetInTheme();

        context.requestRepeat(this, Scope.RESOURCE_FILE_SCOPE);
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:RequiredAttributeDetector.java

示例12: beforeCheckProject

import com.android.tools.lint.detector.api.Scope; //导入依赖的package包/类
@Override
public void beforeCheckProject(@NonNull Context context) {
    // In incremental mode, or checking all files (full lint analysis) ? If the latter,
    // we should store state and look for deeper cycles
    if (context.getScope().contains(Scope.ALL_RESOURCE_FILES)) {
        mReferences = Maps.newEnumMap(ResourceType.class);
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ResourceCycleDetector.java

示例13: findCycles

import com.android.tools.lint.detector.api.Scope; //导入依赖的package包/类
private void findCycles(
        @NonNull Context context,
        @NonNull ResourceType type,
        @NonNull Multimap<String, String> map) {
    Set<String> visiting = Sets.newHashSetWithExpectedSize(map.size());
    Set<String> seen = Sets.newHashSetWithExpectedSize(map.size());
    for (String from : map.keySet()) {
        if (seen.contains(from)) {
            continue;
        }
        List<String> chain = dfs(map, from, visiting);
        if (chain != null && chain.size() > 2) { // size 1 chains are handled directly
            seen.addAll(chain);
            Collections.reverse(chain);
            if (mChains == null) {
                mChains = Maps.newEnumMap(ResourceType.class);
                mLocations = Maps.newEnumMap(ResourceType.class);
                context.getDriver().requestRepeat(this, Scope.RESOURCE_FILE_SCOPE);
            }
            List<List<String>> list = mChains.get(type);
            if (list == null) {
                list = Lists.newArrayList();
                mChains.put(type, list);
            }
            list.add(chain);
        }
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:ResourceCycleDetector.java

示例14: afterCheckProject

import com.android.tools.lint.detector.api.Scope; //导入依赖的package包/类
@Override
public void afterCheckProject(@NonNull Context context) {
    LintDriver driver = context.getDriver();
    if (driver.getPhase() == 1) {
        // First phase: gather all the ids and look for consistency issues.
        // If any are found, request location computation in phase 2 by
        // writing the ids needed for each layout in the {@link #mLocations} map.
        for (Map.Entry<String,List<Pair<File,Map<String,String>>>> entry : mMap.entrySet()) {
            String layout = entry.getKey();
            List<Pair<File, Map<String, String>>> files = entry.getValue();
            if (files.size() < 2) {
                // No consistency problems for files that don't have resource variations
                continue;
            }

            checkConsistentIds(layout, files);
        }

        if (mLocations != null) {
            driver.requestRepeat(this, Scope.ALL_RESOURCES_SCOPE);
        }
    } else {
        // Collect results and print
        if (!mLocations.isEmpty()) {
            reportErrors(context);
        }
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:LayoutConsistencyDetector.java

示例15: afterCheckProject

import com.android.tools.lint.detector.api.Scope; //导入依赖的package包/类
@Override
public void afterCheckProject(@NonNull Context context) {
    int phase = context.getPhase();
    if (phase == 1 && mApplicableResources != null) {
        // We found resources for the string "Cancel"; perform a second pass
        // where we check layout text attributes against these strings.
        context.getDriver().requestRepeat(this, Scope.RESOURCE_FILE_SCOPE);
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ButtonDetector.java


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