本文整理汇总了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();
}
}
}