use of com.android.annotations.NonNull in project android by JetBrains.
the class LintIdeJavaParser method getAnnotations.
@NonNull
private static Iterable<ResolvedAnnotation> getAnnotations(@Nullable PsiModifierListOwner owner) {
if (owner != null) {
PsiModifierList modifierList = owner.getModifierList();
if (modifierList != null) {
PsiAnnotation[] annotations = modifierList.getAnnotations();
if (annotations.length > 0) {
List<ResolvedAnnotation> result = Lists.newArrayListWithExpectedSize(annotations.length);
for (PsiAnnotation method : annotations) {
result.add(new ResolvedPsiAnnotation(method));
}
return result;
}
}
ExternalAnnotationsManager annotationsManager = ExternalAnnotationsManager.getInstance(owner.getProject());
PsiAnnotation[] annotations = annotationsManager.findExternalAnnotations(owner);
if (annotations != null) {
List<ResolvedAnnotation> result = Lists.newArrayListWithExpectedSize(annotations.length);
for (PsiAnnotation method : annotations) {
result.add(new ResolvedPsiAnnotation(method));
}
return result;
}
}
return Collections.emptyList();
}
use of com.android.annotations.NonNull in project android by JetBrains.
the class LintIdeJavaParser method getRangeLocation.
@NonNull
@Override
public Location getRangeLocation(@NonNull JavaContext context, @NonNull Node from, int fromDelta, @NonNull Node to, int toDelta) {
Position position1 = from.getPosition();
Position position2 = to.getPosition();
if (position1 == null) {
return getLocation(context, to);
} else if (position2 == null) {
return getLocation(context, from);
}
int start = Math.max(0, from.getPosition().getStart() + fromDelta);
int end = to.getPosition().getEnd() + toDelta;
return Location.create(context.file, null, start, end);
}
use of com.android.annotations.NonNull in project android by JetBrains.
the class LintIdeProject method create.
/** Creates a set of projects for the given IntelliJ modules */
@NonNull
public static List<Project> create(@NonNull LintIdeClient 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;
}
}
use of com.android.annotations.NonNull in project android by JetBrains.
the class LintIdeUtils 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);
}
use of com.android.annotations.NonNull in project android by JetBrains.
the class EclipseProject method getManifestDoc.
@NonNull
public Document getManifestDoc() throws IOException {
assert isAndroidProject();
if (myManifestDoc == null) {
File file = getManifestFile();
myManifestDoc = myImporter.getXmlDocument(file, true);
}
return myManifestDoc;
}
Aggregations