org.eclipse.jdt.internal.core.DefaultWorkingCopyOwner Java Examples
The following examples show how to use
org.eclipse.jdt.internal.core.DefaultWorkingCopyOwner.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SourceIndexer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void resolveDocument() { try { IPath path = new Path(this.document.getPath()); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0)); JavaModel model = JavaModelManager.getJavaModelManager().getJavaModel(); JavaProject javaProject = (JavaProject) model.getJavaProject(project); this.options = new CompilerOptions(javaProject.getOptions(true)); ProblemReporter problemReporter = new ProblemReporter( DefaultErrorHandlingPolicies.proceedWithAllProblems(), this.options, new DefaultProblemFactory()); // Re-parse using normal parser, IndexingParser swallows several nodes, see comment above class. this.basicParser = new Parser(problemReporter, false); this.basicParser.reportOnlyOneSyntaxError = true; this.basicParser.scanner.taskTags = null; this.cud = this.basicParser.parse(this.compilationUnit, new CompilationResult(this.compilationUnit, 0, 0, this.options.maxProblemsPerUnit)); // Use a non model name environment to avoid locks, monitors and such. INameEnvironment nameEnvironment = new JavaSearchNameEnvironment(javaProject, JavaModelManager.getJavaModelManager().getWorkingCopies(DefaultWorkingCopyOwner.PRIMARY, true/*add primary WCs*/)); this.lookupEnvironment = new LookupEnvironment(this, this.options, problemReporter, nameEnvironment); reduceParseTree(this.cud); this.lookupEnvironment.buildTypeBindings(this.cud, null); this.lookupEnvironment.completeTypeBindings(); this.cud.scope.faultInTypes(); this.cud.resolve(); } catch (Exception e) { if (JobManager.VERBOSE) { e.printStackTrace(); } } }
Example #2
Source File: ProjectAwareUniqueClassNameValidator.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
private ICompilationUnit[] getWorkingCopies(JvmDeclaredType type) { return ResourceSetContext.get(type).isBuilder() // ? new ICompilationUnit[] {} // : JavaModelManager.getJavaModelManager().getWorkingCopies(DefaultWorkingCopyOwner.PRIMARY, false); }
Example #3
Source File: IWorkingCopyOwnerProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Override public WorkingCopyOwner getWorkingCopyOwner(IJavaProject javaProject, ResourceSet resourceset) { return DefaultWorkingCopyOwner.PRIMARY; }
Example #4
Source File: JdtTypeProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
private ICompilationUnit[] getWorkingCopies() { if (ResourceSetContext.get(getResourceSet()).isBuilder()) { return new ICompilationUnit[0]; } return JavaModelManager.getJavaModelManager().getWorkingCopies(DefaultWorkingCopyOwner.PRIMARY, false/*don't add primary WCs a second time*/); }
Example #5
Source File: JdtTypeProviderFactory.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
protected IJdtTypeProvider createJdtTypeProvider(IJavaProject javaProject, ResourceSet resourceSet) { if (javaProject == null) //TODO throw a serious exception instead of returning a non working implementation return new NullJdtTypeProvider(resourceSet); return new JdtTypeProvider(javaProject, resourceSet, getIndexedJvmTypeAccess(), copyOwnerProvider==null? DefaultWorkingCopyOwner.PRIMARY : copyOwnerProvider.getWorkingCopyOwner(javaProject, resourceSet), typeResourceServices); }
Example #6
Source File: JdtBasedTypeFactory.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Deprecated public JdtBasedTypeFactory(TypeURIHelper uriHelper) { this(uriHelper, DefaultWorkingCopyOwner.PRIMARY); }
Example #7
Source File: CompletionHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
private CompletionList computeContentAssist(ICompilationUnit unit, int line, int column, IProgressMonitor monitor) throws JavaModelException { CompletionResponses.clear(); if (unit == null) { return null; } List<CompletionItem> proposals = new ArrayList<>(); final int offset = JsonRpcHelpers.toOffset(unit.getBuffer(), line, column); CompletionProposalRequestor collector = new CompletionProposalRequestor(unit, offset, manager); // Allow completions for unresolved types - since 3.3 collector.setAllowsRequiredProposals(CompletionProposal.FIELD_REF, CompletionProposal.TYPE_REF, true); collector.setAllowsRequiredProposals(CompletionProposal.FIELD_REF, CompletionProposal.TYPE_IMPORT, true); collector.setAllowsRequiredProposals(CompletionProposal.FIELD_REF, CompletionProposal.FIELD_IMPORT, true); collector.setAllowsRequiredProposals(CompletionProposal.METHOD_REF, CompletionProposal.TYPE_REF, true); collector.setAllowsRequiredProposals(CompletionProposal.METHOD_REF, CompletionProposal.TYPE_IMPORT, true); collector.setAllowsRequiredProposals(CompletionProposal.METHOD_REF, CompletionProposal.METHOD_IMPORT, true); collector.setAllowsRequiredProposals(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF, true); collector.setAllowsRequiredProposals(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF, true); collector.setAllowsRequiredProposals(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, CompletionProposal.TYPE_REF, true); collector.setAllowsRequiredProposals(CompletionProposal.TYPE_REF, CompletionProposal.TYPE_REF, true); collector.setFavoriteReferences(getFavoriteStaticMembers()); if (offset >-1 && !monitor.isCanceled()) { IBuffer buffer = unit.getBuffer(); if (buffer != null && buffer.getLength() >= offset) { IProgressMonitor subMonitor = new ProgressMonitorWrapper(monitor) { private long timeLimit; private final long TIMEOUT = Long.getLong("completion.timeout", 5000); @Override public void beginTask(String name, int totalWork) { timeLimit = System.currentTimeMillis() + TIMEOUT; } @Override public boolean isCanceled() { return super.isCanceled() || timeLimit <= System.currentTimeMillis(); } }; try { if (isIndexEngineEnabled()) { unit.codeComplete(offset, collector, subMonitor); } else { ModelBasedCompletionEngine.codeComplete(unit, offset, collector, DefaultWorkingCopyOwner.PRIMARY, subMonitor); } proposals.addAll(collector.getCompletionItems()); if (isSnippetStringSupported() && !UNSUPPORTED_RESOURCES.contains(unit.getResource().getName())) { proposals.addAll(SnippetCompletionProposal.getSnippets(unit, collector.getContext(), subMonitor)); } proposals.addAll(new JavadocCompletionProposal().getProposals(unit, offset, collector, subMonitor)); } catch (OperationCanceledException e) { monitor.setCanceled(true); } } } proposals.sort(PROPOSAL_COMPARATOR); CompletionList list = new CompletionList(proposals); list.setIsIncomplete(!collector.isComplete()); return list; }
Example #8
Source File: AbstractNewXtendElementWizardPage.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
private ICompilationUnit getCompilationUnitStub() { String compilationUnitName = getCompilationUnitName(getTypeName()); return new CompilationUnit((PackageFragment) getPackageFragment(), compilationUnitName, DefaultWorkingCopyOwner.PRIMARY); }
Example #9
Source File: AbstractNewSarlElementWizardPage.java From sarl with Apache License 2.0 | 4 votes |
private ICompilationUnit getCompilationUnitStub() { final String compilationUnitName = getCompilationUnitName(getTypeName()); return new CompilationUnit((PackageFragment) getPackageFragment(), compilationUnitName, DefaultWorkingCopyOwner.PRIMARY); }
Example #10
Source File: WorkingCopyOwner.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Sets the buffer provider of the primary working copy owner. Note that even if the * buffer provider is a working copy owner, only its <code>createBuffer(ICompilationUnit)</code> * method is used by the primary working copy owner. It doesn't replace the internal primary * working owner. * <p> * This method is for internal use by the jdt-related plug-ins. * Clients outside of the jdt should not reference this method. * </p> * * @param primaryBufferProvider the primary buffer provider */ public static void setPrimaryBufferProvider(WorkingCopyOwner primaryBufferProvider) { DefaultWorkingCopyOwner.PRIMARY.primaryBufferProvider = primaryBufferProvider; }