Package org.eclipse.jdt.internal.compiler

Examples of org.eclipse.jdt.internal.compiler.SourceElementParser


    if (elementToFind != null) {
      oldSourceRanges = (HashMap) this.sourceRanges.clone();
    }
    try {
      IProblemFactory factory = new DefaultProblemFactory();
      SourceElementParser parser = null;
      this.anonymousClassName = 0;
      if (info == null) {
        try {
          info = (IBinaryType) this.binaryType.getElementInfo();
        } catch(JavaModelException e) {
          return null;
        }
      }
      boolean isAnonymousClass = info.isAnonymous();
      char[] fullName = info.getName();
      if (isAnonymousClass) {
        String eltName = this.binaryType.getParent().getElementName();
        eltName = eltName.substring(eltName.lastIndexOf('$') + 1, eltName.length());
        try {
          this.anonymousClassName = Integer.parseInt(eltName);
        } catch(NumberFormatException e) {
          // ignore
        }
      }
      boolean doFullParse = hasToRetrieveSourceRangesForLocalClass(fullName);
      parser = new SourceElementParser(this, factory, new CompilerOptions(this.options), doFullParse, true/*optimize string literals*/);
      parser.javadocParser.checkDocComment = false; // disable javadoc parsing
      IJavaElement javaElement = this.binaryType.getCompilationUnit();
      if (javaElement == null) javaElement = this.binaryType.getParent();
      parser.parseCompilationUnit(
        new BasicCompilationUnit(contents, null, this.binaryType.sourceFileName(info), javaElement),
        doFullParse,
        null/*no progress*/);
      if (elementToFind != null) {
        ISourceRange range = getNameRange(elementToFind);
View Full Code Here


            );
          }
        }
      }

      SourceElementParser parser = this.manager.getSourceElementParser(javaProject, null/*requestor will be set by indexer*/);
      Object[] names = indexedFileNames.keyTable;
      Object[] values = indexedFileNames.valueTable;
      for (int i = 0, namesLength = names.length; i < namesLength; i++) {
        String name = (String) names[i];
        if (name != null) {
View Full Code Here

public SourceElementParser getSourceElementParser(IJavaProject project, ISourceElementRequestor requestor) {
  // disable task tags to speed up parsing
  Map options = project.getOptions(true);
  options.put(JavaCore.COMPILER_TASK_TAGS, ""); //$NON-NLS-1$

  SourceElementParser parser = new IndexingParser(
    requestor,
    new DefaultProblemFactory(Locale.getDefault()),
    new CompilerOptions(options),
    true, // index local declarations
    true, // optimize string literals
View Full Code Here

  }
  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) {
      IPath path = new Path(documentPath);
      IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0));
      parser = JavaModelManager.getJavaModelManager().indexManager.getSourceElementParser(JavaCore.create(project), requestor);
    } else {
      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();
      }
    }
View Full Code Here

    this.requestor = new SourceIndexerRequestor(this);
  }
  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), this.requestor);
    } else {
      parser.setRequestor(this.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();
      }
View Full Code Here

public SourceElementParser getSourceElementParser(IJavaProject project, ISourceElementRequestor requestor) {
  // disable task tags to speed up parsing
  Map options = project.getOptions(true);
  options.put(JavaCore.COMPILER_TASK_TAGS, ""); //$NON-NLS-1$

  SourceElementParser parser = new IndexingParser(
    requestor,
    new DefaultProblemFactory(Locale.getDefault()),
    new CompilerOptions(options),
    true, // index local declarations
    true, // optimize string literals
View Full Code Here

            );
          }
        }
      }

      SourceElementParser parser = this.manager.getSourceElementParser(javaProject, null/*requestor will be set by indexer*/);
      Object[] names = indexedFileNames.keyTable;
      Object[] values = indexedFileNames.valueTable;
      for (int i = 0, namesLength = names.length; i < namesLength; i++) {
        String name = (String) names[i];
        if (name != null) {
View Full Code Here

    try {
      monitor.enterRead(); // ask permission to read

      final IPath container = this.containerPath;
      final IndexManager indexManager = this.manager;
      final SourceElementParser parser = indexManager.getSourceElementParser(JavaCore.create(this.project), null/*requestor will be set by indexer*/);
      if (this.exclusionPatterns == null && this.inclusionPatterns == null) {
        folder.accept(
          new IResourceProxyVisitor() {
            public boolean visit(IResourceProxy proxy) /* throws CoreException */{
              if (proxy.getType() == IResource.FILE) {
View Full Code Here

    if (elementToFind != null) {
      oldSourceRanges = (HashMap) this.sourceRanges.clone();
    }
    try {
      IProblemFactory factory = new DefaultProblemFactory();
      SourceElementParser parser = null;
      this.anonymousClassName = 0;
      if (info == null) {
        try {
          info = (IBinaryType) this.binaryType.getElementInfo();
        } catch(JavaModelException e) {
          return null;
        }
      }
      boolean isAnonymousClass = info.isAnonymous();
      char[] fullName = info.getName();
      if (isAnonymousClass) {
        String eltName = this.binaryType.getParent().getElementName();
        eltName = eltName.substring(eltName.lastIndexOf('$') + 1, eltName.length());
        try {
          this.anonymousClassName = Integer.parseInt(eltName);
        } catch(NumberFormatException e) {
          // ignore
        }
      }
      boolean doFullParse = hasToRetrieveSourceRangesForLocalClass(fullName);
      parser = new SourceElementParser(this, factory, new CompilerOptions(this.options), doFullParse, true/*optimize string literals*/);
      parser.javadocParser.checkDocComment = false; // disable javadoc parsing
      IJavaElement javaElement = this.binaryType.getCompilationUnit();
      if (javaElement == null) javaElement = this.binaryType.getParent();
      parser.parseCompilationUnit(
        new BasicCompilationUnit(contents, null, this.binaryType.sourceFileName(info), javaElement),
        doFullParse,
        null/*no progress*/);
      if (elementToFind != null) {
        ISourceRange range = getNameRange(elementToFind);
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.SourceElementParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.