use of com.android.annotations.NonNull in project kotlin by JetBrains.
the class Project method getResourceFolders.
/**
* Returns the resource folders.
*
* @return a list of files pointing to the resource folders, which might be empty if the project
* does not provide any resources.
*/
@NonNull
public List<File> getResourceFolders() {
if (mResourceFolders == null) {
List<File> folders = mClient.getResourceFolders(this);
if (folders.size() == 1 && isAospFrameworksRelatedProject(mDir)) {
// No manifest file for this project: just init the manifest values here
mManifestMinSdk = mManifestTargetSdk = new AndroidVersion(HIGHEST_KNOWN_API, null);
File folder = new File(folders.get(0), RES_FOLDER);
if (!folder.exists()) {
folders = Collections.emptyList();
}
}
mResourceFolders = folders;
}
return mResourceFolders;
}
use of com.android.annotations.NonNull in project kotlin by JetBrains.
the class IssueRegistry method createCategoryList.
@NonNull
private List<Category> createCategoryList() {
Set<Category> categorySet = Sets.newHashSetWithExpectedSize(20);
for (Issue issue : getIssues()) {
categorySet.add(issue.getCategory());
}
List<Category> sorted = new ArrayList<Category>(categorySet);
Collections.sort(sorted);
return sorted;
}
use of com.android.annotations.NonNull in project kotlin by JetBrains.
the class IssueRegistry method getIssuesForScope.
/**
* 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;
}
use of com.android.annotations.NonNull in project kotlin by JetBrains.
the class JavaParser method getLocation.
/**
* Returns a {@link Location} for the given element
*
* @param context information about the file being parsed
* @param element the element to create a location for
* @return a location for the given node
*/
// subclasses may want to override/optimize
@SuppressWarnings("MethodMayBeStatic")
@NonNull
public Location getLocation(@NonNull JavaContext context, @NonNull PsiElement element) {
TextRange range = element.getTextRange();
UFile uFile = (UFile) getUastContext().convertElementWithParent(element.getContainingFile(), UFile.class);
if (uFile == null) {
return Location.NONE;
}
PsiFile containingFile = uFile.getPsi();
File file = context.file;
if (containingFile != context.getUFile().getPsi()) {
// Reporting an error in a different file.
if (context.getDriver().getScope().size() == 1) {
// Don't bother with this error if it's in a different file during single-file analysis
return Location.NONE;
}
VirtualFile virtualFile = containingFile.getVirtualFile();
if (virtualFile == null) {
return Location.NONE;
}
file = VfsUtilCore.virtualToIoFile(virtualFile);
}
return Location.create(file, context.getContents(), range.getStartOffset(), range.getEndOffset());
}
use of com.android.annotations.NonNull in project kotlin by JetBrains.
the class JavaParser method getNameLocation.
/**
* Returns a {@link Location} for the given node. This attempts to pick a shorter
* location range than the entire node; for a class or method for example, it picks
* the name node (if found). For statement constructs such as a {@code switch} statement
* it will highlight the keyword, etc.
*
* @param context information about the file being parsed
* @param node the node to create a location for
* @return a location for the given node
* @deprecated Use {@link #getNameLocation(JavaContext, PsiElement)} instead
*/
@Deprecated
@NonNull
public Location getNameLocation(@NonNull JavaContext context, @NonNull Node node) {
Node nameNode = JavaContext.findNameNode(node);
if (nameNode != null) {
node = nameNode;
} else {
if (node instanceof Switch || node instanceof For || node instanceof If || node instanceof While || node instanceof Throw || node instanceof Return) {
// Lint doesn't want to highlight the entire statement/block associated
// with this node, it wants to just highlight the keyword.
Location location = getLocation(context, node);
Position start = location.getStart();
if (start != null) {
// The Lombok classes happen to have the same length as the target keyword
int length = node.getClass().getSimpleName().length();
return Location.create(location.getFile(), start, new DefaultPosition(start.getLine(), start.getColumn() + length, start.getOffset() + length));
}
}
}
return getLocation(context, node);
}
Aggregations