use of com.android.annotations.NonNull in project kotlin by JetBrains.
the class PermissionFinder method getPermissionRequirement.
@NonNull
private Result getPermissionRequirement(@NonNull PsiField field, @NonNull UAnnotation annotation) {
PermissionRequirement requirement = PermissionRequirement.create(annotation);
PsiClass containingClass = field.getContainingClass();
String name = containingClass != null ? containingClass.getName() + "." + field.getName() : field.getName();
assert name != null;
return new Result(mOperation, requirement, name);
}
use of com.android.annotations.NonNull in project android 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 LintXmlPosition(node, textRange.getStartOffset() + startDelta);
Position end = new LintXmlPosition(node, textRange.getStartOffset() + endDelta);
return Location.create(context.file, start, end);
}
use of com.android.annotations.NonNull in project android by JetBrains.
the class DomPsiParser method getLocation.
@NonNull
@Override
public Location getLocation(@NonNull XmlContext context, @NonNull Node node) {
TextRange textRange = DomPsiConverter.getTextRange(node);
Position start = new LintXmlPosition(node, textRange.getStartOffset());
Position end = new LintXmlPosition(node, textRange.getEndOffset());
return Location.create(context.file, start, end);
}
use of com.android.annotations.NonNull in project bazel by bazelbuild.
the class FileUtils method getDirectoryNameForJar.
/**
* Chooses a directory name, based on a JAR file name, considering exploded-aar and classes.jar.
*/
@NonNull
public static String getDirectoryNameForJar(@NonNull File inputFile) {
// add a hash of the original file path.
HashFunction hashFunction = Hashing.sha1();
HashCode hashCode = hashFunction.hashString(inputFile.getAbsolutePath(), Charsets.UTF_16LE);
String name = Files.getNameWithoutExtension(inputFile.getName());
if (name.equals("classes") && inputFile.getAbsolutePath().contains("exploded-aar")) {
// This naming scheme is coming from DependencyManager#computeArtifactPath.
File versionDir = inputFile.getParentFile().getParentFile();
File artifactDir = versionDir.getParentFile();
File groupDir = artifactDir.getParentFile();
name = Joiner.on('-').join(groupDir.getName(), artifactDir.getName(), versionDir.getName());
}
name = name + "_" + hashCode.toString();
return name;
}
use of com.android.annotations.NonNull in project buck by facebook.
the class XmlPrettyPrinter method prettyPrint.
/**
* Pretty-prints the given XML document, which must be well-formed. If it is not,
* the original unformatted XML document is returned
*
* @param xml the XML content to format
* @param prefs the preferences to format with
* @param style the style to format with
* @param lineSeparator the line separator to use, such as "\n" (can be null, in which
* case the system default is looked up via the line.separator property)
* @return the formatted document (or if a parsing error occurred, returns the
* unformatted document)
*/
@NonNull
public static String prettyPrint(@NonNull String xml, @NonNull XmlFormatPreferences prefs, @NonNull XmlFormatStyle style, @Nullable String lineSeparator) {
Document document = XmlUtils.parseDocumentSilently(xml, true);
if (document != null) {
XmlPrettyPrinter printer = new XmlPrettyPrinter(prefs, style, lineSeparator);
printer.setEndWithNewline(xml.endsWith(printer.getLineSeparator()));
StringBuilder sb = new StringBuilder(3 * xml.length() / 2);
printer.prettyPrint(-1, document, null, null, sb, false);
return sb.toString();
} else {
// Parser error: just return the unformatted content
return xml;
}
}
Aggregations