Search in sources :

Example 76 with NonNull

use of com.android.annotations.NonNull in project android by JetBrains.

the class MultiResourceRepository method getMap.

@NonNull
@Override
protected Map<ResourceType, ListMultimap<String, ResourceItem>> getMap() {
    if (myItems == null) {
        if (myChildren.size() == 1) {
            myItems = myChildren.get(0).getItems();
        } else {
            Map<ResourceType, ListMultimap<String, ResourceItem>> map = Maps.newEnumMap(ResourceType.class);
            for (ResourceType type : ResourceType.values()) {
                // should pass create is true, but as described below we interpret this differently
                map.put(type, getMap(type, false));
            }
            myItems = map;
        }
    }
    return myItems;
}
Also used : ResourceType(com.android.resources.ResourceType) NonNull(com.android.annotations.NonNull)

Example 77 with NonNull

use of com.android.annotations.NonNull in project kotlin by JetBrains.

the class SupportAnnotationDetector method addLocalPermissions.

@NonNull
private static PermissionHolder addLocalPermissions(@NonNull PermissionHolder permissions, @NonNull UElement node) {
    // Accumulate @RequirePermissions available in the local context
    UMethod method = UastUtils.getParentOfType(node, UMethod.class, true);
    if (method == null) {
        return permissions;
    }
    UAnnotation annotation = method.findAnnotation(PERMISSION_ANNOTATION);
    permissions = mergeAnnotationPermissions(permissions, annotation);
    UClass containingClass = UastUtils.getContainingUClass(method);
    if (containingClass != null) {
        annotation = containingClass.findAnnotation(PERMISSION_ANNOTATION);
        permissions = mergeAnnotationPermissions(permissions, annotation);
    }
    return permissions;
}
Also used : JavaUAnnotation(org.jetbrains.uast.java.JavaUAnnotation) NonNull(com.android.annotations.NonNull)

Example 78 with NonNull

use of com.android.annotations.NonNull in project kotlin by JetBrains.

the class DomPsiParser method getValueLocation.

@NonNull
@Override
public Location getValueLocation(@NonNull XmlContext context, @NonNull Attr node) {
    TextRange textRange = DomPsiConverter.getTextValueRange(node);
    Position start = new DefaultPosition(-1, -1, textRange.getStartOffset());
    Position end = new DefaultPosition(-1, -1, textRange.getEndOffset());
    return Location.create(context.file, start, end);
}
Also used : Position(com.android.tools.klint.detector.api.Position) DefaultPosition(com.android.tools.klint.detector.api.DefaultPosition) DefaultPosition(com.android.tools.klint.detector.api.DefaultPosition) TextRange(com.intellij.openapi.util.TextRange) NonNull(com.android.annotations.NonNull)

Example 79 with NonNull

use of com.android.annotations.NonNull in project kotlin by JetBrains.

the class IntellijLintProject method create.

/** Creates a set of projects for the given IntelliJ modules */
@NonNull
public static List<Project> create(@NonNull IntellijLintClient client, @Nullable List<VirtualFile> files, @NonNull Module... modules) {
    List<Project> projects = Lists.newArrayList();
    Map<Project, Module> projectMap = Maps.newHashMap();
    Map<Module, Project> moduleMap = Maps.newHashMap();
    Map<AndroidLibrary, Project> libraryMap = Maps.newHashMap();
    if (files != null && !files.isEmpty()) {
        // Wrap list with a mutable list since we'll be removing the files as we see them
        files = Lists.newArrayList(files);
    }
    for (Module module : modules) {
        addProjects(client, module, files, moduleMap, libraryMap, projectMap, projects);
    }
    client.setModuleMap(projectMap);
    if (projects.size() > 1) {
        // Partition the projects up such that we only return projects that aren't
        // included by other projects (e.g. because they are library projects)
        Set<Project> roots = new HashSet<Project>(projects);
        for (Project project : projects) {
            roots.removeAll(project.getAllLibraries());
        }
        return Lists.newArrayList(roots);
    } else {
        return projects;
    }
}
Also used : Project(com.android.tools.klint.detector.api.Project) Module(com.intellij.openapi.module.Module) NonNull(com.android.annotations.NonNull)

Example 80 with NonNull

use of com.android.annotations.NonNull in project kotlin by JetBrains.

the class IntellijLintUtils method getLocation.

/**
   * Gets the location of the given element
   *
   * @param file the file containing the location
   * @param element the element to look up the location for
   * @return the location of the given element
   */
@NonNull
public static Location getLocation(@NonNull File file, @NonNull PsiElement element) {
    //noinspection ConstantConditions
    assert element.getContainingFile().getVirtualFile() == null || FileUtil.filesEqual(VfsUtilCore.virtualToIoFile(element.getContainingFile().getVirtualFile()), file);
    if (element instanceof PsiClass) {
        // Point to the name rather than the beginning of the javadoc
        PsiClass clz = (PsiClass) element;
        PsiIdentifier nameIdentifier = clz.getNameIdentifier();
        if (nameIdentifier != null) {
            element = nameIdentifier;
        }
    }
    TextRange textRange = element.getTextRange();
    Position start = new DefaultPosition(-1, -1, textRange.getStartOffset());
    Position end = new DefaultPosition(-1, -1, textRange.getEndOffset());
    return Location.create(file, start, end);
}
Also used : TextRange(com.intellij.openapi.util.TextRange) NonNull(com.android.annotations.NonNull)

Aggregations

NonNull (com.android.annotations.NonNull)89 File (java.io.File)23 TextRange (com.intellij.openapi.util.TextRange)13 IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)8 OutputFile (com.android.build.OutputFile)5 DefaultPosition (com.android.tools.klint.detector.api.DefaultPosition)5 Position (com.android.tools.klint.detector.api.Position)5 Issue (com.android.tools.klint.detector.api.Issue)4 Position (com.android.tools.lint.detector.api.Position)4 Module (com.intellij.openapi.module.Module)4 StringReader (java.io.StringReader)4 AbstractInsnNode (org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode)4 Node (org.w3c.dom.Node)4 NodeList (org.w3c.dom.NodeList)4 InputSource (org.xml.sax.InputSource)4 Nullable (com.android.annotations.Nullable)3 AaptPackageProcessBuilder (com.android.builder.core.AaptPackageProcessBuilder)3 AtlasBuilder (com.android.builder.core.AtlasBuilder)3 AndroidProject (com.android.builder.model.AndroidProject)3