Search in sources :

Example 31 with Nullable

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());
        }
    };
}
Also used : TreeBasedStructureViewBuilder(com.intellij.ide.structureView.TreeBasedStructureViewBuilder) TemplateLanguageStructureViewBuilder(com.intellij.ide.structureView.impl.TemplateLanguageStructureViewBuilder) StructureViewBuilder(com.intellij.ide.structureView.StructureViewBuilder) FileEditor(com.intellij.openapi.fileEditor.FileEditor) StructureView(com.intellij.ide.structureView.StructureView) TreeBasedStructureViewBuilder(com.intellij.ide.structureView.TreeBasedStructureViewBuilder) HbPsiFile(com.dmarcotte.handlebars.psi.HbPsiFile) PsiFile(com.intellij.psi.PsiFile) TemplateLanguageStructureViewBuilder(com.intellij.ide.structureView.impl.TemplateLanguageStructureViewBuilder) Editor(com.intellij.openapi.editor.Editor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) Nullable(org.jetbrains.annotations.Nullable) StructureViewComposite(com.intellij.ide.structureView.impl.StructureViewComposite) Nullable(org.jetbrains.annotations.Nullable)

Example 32 with Nullable

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;
}
Also used : PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Example 33 with Nullable

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);
}
Also used : DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) ConsoleView(com.intellij.execution.ui.ConsoleView) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) ProcessHandler(com.intellij.execution.process.ProcessHandler) TestConsoleProperties(com.intellij.execution.testframework.TestConsoleProperties) Nullable(org.jetbrains.annotations.Nullable)

Example 34 with Nullable

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;
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) JBColor(com.intellij.ui.JBColor) JBColor(com.intellij.ui.JBColor) Nullable(org.jetbrains.annotations.Nullable)

Example 35 with Nullable

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;
}
Also used : FileDocumentManager(com.intellij.openapi.fileEditor.FileDocumentManager) IOException(java.io.IOException) Document(com.intellij.openapi.editor.Document) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Nullable (org.jetbrains.annotations.Nullable)4694 VirtualFile (com.intellij.openapi.vfs.VirtualFile)812 PsiElement (com.intellij.psi.PsiElement)485 File (java.io.File)405 Project (com.intellij.openapi.project.Project)396 PsiFile (com.intellij.psi.PsiFile)320 NotNull (org.jetbrains.annotations.NotNull)259 IOException (java.io.IOException)247 Module (com.intellij.openapi.module.Module)227 ArrayList (java.util.ArrayList)178 TextRange (com.intellij.openapi.util.TextRange)156 Document (com.intellij.openapi.editor.Document)124 List (java.util.List)116 ASTNode (com.intellij.lang.ASTNode)105 IElementType (com.intellij.psi.tree.IElementType)103 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)102 XmlTag (com.intellij.psi.xml.XmlTag)96 Editor (com.intellij.openapi.editor.Editor)94 Element (org.jdom.Element)93 XmlFile (com.intellij.psi.xml.XmlFile)78