本文整理了Java中com.intellij.openapi.project.Project
类的一些代码示例,展示了Project
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project
类的具体详情如下:
包路径:com.intellij.openapi.project.Project
类名称:Project
暂无
代码示例来源:origin: ballerina-platform/ballerina-lang
@Nullable
public static VirtualFile findByPath(@NotNull String path, @NotNull Project project) {
String systemIndependentPath = FileUtil.toSystemIndependentName(path);
VirtualFile projectBaseDir = project.getBaseDir();
if (systemIndependentPath.isEmpty()) {
return projectBaseDir;
}
return projectBaseDir.findFileByRelativePath(systemIndependentPath);
}
}
代码示例来源: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: hsz/idea-gitignore
/**
* Returns {@link FilesIndexCacheProjectComponent} service instance.
*
* @param project current project
* @return {@link FilesIndexCacheProjectComponent instance}
*/
public static FilesIndexCacheProjectComponent getInstance(@NotNull final Project project) {
return project.getComponent(FilesIndexCacheProjectComponent.class);
}
代码示例来源:origin: hsz/idea-gitignore
final VirtualFile baseDir = myProject.getBaseDir();
if (cached != null) {
return cached;
if (ApplicationManager.getApplication().isDisposed() || myProject.isDisposed() ||
DumbService.isDumb(myProject) || !isEnabled() || baseDir == null || !Utils.isUnder(file, baseDir) ||
NoAccessDuringPsiEvents.isInsideEventProcessing()) {
myProject.getBasePath() != null ? myProject.getBasePath() : entryFile.getParent().getPath();
if (!StringUtil.startsWith(file.getPath(), parentPath) &&
!ExternalIndexableSetContributor.getAdditionalFiles(myProject).contains(entryFile)) {
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Override
public void run(@NotNull ProgressIndicator indicator) {
if (doNotStart || myProject == null || myProject.isDisposed()) {
return;
}
indicator.setIndeterminate(true);
consumer.consume(execute());
}
});
代码示例来源:origin: JetBrains/ideavim
public void addFileEditorManagerListener(@NotNull Project project, @NotNull FileEditorManagerListener listener) {
final MessageBusConnection connection = project.getMessageBus().connect();
connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, listener);
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@Nullable
public static Object run(@NotNull Project project, @NotNull String className, @NotNull String serviceJsNameStrategy) throws ScriptException {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("className", className);
jsonObject.addProperty("projectName", project.getName());
jsonObject.addProperty("projectBasePath", project.getBasePath());
jsonObject.addProperty("defaultNaming", new DefaultServiceNameStrategy().getServiceName(new ServiceNameStrategyParameter(project, className)));
PhpClass aClass = PhpElementsUtil.getClass(project, className);
if(aClass != null) {
String relativePath = VfsUtil.getRelativePath(aClass.getContainingFile().getVirtualFile(), project.getBaseDir(), '/');
if(relativePath != null) {
jsonObject.addProperty("relativePath", relativePath);
}
jsonObject.addProperty("absolutePath", aClass.getContainingFile().getVirtualFile().toString());
}
ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
if(engine == null) {
return null;
}
return engine.eval("var __p = eval(" + jsonObject.toString() + "); result = function(args) { " + serviceJsNameStrategy + " }(__p)");
}
代码示例来源:origin: ballerina-platform/ballerina-lang
VirtualFile baseDir = project.getBaseDir();
String filePath;
String rootDir = new File(project.getBasePath()).getParent();
String sourcerootDir = getSourceRoot(fileDir.getPath(), rootDir);
代码示例来源:origin: hsz/idea-gitignore
/**
* {@link IgnoreManager.TrackedIgnoredListener} method implementation to handle incoming files.
*
* @param files tracked and ignored files list
*/
@Override
public void handleFiles(@NotNull final ConcurrentMap<VirtualFile, VcsRoot> files) {
if (!settings.isInformTrackedIgnored() || notificationShown || myProject.getBaseDir() == null) {
return;
}
notificationShown = true;
Notify.show(
myProject,
IgnoreBundle.message("notification.untrack.title", Utils.getVersion()),
IgnoreBundle.message("notification.untrack.content"),
NotificationType.INFORMATION,
(notification, event) -> {
if (DISABLE_ACTION.equals(event.getDescription())) {
settings.setInformTrackedIgnored(false);
} else if (!myProject.isDisposed()) {
new UntrackFilesDialog(myProject, files).show();
}
notification.expire();
}
);
}
}
代码示例来源:origin: jshiell/checkstyle-idea
@Override
public void run() {
List<VirtualFile> filesToScan = null;
if (module != null) {
// all non-excluded files of a module
final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
filesToScan = flattenFiles(moduleRootManager.getContentRoots());
} else {
// all non-excluded files of the project
filesToScan = flattenFiles(new VirtualFile[]{project.getBaseDir()});
}
project.getComponent(CheckStylePlugin.class).asyncScanFiles(filesToScan, selectedOverride);
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Override
public void apply() throws ConfigurationException {
ApplicationManager.getApplication().runWriteAction(() -> {
if (myProject.isDefault() || myProject.isDisposed()) {
return;
代码示例来源:origin: jshiell/checkstyle-idea
private void putReadmeFile(@NotNull final Project project, @NotNull final File pTempDir)
throws IOException {
final Path tempDir = Paths.get(pTempDir.toURI());
final Path readme = tempDir.resolve(README_FILE);
if (!Files.isRegularFile(readme)) {
String template = readTemplate();
if (template != null) {
template = MessageFormat.format(template, project.getName(), CheckStylePlugin.ID_PLUGIN);
template = template.replaceAll("[\r\n]+", System.lineSeparator());
Files.write(readme, template.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE);
}
}
}
代码示例来源:origin: antlr/intellij-plugin-v4
public static ANTLRv4PluginController getInstance(Project project) {
if ( project==null ) {
LOG.error("getInstance: project is null");
return null;
}
ANTLRv4PluginController pc = project.getComponent(ANTLRv4PluginController.class);
if ( pc==null ) {
LOG.error("getInstance: getComponent() for "+project.getName()+" returns null");
}
return pc;
}
代码示例来源:origin: google/google-java-format
private EnabledState getDisabledState() {
// The default settings (inherited by new projects) are either 'enabled' or
// 'show notification'. There's no way to default new projects to disabled. If someone wants
// that, we can add another checkbox, I suppose.
return project.isDefault() ? EnabledState.UNKNOWN : EnabledState.DISABLED;
}
代码示例来源:origin: jshiell/checkstyle-idea
@BeforeClass
public static void setup() {
Mockito.when(PROJECT.getName()).thenReturn("project-TempDirProviderTest");
Mockito.when(PROJECT.getLocationHash()).thenReturn("f2d57494");
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
if (!myProject.isDisposed()) {
Set<VirtualFile> openFiles = ContainerUtil.newHashSet(fileEditorManager.getSelectedFiles());
for (VFileEvent event : events) {
VirtualFile file = event.getFile();
if (file != null && openFiles.contains(file)) {
notifications.updateNotifications(file);
}
}
}
}
});
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
public GoIdeaSdkService(@NotNull Project project) {
super(project);
myProject.getMessageBus().connect(project).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
@Override
public void rootsChanged(ModuleRootEvent event) {
incModificationCount();
}
});
}
代码示例来源:origin: ballerina-platform/ballerina-lang
@Override
public void apply() throws ConfigurationException {
ApplicationManager.getApplication().runWriteAction(() -> {
if (myProject.isDefault() || myProject.isDisposed()) {
return;
代码示例来源:origin: jshiell/checkstyle-idea
CheckerFactoryCacheKey(@NotNull final ConfigurationLocation location, @Nullable final Module module) {
this.projectName = module != null ? module.getProject().getName() : "noProject";
this.moduleName = module != null ? module.getName() : "noModule";
this.location = location;
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Nullable
@Override
public Configurable createSdkConfigurable() {
return !myProject.isDefault() ? new GoSdkConfigurable(myProject, false) : null;
}
内容来源于网络,如有侵权,请联系作者删除!