当前位置: 首页>>代码示例>>Java>>正文


Java AndroidFacet.getInstance方法代码示例

本文整理汇总了Java中org.jetbrains.android.facet.AndroidFacet.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java AndroidFacet.getInstance方法的具体用法?Java AndroidFacet.getInstance怎么用?Java AndroidFacet.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jetbrains.android.facet.AndroidFacet的用法示例。


在下文中一共展示了AndroidFacet.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isAvailable

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
protected static boolean isAvailable(DataContext dataContext) {
  final Module module = LangDataKeys.MODULE.getData(dataContext);
  final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);

  if (module == null ||
      view == null ||
      view.getDirectories().length == 0 ||
      AndroidFacet.getInstance(module) == null) {
    return false;
  }
  final ProjectFileIndex projectIndex = ProjectRootManager.getInstance(module.getProject()).getFileIndex();
  final JavaDirectoryService dirService = JavaDirectoryService.getInstance();

  for (PsiDirectory dir : view.getDirectories()) {
    if (projectIndex.isUnderSourceRootOfType(dir.getVirtualFile(), JavaModuleSourceRootTypes.SOURCES) &&
        dirService.getPackage(dir) != null &&
        !dirService.getPackage(dir).getQualifiedName().isEmpty()) {
      return true;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:JavaSourceAction.java

示例2: createRunner

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@Override
public BlazeCommandRunConfigurationRunner createRunner(
    Executor executor, ExecutionEnvironment environment) throws ExecutionException {
  Project project = environment.getProject();

  Module module = getModule();
  AndroidFacet facet = module != null ? AndroidFacet.getInstance(module) : null;
  ProjectViewSet projectViewSet = ProjectViewManager.getInstance(project).getProjectViewSet();
  BlazeAndroidRunConfigurationValidationUtil.validateExecution(module, facet, projectViewSet);

  ImmutableList<String> blazeFlags =
      configState
          .getCommonState()
          .getExpandedBuildFlags(project, projectViewSet, BlazeCommandName.TEST);
  ImmutableList<String> exeFlags =
      ImmutableList.copyOf(configState.getCommonState().getExeFlagsState().getExpandedFlags());
  BlazeAndroidRunContext runContext =
      createRunContext(project, facet, environment, blazeFlags, exeFlags);

  return new BlazeAndroidRunConfigurationRunner(
      module,
      runContext,
      getCommonState().getDeployTargetManager(),
      getCommonState().getDebuggerManager(),
      configuration.getUniqueID());
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:27,代码来源:BlazeAndroidTestRunConfigurationHandler.java

示例3: getGradleModulesWithAndroidProjects

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@NotNull
private List<Module> getGradleModulesWithAndroidProjects() {
  List<Module> gradleModules = Lists.newArrayList();
  for (Module module : ModuleManager.getInstance(myProject).getModules()) {
    AndroidFacet androidFacet = AndroidFacet.getInstance(module);
    if (androidFacet != null && androidFacet.isGradleProject() && androidFacet.getIdeaAndroidProject() != null) {
      gradleModules.add(module);
    }
  }

  if (!gradleModules.isEmpty()) {
    Collections.sort(gradleModules, ModuleTypeComparator.INSTANCE);
    return gradleModules;
  }
  return Collections.emptyList();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:BuildVariantView.java

示例4: getAndroidProject

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@Nullable
public static AndroidProject getAndroidProject(@NotNull Module module) {
  AndroidFacet facet = AndroidFacet.getInstance(module);
  if (facet != null) {
    IdeaAndroidProject androidProject = facet.getIdeaAndroidProject();
    if (androidProject != null) {
      return androidProject.getDelegate();
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:GradleUtil.java

示例5: findResourcesByField

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@NotNull
public static List<PsiElement> findResourcesByField(@NotNull PsiField field) {
  final AndroidFacet facet = AndroidFacet.getInstance(field);
  return facet != null
         ? facet.getLocalResourceManager().findResourcesByField(field)
         : Collections.<PsiElement>emptyList();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:AndroidResourceUtil.java

示例6: getModule

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@Nullable
@Override
public Module getModule() {
  if (myFile != null) {
    final AndroidFacet facet = AndroidFacet.getInstance(myFile);
    if (facet != null) {
      return facet.getModule();
    }
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:AndroidLayoutPreviewToolWindowForm.java

示例7: ModulePermissions

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
public ModulePermissions(Module module) {
  myFacet = AndroidFacet.getInstance(module);
  if (myFacet != null) {
    myManifests = Lists.newArrayListWithExpectedSize(4);
    for (IdeaSourceProvider provider : IdeaSourceProvider.getAllIdeaSourceProviders(myFacet)) {
      VirtualFile manifest = provider.getManifestFile();
      if (manifest != null) {
        myManifests.add(getManifestPermissions(manifest));
      }
    }
    if (myFacet.isGradleProject() && myFacet.getIdeaAndroidProject() != null) {
      Collection<AndroidLibrary> libraries = myFacet.getIdeaAndroidProject().getSelectedVariant().getMainArtifact().getDependencies().getLibraries();
      myLibraries = Lists.newArrayList();
      for (AndroidLibrary library : libraries) {
        myLibraries.add(getLibraryPermissions(library));
      }
    }

    Module[] dependencies = ModuleRootManager.getInstance(module).getDependencies(false);
    if (dependencies.length > 0) {
      myDependencies = Lists.newArrayListWithExpectedSize(dependencies.length);
      for (Module depModule : dependencies) {
        myDependencies.add(getModulePermissions(depModule));
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:DeclaredPermissionsLookup.java

示例8: getApplicationPackage

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@Nullable
private static String getApplicationPackage(@NotNull PsiFile targetFile) {
  AndroidFacet facet = AndroidFacet.getInstance(targetFile);
  if (facet != null) {
    // We need the manifest package here, not the Gradle effective package (which can vary by flavor and build type)
    return ManifestInfo.get(facet.getModule(), false).getPackage();
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:AndroidImportFilter.java

示例9: isPackageAttributeInManifest

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
static boolean isPackageAttributeInManifest(@NotNull Project project, @Nullable PsiElement element) {
  if (element == null) {
    return false;
  }
  final PsiFile psiFile = element.getContainingFile();

  if (!(psiFile instanceof XmlFile)) {
    return false;
  }
  final AndroidFacet facet = AndroidFacet.getInstance(psiFile);

  if (facet == null) {
    return false;
  }
  final VirtualFile vFile = psiFile.getVirtualFile();

  if (vFile == null || !vFile.equals(AndroidRootUtil.getManifestFile(facet))) {
    return false;
  }
  if (!(element instanceof XmlAttributeValue)) {
    return false;
  }
  final PsiElement parent = element.getParent();

  if (!(parent instanceof XmlAttribute)) {
    return false;
  }
  final GenericAttributeValue attrValue = DomManager.getDomManager(project).getDomElement((XmlAttribute)parent);

  if (attrValue == null) {
    return false;
  }
  final DomElement parentDomElement = attrValue.getParent();
  return parentDomElement instanceof Manifest && attrValue.equals(((Manifest)parentDomElement).getPackage());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:AndroidRenameHandler.java

示例10: testFacetProperties2

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
public void testFacetProperties2() throws Exception {
  AndroidFacetImporterBase.ANDROID_SDK_PATH_TEST = AndroidTestCase.getDefaultTestSdkPath();
  try {
    importProject(getPomContent(
      "apklib", "module",
      "<mergeManifests>true</mergeManifests>" +
      "<androidManifestFile>${project.build.directory}/manifest/AndroidManifest.xml</androidManifestFile>" +
      "<resourceDirectory>${project.build.directory}/resources</resourceDirectory>" +
      "<assetsDirectory>${project.build.directory}/assets</assetsDirectory>" +
      "<nativeLibrariesDirectory>${project.build.directory}/nativeLibs</nativeLibrariesDirectory>" +
      "<dexCoreLibrary>true</dexCoreLibrary>"));

    assertModules("module");
    final Module module = getModule("module");
    checkSdk(ModuleRootManager.getInstance(module).getSdk());
    final AndroidFacet facet = AndroidFacet.getInstance(module);
    assertNotNull(facet);
    final JpsAndroidModuleProperties properties = facet.getProperties();
    assertEquals(true, properties.LIBRARY_PROJECT);
    assertEquals("/target/resources", properties.RES_FOLDER_RELATIVE_PATH);
    assertEquals(false, properties.USE_CUSTOM_APK_RESOURCE_FOLDER);
    assertEquals("/target/manifest/AndroidManifest.xml", properties.MANIFEST_FILE_RELATIVE_PATH);
    assertEquals(false, properties.USE_CUSTOM_COMPILER_MANIFEST);
    assertEquals("", properties.CUSTOM_COMPILER_MANIFEST);
    assertEquals("/target/nativeLibs", properties.LIBS_FOLDER_RELATIVE_PATH);
    assertEquals("/target/assets", properties.ASSETS_FOLDER_RELATIVE_PATH);
    assertEquals("/target/generated-sources/aidl", properties.GEN_FOLDER_RELATIVE_PATH_AIDL);
    assertEquals("/target/generated-sources/r", properties.GEN_FOLDER_RELATIVE_PATH_APT);
    assertEquals(true, properties.ENABLE_MANIFEST_MERGING);
    assertTrue(AndroidDexCompilerConfiguration.getInstance(myProject).CORE_LIBRARY);
  }
  finally {
    AndroidFacetImporterBase.ANDROID_SDK_PATH_TEST = null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:AndroidFacetImporterTest.java

示例11: createModuleProject

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
/** Creates a new module project */
@Nullable
private static LintModuleProject createModuleProject(@NonNull LintClient client, @NonNull Module module) {
  AndroidFacet facet = AndroidFacet.getInstance(module);
  File dir;

  if (facet != null) {
    final VirtualFile mainContentRoot = AndroidRootUtil.getMainContentRoot(facet);

    if (mainContentRoot == null) {
      return null;
    }
    dir = new File(FileUtil.toSystemDependentName(mainContentRoot.getPath()));
  } else {
    String moduleDirPath = AndroidRootUtil.getModuleDirPath(module);
    if (moduleDirPath == null) {
      return null;
    }
    dir = new File(FileUtil.toSystemDependentName(moduleDirPath));
  }
  LintModuleProject project;
  if (facet == null) {
    project = new LintModuleProject(client, dir, dir, module);
    AndroidFacet f = findAndroidFacetInProject(module.getProject());
    if (f != null) {
      project.mGradleProject = f.isGradleProject();
    }
  }
  else if (facet.isGradleProject()) {
    project = new LintGradleProject(client, dir, dir, facet);
  }
  else {
    project = new LintAndroidProject(client, dir, dir, facet);
  }
  client.registerProject(dir, project);
  return project;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:IntellijLintProject.java

示例12: isAvailable

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
  if (file instanceof XmlFile && file.isValid() && AndroidFacet.getInstance(file) != null) {
    ResourceFolderType folderType = ResourceHelper.getFolderType(file);
    if (folderType == null) {
      return false;
    } else if (folderType != ResourceFolderType.VALUES) {
      return true;
    } else {
      return isAvailable(getValueTag(editor, file), file);
    }
  }

  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:OverrideResourceAction.java

示例13: getProjectResources

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
/**
 * Returns the Android resources for this module and any modules it depends on, but not resources in any libraries
 *
 * @param module the module to look up resources for
 * @param createIfNecessary if true, create the app resources if necessary, otherwise only return if already computed
 * @return the resource repository
 */
@Nullable
public static ProjectResourceRepository getProjectResources(@NotNull Module module, boolean createIfNecessary) {
  AndroidFacet facet = AndroidFacet.getInstance(module);
  if (facet != null) {
    return facet.getProjectResources(createIfNecessary);
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ProjectResourceRepository.java

示例14: isAvailable

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
  if (editor == null || !(file instanceof XmlFile)) {
    return false;
  }
  final AndroidFacet facet = AndroidFacet.getInstance(file);

  if (facet == null) {
    return false;
  }
  final XmlAttributeValue attrValue = getXmlAttributeValue(file, editor);

  if (attrValue == null) {
    return false;
  }
  final PsiElement parent = attrValue.getParent();

  if (!(parent instanceof XmlAttribute)) {
    return false;
  }
  final GenericAttributeValue domValue = DomManager.getDomManager(project).getDomElement((XmlAttribute)parent);

  if (domValue == null || !(domValue.getConverter() instanceof OnClickConverter)) {
    return false;
  }
  final String methodName = attrValue.getValue();
  return methodName != null && StringUtil.isJavaIdentifier(methodName);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:AndroidCreateOnClickHandlerAction.java

示例15: findComponentDeclarationInManifest

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@Nullable
public static AndroidAttributeValue<PsiClass> findComponentDeclarationInManifest(@NotNull PsiClass aClass) {
  final AndroidFacet facet = AndroidFacet.getInstance(aClass);
  if (facet == null) {
    return null;
  }

  final boolean isActivity = isInheritor(aClass, AndroidUtils.ACTIVITY_BASE_CLASS_NAME);
  final boolean isService = isInheritor(aClass, AndroidUtils.SERVICE_CLASS_NAME);
  final boolean isReceiver = isInheritor(aClass, AndroidUtils.RECEIVER_CLASS_NAME);
  final boolean isProvider = isInheritor(aClass, AndroidUtils.PROVIDER_CLASS_NAME);

  if (!isActivity && !isService && !isReceiver && !isProvider) {
    return null;
  }
  final Manifest manifest = facet.getManifest();
  if (manifest == null) {
    return null;
  }

  final Application application = manifest.getApplication();
  if (application == null) {
    return null;
  }

  if (isActivity) {
    for (Activity activity : application.getActivities()) {
      final AndroidAttributeValue<PsiClass> activityClass = activity.getActivityClass();
      if (activityClass.getValue() == aClass) {
        return activityClass;
      }
    }
  }
  else if (isService) {
    for (Service service : application.getServices()) {
      final AndroidAttributeValue<PsiClass> serviceClass = service.getServiceClass();
      if (serviceClass.getValue() == aClass) {
        return serviceClass;
      }
    }
  }
  else if (isReceiver) {
    for (Receiver receiver : application.getReceivers()) {
      final AndroidAttributeValue<PsiClass> receiverClass = receiver.getReceiverClass();
      if (receiverClass.getValue() == aClass) {
        return receiverClass;
      }
    }
  }
  else {
    for (Provider provider : application.getProviders()) {
      final AndroidAttributeValue<PsiClass> providerClass = provider.getProviderClass();
      if (providerClass.getValue() == aClass) {
        return providerClass;
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:60,代码来源:AndroidDomUtil.java


注:本文中的org.jetbrains.android.facet.AndroidFacet.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。