use of com.android.annotations.NonNull in project android by JetBrains.
the class DomPsiParser method getValueLocation.
@NonNull
@Override
public Location getValueLocation(@NonNull XmlContext context, @NonNull Attr node) {
TextRange textRange = DomPsiConverter.getTextValueRange(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 android by JetBrains.
the class DomPsiParser method getNameLocation.
@NonNull
@Override
public Location getNameLocation(@NonNull XmlContext context, @NonNull Node node) {
TextRange textRange = DomPsiConverter.getTextNameRange(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 android by JetBrains.
the class LintIdeProject 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 LintIdeClient 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);
}
use of com.android.annotations.NonNull in project android by JetBrains.
the class LocalResourceRepository method getMatchingFiles.
@NonNull
public List<VirtualFile> getMatchingFiles(@NonNull VirtualFile file, @NonNull ResourceType type, @NonNull FolderConfiguration config) {
List<ResourceFile> matches = super.getMatchingFiles(ResourceHelper.getResourceName(file), type, config);
List<VirtualFile> matchesFiles = new ArrayList<VirtualFile>(matches.size());
for (ResourceFile match : matches) {
if (match != null) {
if (match instanceof PsiResourceFile) {
matchesFiles.add(((PsiResourceFile) match).getPsiFile().getVirtualFile());
} else {
matchesFiles.add(LocalFileSystem.getInstance().findFileByIoFile(match.getFile()));
}
}
}
return matchesFiles;
}
use of com.android.annotations.NonNull in project android by JetBrains.
the class PsiResourceItem method parseStyleValue.
@NonNull
private ResourceValue parseStyleValue(@NonNull StyleResourceValue styleValue) {
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 = styleValue.isFramework();
if (name.startsWith(ANDROID_NS_NAME_PREFIX)) {
name = name.substring(ANDROID_NS_NAME_PREFIX_LEN);
isFrameworkAttr = true;
}
ItemResourceValue resValue = new ItemResourceValue(name, isFrameworkAttr, styleValue.isFramework(), styleValue.getLibraryName());
resValue.setValue(ValueXmlHelper.unescapeResourceString(ResourceHelper.getTextContent(child), true, true));
styleValue.addItem(resValue);
}
}
return styleValue;
}
Aggregations