Search in sources :

Example 51 with Nullable

use of com.android.annotations.Nullable in project android by JetBrains.

the class StudioEmbeddedRenderTarget method getEmbeddedLayoutLibPath.

/**
   * Returns the URL for the embedded layoutlib distribution.
   */
@Nullable
private static String getEmbeddedLayoutLibPath() {
    String homePath = FileUtil.toSystemIndependentName(PathManager.getHomePath());
    StringBuilder notFoundPaths = new StringBuilder();
    for (String path : EMBEDDED_PATHS) {
        String jarPath = homePath + path;
        VirtualFile root = LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(jarPath));
        if (root != null) {
            File rootFile = VfsUtilCore.virtualToIoFile(root);
            if (rootFile.exists() && rootFile.isDirectory()) {
                LOG.debug("Embedded layoutlib found at " + jarPath);
                return rootFile.getAbsolutePath() + File.separator;
            }
        } else {
            notFoundPaths.append(jarPath).append('\n');
        }
    }
    LOG.error("Unable to find embedded layoutlib in paths:\n" + notFoundPaths.toString());
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Nullable(com.android.annotations.Nullable)

Example 52 with Nullable

use of com.android.annotations.Nullable in project android by JetBrains.

the class AndroidPluginGeneration method find.

@Nullable
public static AndroidPluginGeneration find(@NotNull Module module) {
    AndroidModuleModel gradleModel = AndroidModuleModel.get(module);
    if (gradleModel != null) {
        try {
            // only true for experimental plugin 0.6.0-betaX (or whenever the getPluginGeneration() was added) or later.
            return gradleModel.getAndroidProject().getPluginGeneration() == GENERATION_COMPONENT ? COMPONENT : ORIGINAL;
        } catch (UnsupportedMethodException t) {
        // happens for 2.0.0-alphaX or earlier stable version plugins and 0.6.0-alphax or earlier experimental plugin versions.
        }
    }
    // Now look at the applied plugins in the build.gradle file.
    GradleBuildModel buildModel = GradleBuildModel.get(module);
    if (buildModel != null) {
        List<String> appliedPlugins = getValues(buildModel.appliedPlugins());
        for (AndroidPluginGeneration generation : ourValues) {
            if (appliedPlugins.contains(generation.getApplicationPluginId()) || appliedPlugins.contains(generation.getLibraryPluginId())) {
                return generation;
            }
        }
    }
    return null;
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) UnsupportedMethodException(org.gradle.tooling.model.UnsupportedMethodException) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) Nullable(com.android.annotations.Nullable)

Example 53 with Nullable

use of com.android.annotations.Nullable in project android by JetBrains.

the class NlPropertyInspectorFixture method findProperty.

@Nullable
public NlPropertyFixture findProperty(final String name) {
    JBLabel label = waitUntilFound(robot(), myPanel, new GenericTypeMatcher<JBLabel>(JBLabel.class) {

        @Override
        protected boolean isMatching(@NotNull JBLabel label) {
            return name.equals(label.getText()) && label.getIcon() == null;
        }
    });
    Container parent = label.getParent();
    Component[] components = parent.getComponents();
    for (int i = 0; i < components.length; i++) {
        if (label == components[i]) {
            return new NlPropertyFixture(robot(), (JPanel) components[i + 1]);
        }
    }
    return null;
}
Also used : JBLabel(com.intellij.ui.components.JBLabel) Nullable(com.android.annotations.Nullable)

Example 54 with Nullable

use of com.android.annotations.Nullable in project android by JetBrains.

the class GradleImport method resolvePathVariable.

@Nullable
File resolvePathVariable(@Nullable EclipseProject fromProject, @NonNull String name, boolean record) throws IOException {
    File file = myPathMap.get(name);
    if (file != null) {
        return file;
    }
    if (fromProject != null && myWorkspaceLocation == null) {
        guessWorkspace(fromProject.getDir());
    }
    String value = null;
    Properties properties = getJdtSettingsProperties(false);
    if (properties != null) {
        value = properties.getProperty("org.eclipse.jdt.core.classpathVariable." + name);
    }
    if (value == null) {
        properties = getPathSettingsProperties(false);
        if (properties != null) {
            value = properties.getProperty("pathvariable." + name);
        }
    }
    if (value == null) {
        if (record) {
            myPathMap.put(name, null);
        }
        return null;
    }
    file = new File(value.replace('/', separatorChar));
    return file;
}
Also used : File(java.io.File) Nullable(com.android.annotations.Nullable)

Example 55 with Nullable

use of com.android.annotations.Nullable in project android by JetBrains.

the class ImportModule method getLatestVersion.

@Nullable
public GradleCoordinate getLatestVersion(String artifact) {
    int compileVersion = GradleImport.CURRENT_COMPILE_VERSION;
    AndroidVersion version = getCompileSdkVersion();
    if (version != AndroidVersion.DEFAULT) {
        compileVersion = version.getFeatureLevel();
    }
    // from version 18 (earliest version where we have all the libs in the m2 repository)
    if (compileVersion < 18) {
        compileVersion = 18;
    }
    String compileVersionString = Integer.toString(compileVersion);
    if (myImporter.getSdkLocation() != null) {
        @SuppressWarnings("UnnecessaryLocalVariable") String filter = compileVersionString;
        GradleCoordinate max = SdkMavenRepository.ANDROID.getHighestInstalledVersion(myImporter.getSdkLocation(), SUPPORT_GROUP_ID, artifact, filter, true);
        if (max != null) {
            return max;
        }
    }
    String coordinate = SUPPORT_GROUP_ID + ':' + artifact + ':' + compileVersionString + ".+";
    return GradleCoordinate.parseCoordinateString(coordinate);
}
Also used : GradleCoordinate(com.android.ide.common.repository.GradleCoordinate) AndroidVersion(com.android.sdklib.AndroidVersion) Nullable(com.android.annotations.Nullable)

Aggregations

Nullable (com.android.annotations.Nullable)83 File (java.io.File)21 IOException (java.io.IOException)9 ResourceType (com.android.resources.ResourceType)8 PsiClass (com.intellij.psi.PsiClass)7 PsiElement (com.intellij.psi.PsiElement)7 PsiReferenceExpression (com.intellij.psi.PsiReferenceExpression)7 ResourceUrl (com.android.ide.common.resources.ResourceUrl)6 PsiAssignmentExpression (com.intellij.psi.PsiAssignmentExpression)6 PsiDeclarationStatement (com.intellij.psi.PsiDeclarationStatement)6 PsiExpression (com.intellij.psi.PsiExpression)6 PsiExpressionStatement (com.intellij.psi.PsiExpressionStatement)6 PsiMethod (com.intellij.psi.PsiMethod)6 PsiStatement (com.intellij.psi.PsiStatement)6 ArrayList (java.util.ArrayList)6 PsiField (com.intellij.psi.PsiField)5 PsiFile (com.intellij.psi.PsiFile)4 Node (lombok.ast.Node)4 UReferenceExpression (org.jetbrains.uast.UReferenceExpression)4 AbstractResourceRepository (com.android.ide.common.res2.AbstractResourceRepository)3