use of org.eclipse.jdt.internal.core.JavaModelStatus in project che by eclipse.
the class CodeAssist method prepareCompilationUnit.
private ICompilationUnit prepareCompilationUnit(IJavaProject project, String fqn) throws JavaModelException {
ICompilationUnit compilationUnit;
IType type = project.findType(fqn);
if (type == null) {
throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.CORE_EXCEPTION, "Can't find a file: " + fqn));
}
if (type.isBinary()) {
throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.CORE_EXCEPTION, "Can't organize imports on binary file"));
} else {
compilationUnit = type.getCompilationUnit();
}
return compilationUnit;
}
use of org.eclipse.jdt.internal.core.JavaModelStatus in project che by eclipse.
the class CodeAssist method computeAssistProposals.
@SuppressWarnings("unchecked")
public Proposals computeAssistProposals(IJavaProject project, String fqn, int offset, List<Problem> problems) throws CoreException {
ICompilationUnit compilationUnit;
IType type = project.findType(fqn);
if (type == null) {
return null;
}
if (type.isBinary()) {
throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.CORE_EXCEPTION, "Can't calculate Quick Assist on binary file"));
} else {
compilationUnit = type.getCompilationUnit();
}
IBuffer buffer = compilationUnit.getBuffer();
ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
bufferManager.connect(compilationUnit.getPath(), LocationKind.IFILE, new NullProgressMonitor());
ITextFileBuffer textFileBuffer = bufferManager.getTextFileBuffer(compilationUnit.getPath(), LocationKind.IFILE);
IDocument document = textFileBuffer.getDocument();
TextViewer viewer = new TextViewer(document, new Point(offset, 0));
AssistContext context = new AssistContext(compilationUnit, offset, 0);
ArrayList proposals = new ArrayList<>();
JavaCorrectionProcessor.collectProposals(context, problems, true, true, proposals);
return convertProposals(offset, compilationUnit, viewer, proposals);
}
use of org.eclipse.jdt.internal.core.JavaModelStatus in project che by eclipse.
the class MavenWorkspace method addSourcesFromBuildHelperPlugin.
private void addSourcesFromBuildHelperPlugin(MavenProject project) {
IJavaProject javaProject = JavaCore.create(project.getProject());
try {
ClasspathHelper helper = new ClasspathHelper(javaProject);
Element pluginConfigurationSource = project.getPluginConfiguration("org.codehaus.mojo", "build-helper-maven-plugin", "add-source");
Element pluginConfigurationTestSource = project.getPluginConfiguration("org.codehaus.mojo", "build-helper-maven-plugin", "add-test-source");
IPath projectPath = project.getProject().getFullPath();
RegisteredProject registeredProject = projectRegistryProvider.get().getProject(projectPath.toOSString());
if (registeredProject == null) {
throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.CORE_EXCEPTION, "Project " + projectPath.toOSString() + " doesn't exist"));
}
List<String> sourceFolders = registeredProject.getAttributes().get(Constants.SOURCE_FOLDER);
List<String> testSourceFolders = registeredProject.getAttributes().get(MavenAttributes.TEST_SOURCE_FOLDER);
addSourcePathFromConfiguration(helper, project, pluginConfigurationSource, sourceFolders);
addSourcePathFromConfiguration(helper, project, pluginConfigurationTestSource, testSourceFolders);
javaProject.setRawClasspath(helper.getEntries(), null);
} catch (JavaModelException e) {
LOG.error("Can't update Java project classpath with Maven build helper plugin configuration", e);
}
}
Aggregations