List of usage examples for org.eclipse.jdt.internal.compiler SourceElementParser setRequestor
public void setRequestor(ISourceElementRequestor requestor)
From source file:com.codenvy.ide.ext.java.server.internal.core.search.indexing.SourceIndexer.java
License:Open Source License
public void indexDocument() { // Create a new Parser SourceIndexerRequestor requestor = new SourceIndexerRequestor(this); String documentPath = this.document.getPath(); SourceElementParser parser = this.document.getParser(); if (parser == null) { //todo change this code IPath path = new Path(documentPath); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0)); parser = JavaModelManager.getJavaModelManager().indexManager .getSourceElementParser(JavaCore.create(project), requestor); } else {//from w ww .j a v a 2s . c o m parser.setRequestor(requestor); } // Launch the parser char[] source = null; char[] name = null; try { source = this.document.getCharContents(); name = documentPath.toCharArray(); } catch (Exception e) { // ignore } if (source == null || name == null) return; // could not retrieve document info (e.g. resource was discarded) CompilationUnit compilationUnit = new CompilationUnit(source, name); try { parser.parseCompilationUnit(compilationUnit, true/*full parse*/, null/*no progress*/); } catch (Exception e) { if (JobManager.VERBOSE) { e.printStackTrace(); } } }
From source file:org.eclipse.che.jdt.internal.core.search.indexing.SourceIndexer.java
License:Open Source License
public void indexDocument() { // Create a new Parser String documentPath = this.document.getPath(); SourceElementParser parser = this.document.getParser(); if (parser == null) { // IPath path = new Path(documentPath); // IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0)); // parser = JavaModelManager.getJavaModelManager().indexManager.getSourceElementParser(JavaCore.create(project), requestor); parser = indexManager.getSourceElementParser(javaProject, requestor); } else {/*from w ww .ja v a2s. c o m*/ parser.setRequestor(requestor); } // Launch the parser char[] source = null; char[] name = null; try { source = this.document.getCharContents(); name = documentPath.toCharArray(); } catch (Exception e) { // ignore } if (source == null || name == null) return; // could not retrieve document info (e.g. resource was discarded) this.compilationUnit = new CompilationUnit(source, name); try { if (parser.parseCompilationUnit(this.compilationUnit, true, null).hasFunctionalTypes()) this.document.requireIndexingResolvedDocument(); } catch (Exception e) { if (JobManager.VERBOSE) { e.printStackTrace(); } } }