use of org.jetbrains.annotations.Nullable in project idea-handlebars by dmarcotte.
the class HbStructureViewFactory method getStructureViewBuilder.
@Nullable
@Override
public StructureViewBuilder getStructureViewBuilder(final PsiFile psiFile) {
return new TemplateLanguageStructureViewBuilder(psiFile) {
@Override
protected StructureViewComposite.StructureViewDescriptor createMainView(FileEditor fileEditor, PsiFile mainFile) {
if (!psiFile.isValid())
return null;
final StructureViewBuilder builder = new TreeBasedStructureViewBuilder() {
@NotNull
@Override
public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
return new HbStructureViewModel((HbPsiFile) psiFile, editor);
}
};
StructureView structureView = builder.createStructureView(fileEditor, psiFile.getProject());
return new StructureViewComposite.StructureViewDescriptor(HbLanguage.INSTANCE.getDisplayName(), structureView, HbFileType.INSTANCE.getIcon());
}
};
}
use of org.jetbrains.annotations.Nullable in project buck by facebook.
the class BuckFormattingModelBuilder method getRangeAffectingIndent.
@Nullable
@Override
public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) {
final PsiElement element = elementAtOffset.getPsi();
final PsiElement container = element.getParent();
return container != null ? container.getTextRange() : null;
}
use of org.jetbrains.annotations.Nullable in project buck by facebook.
the class TestExecutionState method execute.
@Nullable
@Override
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
final ProcessHandler processHandler = runBuildCommand(executor);
final TestConsoleProperties properties = new BuckTestConsoleProperties(processHandler, mProject, mConfiguration, "Buck test", executor);
final ConsoleView console = SMTestRunnerConnectionUtil.createAndAttachConsole("buck test", processHandler, properties);
return new DefaultExecutionResult(console, processHandler, AnAction.EMPTY_ARRAY);
}
use of org.jetbrains.annotations.Nullable in project android-selector-intellij-plugin by importre.
the class ColorIcon method getColor.
@Nullable
private JBColor getColor() {
String regex = "((?:[0-9a-fA-F]{2})?)" + "([0-9a-fA-F]{2})" + "([0-9a-fA-F]{2})" + "([0-9a-fA-F]{2})";
Pattern p = Pattern.compile(regex);
try {
if (color == null) {
return null;
}
Matcher m = p.matcher(color);
if (m.find()) {
int r = Integer.parseInt(m.group(2), 16);
int g = Integer.parseInt(m.group(3), 16);
int b = Integer.parseInt(m.group(4), 16);
if (m.group(1).isEmpty()) {
return new JBColor(new Color(r, g, b), new Color(r, g, b));
} else {
int a = Integer.parseInt(m.group(1), 16);
return new JBColor(new Color(r, g, b, a), new Color(r, g, b, a));
}
}
} catch (Exception ignore) {
}
return null;
}
use of org.jetbrains.annotations.Nullable in project scss-lint-plugin by idok.
the class ActualFile method getOrCreateActualFile.
@Nullable
public static ActualFile getOrCreateActualFile(@NotNull Key<ThreadLocalActualFile> key, @NotNull VirtualFile virtualFile, @Nullable String content) {
FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
if (!fileDocumentManager.isFileModified(virtualFile)) {
File file = new File(virtualFile.getPath());
if (file.isFile()) {
return new ActualFile(file);
}
}
ThreadLocalActualFile threadLocal = key.get(virtualFile);
if (threadLocal == null) {
threadLocal = virtualFile.putUserDataIfAbsent(key, new ThreadLocalActualFile(virtualFile));
}
File file = threadLocal.getOrCreateFile();
if (file == null) {
return null;
}
if (content == null) {
Document document = fileDocumentManager.getDocument(virtualFile);
if (document != null) {
content = document.getText();
}
}
if (content == null) {
return null;
}
try {
FileUtil.writeToFile(file, content);
return new ActualFile(new File(virtualFile.getPath()), file);
} catch (IOException e) {
LOG.warn("Can not write to " + file.getAbsolutePath(), e);
}
return null;
}
Aggregations