use of com.android.annotations.Nullable in project kotlin by JetBrains.
the class ApiLookup method get.
/**
* Returns an instance of the API database
*
* @param client the client to associate with this database - used only for
* logging. The database object may be shared among repeated invocations,
* and in that case client used will be the one originally passed in.
* In other words, this parameter may be ignored if the client created
* is not new.
* @return a (possibly shared) instance of the API database, or null
* if its data can't be found
*/
@Nullable
public static ApiLookup get(@NonNull LintClient client) {
synchronized (ApiLookup.class) {
ApiLookup db = sInstance.get();
if (db == null) {
File file = client.findResource(XML_FILE_PATH);
if (file == null) {
// AOSP build environment?
//$NON-NLS-1$
String build = System.getenv("ANDROID_BUILD_TOP");
if (build != null) {
file = new File(build, //$NON-NLS-1$
"development/sdk/api-versions.xml".replace('/', File.separatorChar));
}
}
if (file == null || !file.exists()) {
return null;
} else {
db = get(client, file);
}
sInstance = new WeakReference<ApiLookup>(db);
}
return db;
}
}
use of com.android.annotations.Nullable in project kotlin by JetBrains.
the class ViewTypeDetector method getViewTags.
@Nullable
protected Collection<String> getViewTags(@NonNull Context context, @NonNull ResourceItem item) {
// Check view tag in this file. Can I do it cheaply? Try with
// an XML pull parser. Or DOM if we have multiple resources looked
// up?
ResourceFile source = item.getSource();
if (source != null) {
File file = source.getFile();
Multimap<String, String> map = getIdToTagsIn(context, file);
if (map != null) {
return map.get(item.getName());
}
}
return null;
}
use of com.android.annotations.Nullable in project kotlin by JetBrains.
the class IntellijLintUtils method getPsiFile.
/**
* Returns the {@link PsiFile} associated with a given lint {@link Context}
*
* @param context the context to look up the file for
* @return the corresponding {@link PsiFile}, or null
*/
@Nullable
public static PsiFile getPsiFile(@NonNull Context context) {
VirtualFile file = VfsUtil.findFileByIoFile(context.file, false);
if (file == null) {
return null;
}
LintRequest request = context.getDriver().getRequest();
Project project = ((IntellijLintRequest) request).getProject();
if (project.isDisposed()) {
return null;
}
return AndroidPsiUtils.getPsiFileSafely(project, file);
}
use of com.android.annotations.Nullable in project kotlin by JetBrains.
the class IntellijViewTypeDetector method getViewTags.
@Nullable
@Override
protected Collection<String> getViewTags(@NonNull Context context, @NonNull ResourceItem item) {
AbstractResourceRepository projectResources = context.getClient().getProjectResources(context.getMainProject(), true);
assert projectResources instanceof LocalResourceRepository : projectResources;
LocalResourceRepository repository = (LocalResourceRepository) projectResources;
String viewTag = repository.getViewTag(item);
if (viewTag != null) {
return Collections.singleton(viewTag);
}
return super.getViewTags(context, item);
}
use of com.android.annotations.Nullable in project android by JetBrains.
the class LombokPsiConverterTest method parse.
@Nullable
private static Node parse(String code) {
CompilerOptions options = new CompilerOptions();
options.complianceLevel = options.sourceLevel = options.targetJDK = ClassFileConstants.JDK1_7;
options.parseLiteralExpressionsAsConstants = true;
ProblemReporter problemReporter = new ProblemReporter(DefaultErrorHandlingPolicies.exitOnFirstError(), options, new DefaultProblemFactory());
Parser parser = new Parser(problemReporter, options.parseLiteralExpressionsAsConstants);
parser.javadocParser.checkDocComment = false;
EcjTreeConverter converter = new EcjTreeConverter();
org.eclipse.jdt.internal.compiler.batch.CompilationUnit sourceUnit = new org.eclipse.jdt.internal.compiler.batch.CompilationUnit(code.toCharArray(), "unitTest", "UTF-8");
CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
CompilationUnitDeclaration unit = parser.parse(sourceUnit, compilationResult);
if (unit == null) {
return null;
}
converter.visit(code, unit);
List<? extends Node> nodes = converter.getAll();
for (lombok.ast.Node node : nodes) {
if (node instanceof lombok.ast.CompilationUnit) {
return node;
}
}
return null;
}
Aggregations