use of com.android.annotations.VisibleForTesting in project android by JetBrains.
the class StyleFilter method isDerived.
@VisibleForTesting
boolean isDerived(@NotNull StyleResourceValue style) {
String styleName = getStyleName(style);
if (myDerivedStyles.contains(styleName)) {
return true;
}
if (myOtherStyles.contains(styleName)) {
return false;
}
StyleResourceValue parentStyle = myResolver.getParent(style);
if (parentStyle != null && !myCurrentInheritanceChain.contains(styleName)) {
myCurrentInheritanceChain.add(styleName);
return found(styleName, isDerived(parentStyle));
}
return found(styleName, false);
}
use of com.android.annotations.VisibleForTesting in project kotlin by JetBrains.
the class LayoutInflationDetector method hasLayoutParams.
@VisibleForTesting
static boolean hasLayoutParams(@NonNull Reader reader) throws XmlPullParserException, IOException {
KXmlParser parser = new KXmlParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
parser.setInput(reader);
while (true) {
int event = parser.next();
if (event == XmlPullParser.START_TAG) {
for (int i = 0; i < parser.getAttributeCount(); i++) {
if (parser.getAttributeName(i).startsWith(ATTR_LAYOUT_RESOURCE_PREFIX)) {
String prefix = parser.getAttributePrefix(i);
if (prefix != null && !prefix.isEmpty() && ANDROID_URI.equals(parser.getNamespace(prefix))) {
return true;
}
}
}
return false;
} else if (event == XmlPullParser.END_DOCUMENT) {
return false;
}
}
}
use of com.android.annotations.VisibleForTesting in project kotlin by JetBrains.
the class StringFormatDetector method getFormatArgumentType.
//$NON-NLS-1$
/** Given a format string returns the format type of the given argument */
@VisibleForTesting
@Nullable
static String getFormatArgumentType(String s, int argument) {
Matcher matcher = FORMAT.matcher(s);
int index = 0;
int prevIndex = 0;
int nextNumber = 1;
while (true) {
if (matcher.find(index)) {
String value = matcher.group(6);
if ("%".equals(value) || "n".equals(value)) {
//$NON-NLS-1$ //$NON-NLS-2$
index = matcher.end();
continue;
}
int matchStart = matcher.start();
// Make sure this is not an escaped '%'
for (; prevIndex < matchStart; prevIndex++) {
char c = s.charAt(prevIndex);
if (c == '\\') {
prevIndex++;
}
}
if (prevIndex > matchStart) {
// We're in an escape, ignore this result
index = prevIndex;
continue;
}
// Shouldn't throw a number format exception since we've already
// matched the pattern in the regexp
int number;
String numberString = matcher.group(1);
if (numberString != null) {
// Strip off trailing $
numberString = numberString.substring(0, numberString.length() - 1);
number = Integer.parseInt(numberString);
nextNumber = number + 1;
} else {
number = nextNumber++;
}
if (number == argument) {
return matcher.group(6);
}
index = matcher.end();
} else {
break;
}
}
return null;
}
use of com.android.annotations.VisibleForTesting in project android by JetBrains.
the class NewProjectImportGradleSyncListener method createTopLevelModule.
@VisibleForTesting
public static void createTopLevelModule(@NotNull Project project) {
ModuleManager moduleManager = ModuleManager.getInstance(project);
File projectRootDir = getBaseDirPath(project);
VirtualFile contentRoot = findFileByIoFile(projectRootDir, true);
if (contentRoot != null) {
File moduleFile = new File(projectRootDir, projectRootDir.getName() + ".iml");
Module module = moduleManager.newModule(moduleFile.getPath(), JAVA.getId());
// This prevents the balloon "Unsupported Modules detected".
ExternalSystemModulePropertyManager.getInstance(module).setExternalId(GRADLE_SYSTEM_ID);
ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
model.addContentEntry(contentRoot);
if (IdeInfo.getInstance().isAndroidStudio()) {
// If sync fails, make sure that the project has a JDK, otherwise Groovy indices won't work (a common scenario where
// users will update build.gradle files to fix Gradle sync.)
// See: https://code.google.com/p/android/issues/detail?id=194621
Sdk jdk = IdeSdks.getInstance().getJdk();
if (jdk != null) {
model.setSdk(jdk);
}
}
model.commit();
FacetManager facetManager = FacetManager.getInstance(module);
ModifiableFacetModel facetModel = facetManager.createModifiableModel();
try {
GradleFacet gradleFacet = GradleFacet.getInstance(module);
if (gradleFacet == null) {
// Add "gradle" facet, to avoid balloons about unsupported compilation of modules.
gradleFacet = facetManager.createFacet(GradleFacet.getFacetType(), GradleFacet.getFacetName(), null);
facetModel.addFacet(gradleFacet);
}
gradleFacet.getConfiguration().GRADLE_PROJECT_PATH = GRADLE_PATH_SEPARATOR;
// Add "android" facet to avoid the balloon "Android Framework detected".
AndroidFacet androidFacet = AndroidFacet.getInstance(module);
if (androidFacet == null) {
androidFacet = facetManager.createFacet(AndroidFacet.getFacetType(), AndroidFacet.NAME, null);
facetModel.addFacet(androidFacet);
}
// This is what actually stops Studio from showing the balloon.
androidFacet.getProperties().ALLOW_USER_CONFIGURATION = false;
} finally {
facetModel.commit();
}
}
}
use of com.android.annotations.VisibleForTesting in project android by JetBrains.
the class RenderErrorContributor method performClick.
@VisibleForTesting
public void performClick(@NotNull RenderResult result, @NotNull String url) {
Module module = result.getModule();
PsiFile file = result.getFile();
myLinkManager.handleUrl(url, module, file, myDataContext, result);
}
Aggregations