Examples of ISourceModule


Examples of org.eclipse.dltk.core.ISourceModule

  }
 
  @Test
  public void testCompletionOnOutSrc() throws Exception { testCompletionOnOutSrc$(); }
  public void testCompletionOnOutSrc$() throws Exception {
    ISourceModule srcModule = SampleMainProject.getSourceModule(IOutsideBuildpathTestResources.TEST_OUTFILE);
   
    srcModule.becomeWorkingCopy(null, null);
    try {
      final int offset = srcModule.getSource().indexOf("Foo foo");
     
      class CompletionRequestorTestCheck extends CompletionRequestor {
        @Override
        public void accept(CompletionProposal proposal) {
          assertTrue(proposal.getCompletionLocation() == offset);
          assertTrue(proposal.getReplaceStart() == offset);
        }
      }
     
      DeeCompletionEngine completionEngine = new DeeCompletionEngine();
      completionEngine.setRequestor(new CompletionRequestorTestCheck());
      completionEngine.complete((IModuleSource) srcModule, offset, 0);
    } finally {
      srcModule.discardWorkingCopy();
    }
  }
View Full Code Here

Examples of org.eclipse.dltk.core.ISourceModule

            Module moduleNode = defUnit.getModuleNode();
            if(moduleNode == null) {
              continue; // consider this case more
            }
             
            ISourceModule defUnitSrcModule = findSourceModule(moduleNode, searchProj);
           
            ArrayList<Integer> nodeTreePath = DeeSearchEngineTestUtils.getNodeTreePath(defUnit);
            Pair<ISourceModule, ?> key = Pair.create(defUnitSrcModule, nodeTreePath);
           
            if(defUnitToReferencesMap.get(key) == null) {
              defUnitToReferencesMap.put(key, new HashSet<Reference>());
            }
           
            defUnitToReferencesMap.get(key).add(reference);
          }
        }
      }
    }.visitElementsAndNodes(getSrcFolder(searchProj, "srcA"), 10);
   
   
   
    for (Pair<ISourceModule, ?> key : defUnitToReferencesMap.keySet()) {
      ISourceModule sourceModule = key.getFirst();
      ArrayList<Integer> nodeTreePath = blindCast(key.getSecond());
     
      Path filePath = DLTKUtils.getFilePath(sourceModule);
     
      ParsedModule parseModule = DToolClient.getDefaultModuleCache().getParsedModuleOrNull(filePath);
      Module deeModule = parseModule == null ? null : parseModule.module;
      ASTNode node = DeeSearchEngineTestUtils.getNodeFromPath(deeModule, nodeTreePath);
     
      final DefUnit defUnit = (DefUnit) node;
      final HashSet<Reference> expectedReferences = defUnitToReferencesMap.get(key);
     
      IMember element = DeeModelEngine.findCorrespondingModelElement(defUnit, sourceModule);
//      if(element == null) {
//        // TODO: consider this case
//        continue;
//      }
     
      final String keyIdentifier = DeeSearchEngineTestUtils.getModelElementFQName(element);
     
      doTestSearchForElementReferences(element, new MatchChecker(){
        @Override
        public void checkMatch(SearchMatch match) throws CoreException {
          IMember refElement = assertInstance(match.getElement(), IMember.class);
          ISourceModule module = getSourceModule(refElement);
          checkKey(module, match.getOffset(), keyIdentifier);
         
          checkReferences(expectedReferences, match);
        }
       
        private void checkReferences(final HashSet<Reference> expectedReferences, SearchMatch referenceMatch) {
          // Search for referenceMatch in expectedReferences, then remove it
         
          for (Reference pair : expectedReferences) {
            Reference reference = pair;
           
            String refModuleName = reference.getModuleNode().getModuleFullyQualifiedName();
           
            IModelElement modelElement = downCast(referenceMatch.getElement());
            ISourceModule matchSrcModule = DeeSearchEngineTestUtils.getSourceModule(modelElement);
           
            String matchModuleName = DeeSearchEngineTestUtils.getSourceModuleFQName(matchSrcModule);
           
            if(areEqual(refModuleName, matchModuleName) &&
              reference.getOffset() == referenceMatch.getOffset() &&
View Full Code Here

Examples of org.eclipse.dltk.core.ISourceModule

    }
    // process all modules
    int remainingWork = resourceToModuleInfos.size();
    for (Iterator i = resourceToModuleInfos.entrySet().iterator(); i.hasNext();) {
      final Map.Entry entry = (Map.Entry) i.next();
      final ISourceModule module = (ISourceModule) entry.getKey();
      final ModuleInfo info = (ModuleInfo) entry.getValue();
      monitor.subTask(NLS.bind(Messages.RutaCheckBuilder_processing, module.getElementName(),
              Integer.toString(remainingWork)));
      codeModels.clear();
      --remainingWork;
    }
  }
View Full Code Here

Examples of org.eclipse.dltk.core.ISourceModule

    if (!(mdObj instanceof ModuleDeclaration)) {
      return;
    }
    ModuleDeclaration md = (ModuleDeclaration) mdObj;
    IProblemReporter problemReporter = context.getProblemReporter();
    ISourceModule smod = context.getSourceModule();

    // traverse:
    ISourceLineTracker linetracker = context.getLineTracker();
    String fileName = smod.getElementName();
    try {
      ASTVisitor visitor = new EngineAndCallCheckerVisitor(problemReporter, linetracker, fileName);
      md.traverse(visitor);
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

Examples of org.eclipse.dltk.core.ISourceModule

    Object mdObj = context.get(IBuildContext.ATTR_MODULE_DECLARATION);
    if (!(mdObj instanceof ModuleDeclaration)) {
      return;
    }
    IProblemReporter problemReporter = context.getProblemReporter();
    ISourceModule smod = context.getSourceModule();
    ISourceLineTracker linetracker = context.getLineTracker();
    RutaCheckerProblemFactory problemFactory = new RutaCheckerProblemFactory(smod.getElementName(), linetracker);
   
    IScriptProject scriptProject = smod.getScriptProject();
    IProject project = scriptProject.getProject();
    IProject[] referencedProjects = project.getReferencedProjects();
    List<IProject> listOfClosedProjects = new ArrayList<IProject>();
    for (IProject each : referencedProjects) {
      if(!each.isOpen()) {
View Full Code Here

Examples of org.eclipse.dltk.core.ISourceModule

    } catch (CoreException e) {
      throw e;
    }
    String fileNameWithoutExtension = path.substring(path.lastIndexOf('.') + 1);
    String fileNameWithExtension = fileNameWithoutExtension + RutaEngine.SCRIPT_FILE_EXTENSION;
    ISourceModule sourceModule = null;
    boolean found = false;
    for (IFolder eachFolder : scriptFolders) {

      IScriptProject sp = DLTKCore.create(eachFolder.getProject());
      IScriptFolder[] scriptFolders2 = sp.getScriptFolders();
      for (IScriptFolder iScriptFolder : scriptFolders2) {
        sourceModule = iScriptFolder.getSourceModule(fileNameWithExtension);
        if (sourceModule.exists() && sourceModule.getResource() != null
                && sourceModule.getResource().exists()) {
          found = true;
          break;
        }
        if (found)
          break;
      }
    }
    IModelElement elements[] = null;
    namespaceStack.push(fileNameWithoutExtension);
    try {
      elements = sourceModule.getChildren();
      for (int i = 0; i < elements.length; i++) {
        IModelElement modelElement = elements[i];
        int elementType = modelElement.getElementType();
        if (elementType == type) {
          if (elementType == IModelElement.METHOD) {
View Full Code Here

Examples of org.eclipse.dltk.core.ISourceModule

    // if ast not declared in context ..
    Object mdObj = context.get(IBuildContext.ATTR_MODULE_DECLARATION);
    if (!(mdObj instanceof ModuleDeclaration)) {
      // ...temporary inefficient hack to get live error msgs
      // TODO refactor
      ISourceModule sourceModule = context.getSourceModule();
      ModuleDeclaration md = SourceParserUtil.getModuleDeclaration(sourceModule, null);
      context.set(IBuildContext.ATTR_MODULE_DECLARATION, md);
    }
    for (IBuildParticipant buildP : buildParticipants) {
      buildP.build(context);
View Full Code Here

Examples of org.eclipse.dltk.core.ISourceModule

      return;
    }
    ModuleDeclaration md = (ModuleDeclaration) mdObj;

    IProblemReporter problemReporter = context.getProblemReporter();
    ISourceModule smod = context.getSourceModule();
    ISourceLineTracker linetracker = context.getLineTracker();
    try {
      Collection<String> dependencies = RutaProjectUtils.getClassPath(smod.getScriptProject()
              .getProject());
      URL[] urls = new URL[dependencies.size()];
      int counter = 0;
      for (String dep : dependencies) {
        urls[counter] = new File(dep).toURI().toURL();
View Full Code Here

Examples of org.eclipse.dltk.core.ISourceModule

    return fSearchResults;
  }

  public IMethod[] findMethods(final String methodName, int argCount, int sourcePosition) {
    final List methods = new ArrayList();
    ISourceModule module = this.method.getSourceModule();
    try {
      IModelElement[] elements = module.codeSelect(sourcePosition, methodName.length());
      for (int i = 0; i < elements.length; ++i) {
        if (elements[i] instanceof IMethod) {
          methods.add(elements[i]);
        }
      }
View Full Code Here

Examples of org.eclipse.dltk.core.ISourceModule

          return;
        }

        if (match.getElement() != null && match.getElement() instanceof IModelElement) {
          IModelElement member = (IModelElement) match.getElement();
          ISourceModule module = (ISourceModule) member.getAncestor(IModelElement.SOURCE_MODULE);
          SimpleReference ref = new SimpleReference(match.getOffset(), match.getOffset()
                  + match.getLength(), "");
          try {
            IModelElement[] e = module.codeSelect(match.getOffset(), 1);
            for (int j = 0; j < e.length; ++j) {
              if (e[j].equals(parent)) {
                elements.put(ref, member);
              }
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.