use of com.intellij.lang.properties.psi.PropertiesFile in project android by JetBrains.
the class GradleImplicitPropertyUsageProviderTest method testGradleWrapper.
public void testGradleWrapper() {
VirtualFile vFile = myFixture.copyFileToProject("projects/projectWithAppandLib/gradle/wrapper/gradle-wrapper.properties", "gradle/wrapper/gradle-wrapper.properties");
PsiFile file = PsiManager.getInstance(getProject()).findFile(vFile);
assertNotNull(file);
PropertiesFile propertiesFile = (PropertiesFile) file;
GradleImplicitPropertyUsageProvider provider = new GradleImplicitPropertyUsageProvider();
for (IProperty property : propertiesFile.getProperties()) {
// All properties are considered used in this file
String name = property.getName();
assertTrue(name, provider.isUsed((Property) property));
}
}
use of com.intellij.lang.properties.psi.PropertiesFile in project android by JetBrains.
the class GradleImplicitPropertyUsageProviderTest method testLocalProperties.
public void testLocalProperties() {
VirtualFile vFile = myFixture.copyFileToProject("test.properties", "local.properties");
PsiFile file = PsiManager.getInstance(getProject()).findFile(vFile);
assertNotNull(file);
PropertiesFile propertiesFile = (PropertiesFile) file;
GradleImplicitPropertyUsageProvider provider = new GradleImplicitPropertyUsageProvider();
for (IProperty property : propertiesFile.getProperties()) {
Property p = (Property) property;
// Only but the property with "unused" in its name are considered used
String name = property.getName();
if (name.contains("unused")) {
assertFalse(name, provider.isUsed(p));
} else {
assertTrue(name, provider.isUsed(p));
}
}
}
use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.
the class DGMMemberContributor method doCollectExtensions.
private static void doCollectExtensions(@NotNull Project project, @NotNull GlobalSearchScope resolveScope, List<String> instanceClasses, List<String> staticClasses) {
PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage("META-INF.services");
if (aPackage == null)
return;
for (PsiDirectory directory : aPackage.getDirectories(resolveScope)) {
PsiFile file = directory.findFile(DGMUtil.ORG_CODEHAUS_GROOVY_RUNTIME_EXTENSION_MODULE);
if (file instanceof PropertiesFile) {
IProperty inst = ((PropertiesFile) file).findPropertyByKey("extensionClasses");
IProperty stat = ((PropertiesFile) file).findPropertyByKey("staticExtensionClasses");
if (inst != null)
collectClasses(inst, instanceClasses);
if (stat != null)
collectClasses(stat, staticClasses);
}
}
}
use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.
the class FindManagerTest method searchProperty.
private void searchProperty(String query) {
FindModel findModel = new FindModel();
findModel.setStringToFind(query);
findModel.setWholeWordsOnly(true);
findModel.setFromCursor(false);
findModel.setGlobal(true);
findModel.setMultipleFiles(true);
findModel.setProjectScope(true);
findModel.setDirectoryName(mySourceDirs[0].getPath());
findModel.setWithSubdirectories(true);
List<UsageInfo> usages = findUsages(findModel);
assertEquals(2, usages.size());
if (!(usages.get(0).getFile() instanceof PsiJavaFile)) {
Collections.swap(usages, 0, 1);
}
PsiElement refElement = getParentFromUsage(usages.get(0));
assertTrue(refElement instanceof PsiLiteralExpression);
assertEquals("xx.yy", ((PsiLiteralExpression) refElement).getValue());
VirtualFile file = mySourceDirs[0].findFileByRelativePath("x/dd.properties");
assertNotNull(file);
PropertiesFile propertiesFile = (PropertiesFile) PsiManager.getInstance(myProject).findFile(file);
assertNotNull(propertiesFile);
refElement = getParentFromUsage(usages.get(1));
assertTrue(refElement instanceof IProperty);
assertSame(propertiesFile.findPropertyByKey("xx.yy"), refElement);
}
use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-plugins by JetBrains.
the class LibraryManager method getResourceBundleFile.
@Nullable
public Pair<PropertiesFile, Integer> getResourceBundleFile(String locale, String bundleName, ModuleInfo moduleInfo) {
final Project project = moduleInfo.getModule().getProject();
LibrarySet librarySet = moduleInfo.getLibrarySet();
do {
PropertiesFile propertiesFile;
for (Library library : librarySet.getLibraries()) {
if (library.hasResourceBundles() && (propertiesFile = getResourceBundleFile(locale, bundleName, library, project)) != null) {
return new Pair<>(propertiesFile, librarySet.getId());
}
}
} while ((librarySet = librarySet.getParent()) != null);
// AS-273
final Sdk sdk = FlexUtils.getSdkForActiveBC(moduleInfo.getModule());
VirtualFile dir = sdk == null ? null : sdk.getHomeDirectory();
if (dir != null) {
dir = dir.findFileByRelativePath("frameworks/projects");
}
if (dir != null) {
for (String libName : new String[] { "framework", "spark", "mx", "airframework", "rpc", "advancedgrids", "charts", "textLayout" }) {
VirtualFile file = dir.findFileByRelativePath(libName + "/bundles/" + locale + "/" + bundleName + PROPERTIES_EXTENSION);
if (file != null) {
return new Pair<>(virtualFileToProperties(project, file), moduleInfo.getFlexLibrarySet().getId());
}
}
}
return null;
}
Aggregations