java relativepath_Java IFile.getProjectRelativePath方法代码示例

import org.eclipse.core.resources.IFile; //导入方法依赖的package包/类

public static PgDatabase buildFiles(Collection files, IProgressMonitor monitor,

List funcBodies) throws InterruptedException, IOException, CoreException {

SubMonitor mon = SubMonitor.convert(monitor, files.size());

Set schemaDirnamesLoaded = new HashSet<>();

IPath schemasPath = new Path(WORK_DIR_NAMES.SCHEMA.name());

PgDatabase db = new PgDatabase(false);

db.setArguments(new PgDiffArguments());

for (IFile file : files) {

IPath filePath = file.getProjectRelativePath();

if (!"sql".equals(file.getFileExtension()) || !isInProject(filePath)) { //$NON-NLS-1$

// skip non-sql or non-project files

// still report work

mon.worked(1);

continue;

}

if (schemasPath.isPrefixOf(filePath)) {

IPath relSchemasPath = filePath.makeRelativeTo(schemasPath);

String schemaDirname;

boolean schemaDefSql = relSchemasPath.segmentCount() == 1;

if (schemaDefSql) {

// schema definition SQL-file

schemaDirname = relSchemasPath.removeFileExtension().lastSegment();

} else {

// schema-contained object

// preload its schema so that search_path parses normally

schemaDirname = relSchemasPath.segment(0);

}

if (!schemaDirnamesLoaded.add(schemaDirname)) {

// schema already loaded, skip

if (schemaDefSql) {

// report schema pre-built if the same schema was to be built normally as well

mon.worked(1);

}

continue;

} else if (!schemaDefSql) {

// pre-load schema for object's search path

// otherwise we're dealing with the schema file itself, allow it to load normally

// don't pass progress monitor since this file isn't in the original load-set

loadFile(file.getProject().getFile(schemasPath.append(schemaDirname + ".sql")), //$NON-NLS-1$

null, db, funcBodies, null);

}

}

loadFile(file, mon, db, funcBodies, null);

}

return db;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值