use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.
the class ResourceBundleManager method closeResourceBundleEditors.
private static void closeResourceBundleEditors(@NotNull ResourceBundle resourceBundle) {
final FileEditorManager fileEditorManager = FileEditorManager.getInstance(resourceBundle.getProject());
fileEditorManager.closeFile(new ResourceBundleAsVirtualFile(resourceBundle));
for (final PropertiesFile propertiesFile : resourceBundle.getPropertiesFiles()) {
fileEditorManager.closeFile(propertiesFile.getVirtualFile());
}
}
use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.
the class ResourceBundleFileStructureViewElement method getPropertiesMap.
public static MultiMap<String, IProperty> getPropertiesMap(ResourceBundle resourceBundle, boolean onlyIncomplete) {
List<PropertiesFile> propertiesFiles = resourceBundle.getPropertiesFiles();
final MultiMap<String, IProperty> propertyNames;
if (onlyIncomplete) {
propertyNames = getChildrenIdShowOnlyIncomplete(resourceBundle);
} else {
propertyNames = MultiMap.createLinked();
for (PropertiesFile propertiesFile : propertiesFiles) {
List<IProperty> properties = propertiesFile.getProperties();
for (IProperty property : properties) {
String name = property.getKey();
propertyNames.putValue(name, property);
}
}
}
return propertyNames;
}
use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.
the class EnterInPropertiesFileHandler method preprocessEnter.
@Override
public Result preprocessEnter(@NotNull final PsiFile file, @NotNull final Editor editor, @NotNull final Ref<Integer> caretOffsetRef, @NotNull final Ref<Integer> caretAdvance, @NotNull final DataContext dataContext, final EditorActionHandler originalHandler) {
if (file instanceof PropertiesFile) {
int caretOffset = caretOffsetRef.get().intValue();
Document document = editor.getDocument();
PsiDocumentManager.getInstance(file.getProject()).commitDocument(document);
PsiElement psiAtOffset = file.findElementAt(caretOffset);
handleEnterInPropertiesFile(editor, document, psiAtOffset, caretOffset);
return Result.Stop;
}
return Result.Continue;
}
use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.
the class ResourcesFavoriteNodeProvider method elementContainsFile.
@Override
public boolean elementContainsFile(final Object element, final VirtualFile vFile) {
if (element instanceof ResourceBundle) {
ResourceBundle bundle = (ResourceBundle) element;
final List<PropertiesFile> propertiesFiles = bundle.getPropertiesFiles();
for (PropertiesFile file : propertiesFiles) {
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null)
continue;
if (vFile.getPath().equals(virtualFile.getPath())) {
return true;
}
}
}
return false;
}
use of com.intellij.lang.properties.psi.PropertiesFile in project intellij-community by JetBrains.
the class PropertiesUtil method getParent.
/**
* messages_en.properties is a parent of the messages_en_US.properties
*/
@Nullable
public static PropertiesFile getParent(@NotNull PropertiesFile file, @NotNull Collection<PropertiesFile> candidates) {
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null)
return null;
String name = virtualFile.getNameWithoutExtension();
String[] parts = name.split("_");
if (parts.length == 1)
return null;
List<String> partsList = Arrays.asList(parts);
for (int i = parts.length - 1; i >= 1; i--) {
String parentName = StringUtil.join(partsList.subList(0, i), "_") + "." + virtualFile.getExtension();
for (PropertiesFile candidate : candidates) {
if (parentName.equals(candidate.getName()))
return candidate;
}
}
return null;
}
Aggregations