本文整理了Java中com.intellij.openapi.project.Project.getBasePath()
方法的一些代码示例,展示了Project.getBasePath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.getBasePath()
方法的具体详情如下:
包路径:com.intellij.openapi.project.Project
类名称:Project
方法名:getBasePath
暂无
代码示例来源:origin: ballerina-platform/ballerina-lang
@NotNull
public static String getFilePathInPackage(@NotNull Project project, @NotNull VirtualFile virtualFile) {
String projectPath = project.getBasePath() + FILE_SEPARATOR;
String filePath = virtualFile.getPath();
filePath = filePath.replace(projectPath, "");
if (!filePath.contains(FILE_SEPARATOR)) {
return "";
}
int index = filePath.indexOf(FILE_SEPARATOR);
return filePath.substring(index + 1);
}
代码示例来源:origin: ballerina-platform/ballerina-lang
@NotNull
public static String getPackage(@NotNull Project project, @NotNull VirtualFile virtualFile) {
String modulePath = project.getBasePath() + FILE_SEPARATOR;
String filePath = virtualFile.getPath();
filePath = filePath.replace(modulePath, "");
if (!filePath.contains(FILE_SEPARATOR)) {
return "";
}
int index = filePath.indexOf(FILE_SEPARATOR);
return filePath.substring(0, index);
}
代码示例来源:origin: ballerina-platform/ballerina-lang
@NotNull
public static String getPackage(@NotNull PsiFile file) {
Project project = file.getProject();
String modulePath = project.getBasePath() + FILE_SEPARATOR;
String filePath = file.getVirtualFile().getPath();
filePath = filePath.replace(modulePath, "");
if (!filePath.contains(FILE_SEPARATOR)) {
return "";
}
int index = filePath.indexOf(FILE_SEPARATOR);
return filePath.substring(0, index);
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Override
protected void resetEditorFrom(@NotNull GoTestRunConfiguration configuration) {
myGotestFrameworkRadioButton.setSelected(configuration.getTestFramework() == GotestFramework.INSTANCE);
myGocheckFrameworkRadioButton.setSelected(configuration.getTestFramework() == GocheckFramework.INSTANCE);
myGobenchRadioButton.setSelected(configuration.getTestFramework() == GobenchFramework.INSTANCE);
myTestKindComboBox.setSelectedItem(configuration.getKind());
myPackageField.setText(configuration.getPackage());
String directoryPath = configuration.getDirectoryPath();
myDirectoryField.setText(directoryPath.isEmpty() ? configuration.getProject().getBasePath() : directoryPath);
String filePath = configuration.getFilePath();
myFileField.setText(filePath.isEmpty() ? configuration.getProject().getBasePath() : filePath);
myPatternEditor.setText(configuration.getPattern());
myCommonSettingsPanel.resetEditorFrom(configuration);
}
代码示例来源:origin: KronicDeth/intellij-elixir
String basePath = myProject.getBasePath();
VirtualFile projectBasedFile = null;
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
public GoRunConfigurationBase(String name, GoModuleBasedConfiguration configurationModule, ConfigurationFactory factory) {
super(name, configurationModule, factory);
Module module = configurationModule.getModule();
if (module == null) {
Collection<Module> modules = getValidModules();
if (modules.size() == 1) {
module = ContainerUtil.getFirstItem(modules);
getConfigurationModule().setModule(module);
}
}
if (module != null) {
if (FileUtil.exists(module.getModuleFilePath())) {
myWorkingDirectory = StringUtil.trimEnd(PathUtil.getParentPath(module.getModuleFilePath()), ".idea");
}
}
else {
myWorkingDirectory = StringUtil.notNullize(configurationModule.getProject().getBasePath());
}
}
代码示例来源:origin: ballerina-platform/ballerina-lang
String rootDir = new File(project.getBasePath()).getParent();
String sourcerootDir = getSourceRoot(fileDir.getPath(), rootDir);
代码示例来源:origin: ballerina-platform/ballerina-lang
public BallerinaRunConfigurationBase(String name, BallerinaModuleBasedConfiguration configurationModule,
ConfigurationFactory factory) {
super(name, configurationModule, factory);
Module module = configurationModule.getModule();
if (module == null) {
Collection<Module> modules = getValidModules();
if (modules.size() == 1) {
module = ContainerUtil.getFirstItem(modules);
getConfigurationModule().setModule(module);
}
}
if (module != null) {
if (FileUtil.exists(module.getModuleFilePath())) {
myWorkingDirectory = StringUtil.trimEnd(PathUtil.getParentPath(module.getModuleFilePath()),
BallerinaConstants.IDEA_CONFIG_DIRECTORY);
}
} else {
myWorkingDirectory = StringUtil.notNullize(configurationModule.getProject().getBasePath());
}
setFileOutputPath(myWorkingDirectory);
}
代码示例来源:origin: jshiell/checkstyle-idea
private File projectRelativeFileOf(final String filename) {
return Paths.get(new File(project.getBasePath(), filename).getAbsolutePath())
.normalize()
.toAbsolutePath()
.toFile();
}
代码示例来源:origin: jshiell/checkstyle-idea
private Optional<Path> getProjectDir() throws IOException {
Optional<Path> result = Optional.empty();
String basePath = project.getBasePath();
if (basePath != null) {
if (basePath.length() > 2 && (basePath.startsWith("/") || basePath.startsWith("\\")) && basePath.charAt
(2) == ':') {
// e.g. "/D:/projects/foo", then we must cut off the leading slash
basePath = basePath.substring(1);
}
result = Optional.of(Paths.get(basePath).toRealPath());
}
return result;
}
}
代码示例来源:origin: jshiell/checkstyle-idea
private String basePathFor(final Module module) {
if (module != null) {
final File moduleFile = new File(module.getModuleFilePath());
if (moduleFile.getParent() != null
&& moduleFile.getParentFile().exists()
&& !moduleFile.getParentFile().getName().equals("modules")) {
return moduleFile.getParentFile().getAbsolutePath();
}
}
return project.getBasePath();
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
private static String getPath(Project project, String path) {
if (!FileUtil.isAbsolute(path)) { // Project relative path
path = project.getBasePath() + "/" + path;
}
return path;
}
代码示例来源:origin: hsz/idea-gitignore
myProject.getBasePath() != null ? myProject.getBasePath() : entryFile.getParent().getPath();
if (!StringUtil.startsWith(file.getPath(), parentPath) &&
!ExternalIndexableSetContributor.getAdditionalFiles(myProject).contains(entryFile)) {
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@Nullable
protected File getTranslationRoot() {
String translationPath = Settings.getInstance(this.project).pathToTranslation;
if (!FileUtil.isAbsolute(translationPath)) {
translationPath = project.getBasePath() + "/" + translationPath;
}
File file = new File(translationPath);
if(!file.exists() || !file.isDirectory()) {
return null;
}
return file;
}
代码示例来源:origin: jshiell/checkstyle-idea
@NotNull
private File temporaryDirectoryLocationFor(final Project project) {
return getIdeaFolder(project).map(vf -> new File(vf.getPath(), "checkstyleidea.tmp"))
.orElse(new File(project.getBasePath(), "checkstyleidea.tmp"));
}
代码示例来源:origin: jshiell/checkstyle-idea
private Map<String, String> addEclipseCsProperties(final ConfigurationLocation location, final Module module, final Map<String, String> properties)
throws IOException {
addIfAbsent("basedir", basePathFor(module), properties);
addIfAbsent("project_loc", project.getBasePath(), properties);
addIfAbsent("workspace_loc", project.getBasePath(), properties);
final String locationBaseDir = Optional.ofNullable(location.getBaseDir())
.map(File::toString)
.orElseGet(project::getBasePath);
addIfAbsent("config_loc", locationBaseDir, properties);
addIfAbsent("samedir", locationBaseDir, properties);
return properties;
}
代码示例来源:origin: jshiell/checkstyle-idea
@BeforeClass
public static void setup() {
String baseDir = ClasspathStabilizerTest.class.getResource("/cpstab").getPath();
Mockito.when(PROJECT.getBasePath()).thenReturn(baseDir);
}
代码示例来源:origin: jshiell/checkstyle-idea
private List<URL> buildInputClasspath() throws MalformedURLException {
final String baseDir = PROJECT.getBasePath();
List<URL> result = new ArrayList<>();
result.add(new File(baseDir, "lib1.jar").toURI().toURL());
result.add(new File(baseDir, "nonexistent.jar").toURI().toURL());
result.add(new File(baseDir, "libs/lib1.jar").toURI().toURL());
result.add(new File(baseDir, "libs/lib2.jar").toURI().toURL());
result.add(new File(baseDir, "hashed/lib1.jar").toURI().toURL());
result.add(new File(baseDir, "a_long_folder/path_more_than_50_characters/in_total/lib1.jar").toURI().toURL());
// SHA1("hashed") == "mmmfkoez3kxcsqlrrqbfbcxo5e4k6gq4"
result.add(new File(baseDir, "mmmfkoez3kxcsqlrrqbfbcxo5e4k6gq4/lib1.jar").toURI().toURL());
result.add(new File(baseDir, TempDirProvider.README_FILE).toURI().toURL());
return result;
}
代码示例来源:origin: jshiell/checkstyle-idea
@Test
public void testUpdate() throws IOException, InterruptedException {
final String baseDir = PROJECT.getBasePath();
final Path tempTargetDir = Paths.get(targetFolder.getRoot().toURI());
final List<URL> inputClasspath = new ArrayList<>();
inputClasspath.add(new File(baseDir, "lib1.jar").toURI().toURL());
final ClasspathStabilizer underTest = new ClasspathStabilizer(PROJECT, tempTargetDir);
URL[] result = underTest.stabilize(inputClasspath);
final URL[] expected = new URL[]{new File(targetFolder.getRoot(), "lib1.jar").toURI().toURL()};
Assert.assertTrue(Arrays.equals(expected, result));
Thread.sleep(TimeUnit.SECONDS.toMillis(2));
result = underTest.stabilize(inputClasspath);
Assert.assertTrue(Arrays.equals(expected, result));
}
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
public void testAbsolutePathResolving() {
createFile("app/views");
String basePath = getProject().getBasePath();
TwigPath twigPath = new TwigPath(basePath + "/app", "namespace");
assertEquals("app", twigPath.getDirectory(getProject()).getName());
assertTrue(twigPath.getPath().endsWith("app"));
assertEquals("namespace", twigPath.getNamespace());
assertEquals("app", twigPath.getRelativePath(getProject()));
}
}
内容来源于网络,如有侵权,请联系作者删除!