use of com.android.annotations.NonNull in project android by JetBrains.
the class PsiResourceItem method parseDeclareStyleable.
@NonNull
private ResourceValue parseDeclareStyleable(@NonNull DeclareStyleableResourceValue declareStyleable) {
assert myTag != null;
for (XmlTag child : myTag.getSubTags()) {
String name = getAttributeValue(child, ATTR_NAME);
if (name != null) {
// is the attribute in the android namespace?
boolean isFrameworkAttr = declareStyleable.isFramework();
if (name.startsWith(ANDROID_NS_NAME_PREFIX)) {
name = name.substring(ANDROID_NS_NAME_PREFIX_LEN);
isFrameworkAttr = true;
}
AttrResourceValue attr = parseAttrValue(child, new AttrResourceValue(ResourceType.ATTR, name, isFrameworkAttr, null));
declareStyleable.addValue(attr);
}
}
return declareStyleable;
}
use of com.android.annotations.NonNull in project android by JetBrains.
the class DynamicResourceValueRepository method getMap.
@Override
@NonNull
protected Map<ResourceType, ListMultimap<String, ResourceItem>> getMap() {
if (mItems.isEmpty()) {
// TODO: b/23032391
AndroidModuleModel androidModel = AndroidModuleModel.get(myFacet);
if (androidModel == null) {
return mItems;
}
Variant selectedVariant = androidModel.getSelectedVariant();
// Reverse overlay order because when processing lower order ones, we ignore keys already processed
BuildTypeContainer buildType = androidModel.findBuildType(selectedVariant.getBuildType());
if (buildType != null) {
addValues(buildType.getBuildType().getResValues());
}
// flavors and default config:
addValues(selectedVariant.getMergedFlavor().getResValues());
}
return mItems;
}
use of com.android.annotations.NonNull in project android by JetBrains.
the class LintIdeClient method getConfiguration.
@NonNull
@Override
public Configuration getConfiguration(@NonNull com.android.tools.lint.detector.api.Project project, @Nullable final LintDriver driver) {
if (project.isGradleProject() && project.isAndroidProject() && !project.isLibrary()) {
AndroidProject model = project.getGradleProjectModel();
if (model != null) {
try {
LintOptions lintOptions = model.getLintOptions();
final Map<String, Integer> overrides = lintOptions.getSeverityOverrides();
if (overrides != null && !overrides.isEmpty()) {
return new DefaultConfiguration(this, project, null) {
@NonNull
@Override
public Severity getSeverity(@NonNull Issue issue) {
Integer severity = overrides.get(issue.getId());
if (severity != null) {
switch(severity.intValue()) {
case LintOptions.SEVERITY_FATAL:
return Severity.FATAL;
case LintOptions.SEVERITY_ERROR:
return Severity.ERROR;
case LintOptions.SEVERITY_WARNING:
return Severity.WARNING;
case LintOptions.SEVERITY_INFORMATIONAL:
return Severity.INFORMATIONAL;
case LintOptions.SEVERITY_IGNORE:
default:
return Severity.IGNORE;
}
}
// This is a LIST lookup. I should make this faster!
if (!getIssues().contains(issue) && (driver == null || !driver.isCustomIssue(issue))) {
return Severity.IGNORE;
}
return super.getSeverity(issue);
}
};
}
} catch (Exception e) {
LOG.error(e);
}
}
}
return new DefaultConfiguration(this, project, null) {
@Override
public boolean isEnabled(@NonNull Issue issue) {
if (getIssues().contains(issue) && super.isEnabled(issue)) {
return true;
}
return driver != null && driver.isCustomIssue(issue) || issue == IssueRegistry.BASELINE || issue == IssueRegistry.CANCELLED;
}
};
}
use of com.android.annotations.NonNull in project android by JetBrains.
the class LintIdeGradleDetector method getPropertyKeyCookie.
@NonNull
@Override
protected Object getPropertyKeyCookie(@NonNull Object cookie) {
PsiElement element = (PsiElement) cookie;
PsiElement parent = element.getParent();
if (parent instanceof GrApplicationStatement) {
GrApplicationStatement call = (GrApplicationStatement) parent;
return call.getInvokedExpression();
} else if (parent instanceof GrAssignmentExpression) {
GrAssignmentExpression assignment = (GrAssignmentExpression) parent;
return assignment.getLValue();
}
return super.getPropertyKeyCookie(cookie);
}
use of com.android.annotations.NonNull in project android by JetBrains.
the class LintIdeJavaParser method createLocation.
@NonNull
private static Location createLocation(@NonNull JavaContext context, @Nullable PsiFile containingFile, int startOffset, int endOffset) {
LintJavaPosition start = new LintJavaPosition(containingFile, startOffset);
LintJavaPosition end = new LintJavaPosition(containingFile, endOffset);
File file = context.file;
if (containingFile != null && containingFile != context.getJavaFile()) {
// 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) {
file = VfsUtilCore.virtualToIoFile(virtualFile);
} else {
return Location.NONE;
}
}
return Location.create(file, start, end);
}
Aggregations