use of com.perl5.lang.mason2.idea.configuration.MasonSettings in project Perl5-IDEA by Camelcade.
the class MasonVirtualFileListener method beforePropertyChange.
/**
* Fired before the change of a name or writable status of a file is processed.
*
* @param event the event object containing information about the change.
*/
@Override
public void beforePropertyChange(@NotNull VirtualFilePropertyEvent event) {
if (!event.getPropertyName().equals(VirtualFile.PROP_NAME)) {
return;
}
MasonSettings masonSettings = MasonSettings.getInstance(getProject());
List<VirtualFile> componentsRoots = masonSettings.getComponentsRoots();
if (componentsRoots.isEmpty()) {
return;
}
VirtualFile renamedFile = event.getFile();
if (renamedFile.isDirectory()) {
if (// contains component root
containsAtLeastOneFile(renamedFile, componentsRoots)) {
renamedFile.putUserData(FORCE_REINDEX, true);
}
}
}
use of com.perl5.lang.mason2.idea.configuration.MasonSettings in project Perl5-IDEA by Camelcade.
the class MasonComponentsCompletionProvider method addCompletions.
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition();
PsiElement parent = position.getParent();
if (parent instanceof PerlString) {
Project project = position.getProject();
MasonSettings masonSettings = MasonSettings.getInstance(project);
String fullPrefix = ElementManipulators.getValueText(parent).replace(CompletionInitializationContext.DUMMY_IDENTIFIER, "").replace(CompletionInitializationContext.DUMMY_IDENTIFIER_TRIMMED, "");
result = result.withPrefixMatcher(new PlainPrefixMatcher(fullPrefix));
final CompletionResultSet finalResultSet = result;
PsiFile psiFile = position.getContainingFile();
if (psiFile instanceof MasonFileImpl) {
final VirtualFile containingFile = MasonCoreUtil.getContainingVirtualFile(psiFile);
VirtualFile containingDir;
if (containingFile != null && (containingDir = containingFile.getParent()) != null) {
VfsUtil.processFilesRecursively(containingDir, new MasonRootsProcessor(containingDir) {
@Override
public boolean process(VirtualFile virtualFile) {
FileType fileType = virtualFile.getFileType();
if (fileType instanceof MasonPurePerlComponentFileType && !containingFile.equals(virtualFile)) {
String relativePath = VfsUtil.getRelativePath(virtualFile, getRoot());
if (StringUtil.isNotEmpty(relativePath)) {
finalResultSet.addElement(LookupElementBuilder.create(relativePath).withIcon(fileType.getIcon()));
}
}
return true;
}
});
}
}
for (VirtualFile componentRoot : masonSettings.getComponentsRoots()) {
VfsUtil.processFilesRecursively(componentRoot, new MasonRootsProcessor(componentRoot) {
@Override
public boolean process(VirtualFile virtualFile) {
FileType fileType = virtualFile.getFileType();
if (fileType instanceof MasonPurePerlComponentFileType) {
String relativePath = VfsUtil.getRelativePath(virtualFile, getRoot());
if (StringUtil.isNotEmpty(relativePath)) {
finalResultSet.addElement(LookupElementBuilder.create("/" + relativePath).withIcon(fileType.getIcon()));
}
}
return true;
}
});
}
}
}
Aggregations