use of com.perl5.lang.mason2.psi.impl.MasonFileImpl in project Perl5-IDEA by Camelcade.
the class MasonPathsNotification method createNotificationPanel.
@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull final VirtualFile file, @NotNull FileEditor fileEditor) {
if (file.getFileType() instanceof MasonPurePerlComponentFileType) {
String message = null;
if (MasonSettings.getInstance(myProject).getComponentsRoots().isEmpty()) {
message = "Mason2 components roots are not configured";
} else {
PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
if (psiFile instanceof MasonFileImpl && ((MasonFileImpl) psiFile).getComponentRoot() == null) {
message = "Component is not under one of configured roots";
}
}
if (message != null) {
EditorNotificationPanel panel = new EditorNotificationPanel();
panel.setText(message);
panel.createActionLabel("Configure", () -> Perl5SettingsConfigurable.open(myProject));
return panel;
}
}
return null;
}
use of com.perl5.lang.mason2.psi.impl.MasonFileImpl 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