Search in sources :

Example 36 with Nullable

use of org.jetbrains.annotations.Nullable in project scss-lint-plugin by idok.

the class ThreadLocalActualFile method createFile.

@Nullable
private File createFile() {
    //        File retFile = new File(file.getParent().getPath(), file.getNameWithoutExtension() + "_jscs_tmp." + file.getExtension());
    File retFile = createFileAsSibling();
    if (retFile != null) {
        return retFile;
    }
    // try to create a temp file in temp folder
    File dir = getOrCreateTempDir();
    if (dir == null) {
        return null;
    }
    File file = new File(dir, this.baseName + this.extension);
    boolean created = false;
    if (!file.exists()) {
        try {
            created = file.createNewFile();
        } catch (IOException ignored) {
            LOG.warn("Can not create " + file.getAbsolutePath());
        }
    }
    if (!created) {
        try {
            file = FileUtil.createTempFile(dir, this.baseName, this.extension);
        } catch (IOException e) {
            LOG.warn("Can not create temp file", e);
            return null;
        }
    }
    file.deleteOnExit();
    return file;
}
Also used : IOException(java.io.IOException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Example 37 with Nullable

use of org.jetbrains.annotations.Nullable in project cassandra-mesos-deprecated by mesosphere.

the class SeedManagerTest method before.

@Before
public void before() {
    InMemoryState state = new InMemoryState();
    PersistedCassandraFrameworkConfiguration config = new PersistedCassandraFrameworkConfiguration(state, "name", 60, 30, "2.1", 0.5, 1024, 1024, 512, 1, 1, "role", "./backup", ".", false, true, "RACK1", "DC1", Arrays.asList(ExternalDc.newBuilder().setName("dc").setUrl("http://dc").build()), "name");
    seedManager = new SeedManager(config, new ObjectMapper(), new SystemClock()) {

        @Override
        @Nullable
        protected JsonNode fetchJson(@NotNull final String url) {
            try {
                return new ObjectMapper().readTree(jsonResponse);
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }
    };
}
Also used : SystemClock(io.mesosphere.mesos.util.SystemClock) InMemoryState(org.apache.mesos.state.InMemoryState) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Nullable(org.jetbrains.annotations.Nullable) Before(org.junit.Before)

Example 38 with Nullable

use of org.jetbrains.annotations.Nullable in project android-parcelable-intellij-plugin by mcharmas.

the class GenerateDialog method createSouthPanel.

@Nullable
@Override
protected JComponent createSouthPanel() {
    JComponent southPanel = super.createSouthPanel();
    if (showCheckbox && southPanel != null) {
        final VerticalBox combinedView = new VerticalBox();
        combinedView.add(includeSubclasses);
        combinedView.add(southPanel);
        return combinedView;
    } else {
        return southPanel;
    }
}
Also used : VerticalBox(com.intellij.ui.components.panels.VerticalBox) JComponent(javax.swing.JComponent) Nullable(org.jetbrains.annotations.Nullable)

Example 39 with Nullable

use of org.jetbrains.annotations.Nullable in project languagetool by languagetool-org.

the class PatternRuleQueryBuilder method getPosQueryOrNull.

@Nullable
private BooleanClause getPosQueryOrNull(PatternToken patternToken, String pos) throws UnsupportedPatternRuleException {
    if (pos == null || pos.isEmpty()) {
        return null;
    }
    Query posQuery;
    Term posQueryTerm;
    if (patternToken.getPOSNegation() || patternToken.getMinOccurrence() == 0) {
        // we need to ignore this - negation, if any, must happen at the same position
        return null;
    } else if (patternToken.isPOStagRegularExpression()) {
        posQueryTerm = getQueryTerm(patternToken, POS_PREFIX + "(", pos, ")");
        posQuery = getRegexQuery(posQueryTerm, pos, patternToken);
    } else {
        posQueryTerm = getQueryTerm(patternToken, POS_PREFIX, pos, "");
        posQuery = new TermQuery(posQueryTerm);
    }
    return new BooleanClause(posQuery, BooleanClause.Occur.MUST);
}
Also used : SpanTermQuery(org.apache.lucene.search.spans.SpanTermQuery) SpanNearQuery(org.apache.lucene.search.spans.SpanNearQuery) SpanTermQuery(org.apache.lucene.search.spans.SpanTermQuery) SpanQuery(org.apache.lucene.search.spans.SpanQuery) Term(org.apache.lucene.index.Term) Nullable(org.jetbrains.annotations.Nullable)

Example 40 with Nullable

use of org.jetbrains.annotations.Nullable in project languagetool by languagetool-org.

the class JLanguageTool method getBuildDate.

/**
   * Returns the build date or {@code null} if not run from JAR.
   */
@Nullable
private static String getBuildDate() {
    try {
        URL res = JLanguageTool.class.getResource(JLanguageTool.class.getSimpleName() + ".class");
        if (res == null) {
            // this will happen on Android, see http://stackoverflow.com/questions/15371274/
            return null;
        }
        Object connObj = res.openConnection();
        if (connObj instanceof JarURLConnection) {
            JarURLConnection conn = (JarURLConnection) connObj;
            Manifest manifest = conn.getManifest();
            return manifest.getMainAttributes().getValue("Implementation-Date");
        } else {
            return null;
        }
    } catch (IOException e) {
        throw new RuntimeException("Could not get build date from JAR", e);
    }
}
Also used : JarURLConnection(java.net.JarURLConnection) IOException(java.io.IOException) Manifest(java.util.jar.Manifest) URL(java.net.URL) 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