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


Java HaxeFileMoveHandler类代码示例

本文整理汇总了Java中com.intellij.plugins.haxe.ide.refactoring.move.HaxeFileMoveHandler的典型用法代码示例。如果您正苦于以下问题:Java HaxeFileMoveHandler类的具体用法?Java HaxeFileMoveHandler怎么用?Java HaxeFileMoveHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HaxeFileMoveHandler类属于com.intellij.plugins.haxe.ide.refactoring.move包,在下文中一共展示了HaxeFileMoveHandler类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: bindToFile

import com.intellij.plugins.haxe.ide.refactoring.move.HaxeFileMoveHandler; //导入依赖的package包/类
private void bindToFile(PsiElement element) {
  final HaxeFileModel elementFileModel = HaxeFileModel.fromElement(element);
  final HaxeFileModel selfFileModel = HaxeFileModel.fromElement(this);
  String destinationPackage = element.getUserData(HaxeFileMoveHandler.destinationPackageKey);
  if (destinationPackage == null) {
    destinationPackage = "";
  }
  final String importPath = (destinationPackage.isEmpty() ? "" : destinationPackage + ".") +
                            elementFileModel.getName();

  if (resolve() == null) {
    final List<HaxeImportModel> imports = selfFileModel.getImportModels();
    final boolean isInImportStatement = getParent() instanceof HaxeImportStatement;
    final boolean isInQualifiedPath = getText().indexOf('.') != -1;
    final boolean inSamePackage = Objects.equals(selfFileModel.getPackageName(), elementFileModel.getPackageName());
    final boolean exposedByImports = imports.stream().anyMatch(
      model -> {
        return model.getExposedMembers().stream().anyMatch(item -> elementFileModel.getQualifiedInfo().equals(item.getQualifiedInfo()));
      });
    final boolean requiredToAddImport = !inSamePackage && (imports.isEmpty() || !exposedByImports);

    if (isInImportStatement) {
      if (inSamePackage || destinationPackage.isEmpty() || exposedByImports) {
        deleteImportStatement();
      } else {
        updateImportStatement(importPath);
      }
    } else if (isInQualifiedPath) {
      final String newName = destinationPackage.equals(selfFileModel.getPackageName()) ? elementFileModel.getName() : importPath;
      updateFullyQualifiedReference(newName);
    } else if (requiredToAddImport) {
      selfFileModel.addImport(importPath);
    }
  } else {
    final HaxeImportStatement importStatement = selfFileModel.getImportStatements().stream()
      .filter(statement -> statement.getReferenceExpression() != null && importPath.equals(statement.getReferenceExpression().getText()))
      .findFirst()
      .orElse(null);

    if (importStatement != null) {
      importStatement.delete();
    }
  }
}
 
开发者ID:HaxeFoundation,项目名称:intellij-haxe,代码行数:45,代码来源:HaxeReferenceImpl.java


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