Search in sources :

Example 76 with Nullable

use of org.jetbrains.annotations.Nullable in project intellij-community by JetBrains.

the class GrNewConsoleAction method getModule.

@Nullable
protected Module getModule(AnActionEvent e) {
    final Project project = e.getProject();
    if (project == null)
        return null;
    final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext());
    if (file != null) {
        final Module moduleForFile = ModuleUtilCore.findModuleForFile(file, project);
        if (moduleForFile != null)
            return moduleForFile;
    }
    final List<Module> modules = ModuleChooserUtil.filterGroovyCompatibleModules(Arrays.asList(ModuleManager.getInstance(project).getModules()), APPLICABLE_MODULE);
    return modules.isEmpty() ? null : modules.get(0);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 77 with Nullable

use of org.jetbrains.annotations.Nullable in project intellij-community by JetBrains.

the class CreateParameterForFieldIntention method findFieldCandidates.

@Nullable
private static List<GrField> findFieldCandidates(PsiElement element) {
    final GrMethod constructor = PsiTreeUtil.getParentOfType(element, GrMethod.class);
    if (constructor == null || !constructor.isConstructor())
        return null;
    if (constructor.getBlock() == null)
        return null;
    if (PsiTreeUtil.isAncestor(constructor.getBlock(), element, false)) {
        return null;
    }
    final PsiClass clazz = constructor.getContainingClass();
    if (!(clazz instanceof GrTypeDefinition))
        return null;
    return findCandidatesCached(constructor, (GrTypeDefinition) clazz);
}
Also used : GrTypeDefinition(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition) GrMethod(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod) Nullable(org.jetbrains.annotations.Nullable)

Example 78 with Nullable

use of org.jetbrains.annotations.Nullable in project intellij-community by JetBrains.

the class HgUtil method getRepositoryForFile.

@Nullable
public static HgRepository getRepositoryForFile(@NotNull Project project, @Nullable VirtualFile file) {
    if (file == null || project.isDisposed())
        return null;
    HgRepositoryManager repositoryManager = getRepositoryManager(project);
    VirtualFile root = getHgRootOrNull(project, file);
    return repositoryManager.getRepositoryForRoot(root);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) AbstractVcsVirtualFile(com.intellij.openapi.vcs.vfs.AbstractVcsVirtualFile) HgRepositoryManager(org.zmlx.hg4idea.repo.HgRepositoryManager) Nullable(org.jetbrains.annotations.Nullable)

Example 79 with Nullable

use of org.jetbrains.annotations.Nullable in project intellij-community by JetBrains.

the class MavenAnnotationProcessorConfigurer method getRelativeAnnotationProcessorDirectory.

@Nullable
private static String getRelativeAnnotationProcessorDirectory(MavenProject mavenProject, boolean isTest) {
    String annotationProcessorDirectory = mavenProject.getAnnotationProcessorDirectory(isTest);
    File annotationProcessorDirectoryFile = new File(annotationProcessorDirectory);
    if (!annotationProcessorDirectoryFile.isAbsolute()) {
        return annotationProcessorDirectory;
    }
    String absoluteProjectDirectory = mavenProject.getDirectory();
    return FileUtil.getRelativePath(new File(absoluteProjectDirectory), annotationProcessorDirectoryFile);
}
Also used : File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Example 80 with Nullable

use of org.jetbrains.annotations.Nullable in project intellij-community by JetBrains.

the class MavenProjectModelModifier method addModuleDependency.

@Nullable
@Override
public Promise<Void> addModuleDependency(@NotNull Module from, @NotNull Module to, @NotNull final DependencyScope scope) {
    final MavenProject toProject = myProjectsManager.findProject(to);
    if (toProject == null)
        return null;
    MavenId mavenId = toProject.getMavenId();
    return addDependency(Collections.singletonList(from), mavenId, scope);
}
Also used : MavenId(org.jetbrains.idea.maven.model.MavenId) MavenProject(org.jetbrains.idea.maven.project.MavenProject) 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