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;
}
use of com.android.annotations.NonNull in project kotlin by JetBrains.
the class LayoutConsistencyDetector method chainLocations.
@NonNull
private static Location chainLocations(@NonNull List<Location> locations) {
assert !locations.isEmpty();
// Sort locations by the file parent folders
if (locations.size() > 1) {
Collections.sort(locations, new Comparator<Location>() {
@Override
public int compare(Location location1, Location location2) {
File file1 = location1.getFile();
File file2 = location2.getFile();
String folder1 = file1.getParentFile().getName();
String folder2 = file2.getParentFile().getName();
return folder1.compareTo(folder2);
}
});
// Chain locations together
Iterator<Location> iterator = locations.iterator();
assert iterator.hasNext();
Location prev = iterator.next();
while (iterator.hasNext()) {
Location next = iterator.next();
prev.setSecondary(next);
prev = next;
}
}
return locations.get(0);
}
use of com.android.annotations.NonNull in project kotlin by JetBrains.
the class DomPsiParser method getLocation.
@NonNull
@Override
public Location getLocation(@NonNull XmlContext context, @NonNull Node node, int startDelta, int endDelta) {
TextRange textRange = DomPsiConverter.getTextRange(node);
Position start = new DefaultPosition(-1, -1, textRange.getStartOffset() + startDelta);
Position end = new DefaultPosition(-1, -1, textRange.getStartOffset() + endDelta);
return Location.create(context.file, start, end);
}
use of com.android.annotations.NonNull in project kotlin by JetBrains.
the class IntellijLintClient method getConfiguration.
@NonNull
@Override
public Configuration getConfiguration(@NonNull com.android.tools.klint.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);
}
};
}
use of com.android.annotations.NonNull in project kotlin by JetBrains.
the class IntellijLintProject method createForSingleFile.
/**
* Creates a project for a single file. Also optionally creates a main project for the file, if applicable.
*
* @param client the lint client
* @param file the file to create a project for
* @param module the module to create a project for
* @return a project for the file, as well as a project (or null) for the main Android module
*/
@NonNull
public static Pair<Project, Project> createForSingleFile(@NonNull IntellijLintClient client, @Nullable VirtualFile file, @NonNull Module module) {
// TODO: Can make this method even more lightweight: we don't need to initialize anything in the project (source paths etc)
// other than the metadata necessary for this file's type
LintModuleProject project = createModuleProject(client, module);
LintModuleProject main = null;
Map<Project, Module> projectMap = Maps.newHashMap();
if (project != null) {
project.setDirectLibraries(Collections.<Project>emptyList());
if (file != null) {
project.addFile(VfsUtilCore.virtualToIoFile(file));
}
projectMap.put(project, module);
// using the library, not "1" (the default for a module without a manifest)
if (!project.isAndroidProject()) {
Module androidModule = findAndroidModule(module);
if (androidModule != null) {
main = createModuleProject(client, androidModule);
if (main != null) {
projectMap.put(main, androidModule);
main.setDirectLibraries(Collections.<Project>singletonList(project));
}
}
}
}
client.setModuleMap(projectMap);
//noinspection ConstantConditions
return Pair.<Project, Project>create(project, main);
}
Aggregations