Package dtool.ast

Examples of dtool.ast.ASTNode


      return Collections.singleton(calleeResult);
    }
   
    Module moduleNode = null;
    if(calleeElem instanceof ASTNode) {
      ASTNode astNode = (ASTNode) calleeElem;
      moduleNode = astNode.getModuleNode();
    }
    if(moduleNode == null) {
      return null;
    }
   
View Full Code Here


  }
 
  @Override
  public Object[] getChildren(Object element) {
    if(element instanceof Module || isSignificantDeclarationBlock(element)) {
      ASTNode node = (ASTNode) element;
      return filterElements(node.getChildren());
    } else {
      return ASTNode.NO_ELEMENTS;
    }
  }
View Full Code Here

      ParsedModule parsedModule = DToolClient.getDefaultModuleCache().getParsedModuleOrNull(inputPath);
      if(parsedModule == null) {
        errorMessage = "Could not parse contents";
      }
      Module neoModule = parsedModule.module;
      ASTNode elem = ASTNodeFinder.findElement(neoModule, offset);
      if(elem instanceof DefSymbol) {
        DefSymbol defSymbol = (DefSymbol) elem;
        defunit = defSymbol.getDefUnit();
      } else if(elem instanceof Reference) {
        Reference ref = (Reference) elem;
View Full Code Here

    ISelection selection = event.getSelection();
    if (selection.isEmpty())
      editor.resetHighlightRange();
    else {
      IStructuredSelection sel = (IStructuredSelection) selection;
      ASTNode node = (ASTNode) sel.getFirstElement();
     
      if(!node.hasSourceRangeInfo())
        return;
     
      int start = node.getOffset();
      int end = node.getLength();
      try {
        editor.setHighlightRange(start, end, true);
        EditorUtils.setEditorSelection(editor, start, end);
      } catch (IllegalArgumentException x) {
        editor.resetHighlightRange();
View Full Code Here

    }
    if(resolvedModule == null) {
      return null; /*FIXME: BUG here: show error message. */
    }
    Module module = resolvedModule.getModuleNode();
    ASTNode pickedNode = ASTNodeFinder.findElement(module, offset);
    IModuleResolver mr = resolvedModule.getModuleResolver();
   
    INamedElement relevantElementForDoc = null;
    if(pickedNode instanceof DefSymbol) {
      relevantElementForDoc = ((DefSymbol) pickedNode).getDefUnit();
View Full Code Here

      resolvedModule = getResolvedModule(filePath);
    } catch (ExecutionException e) {
      return new FindDefinitionResult("Error awaiting operation result: " + e);
    }
    Module module = resolvedModule.getModuleNode();
    ASTNode node = ASTNodeFinder.findElement(module, offset);
    if(node == null) {
      return new FindDefinitionResult("No node found at offset: " + offset);
    }
    assertEquals(node.getModuleNode().compilationUnitPath, filePath); /*FIXME: BUG here normalization */
   
    ReferenceSwitchHelper<FindDefinitionResult> refPickHelper = new ReferenceSwitchHelper<FindDefinitionResult>() {
     
      @Override
      protected FindDefinitionResult nodeIsDefSymbol(DefSymbol defSymbol) {
View Full Code Here

    } else {
      nameToken = null;
    }
   
    Module module = parseResult.getModuleNode();
    ASTNode nodeAtOffset = new ASTNodeFinderExtension(module, offset, true).match;
    assertTrue(nodeAtOffset.getSourceRange().contains(offset));
   
    if(nodeAtOffset instanceof CommonQualifiedReference) {
      CommonQualifiedReference namedRef = (CommonQualifiedReference) nodeAtOffset;
      assertTrue(nameToken == null);
     
      if(offset <= namedRef.getDotOffset()) {
        nodeAtOffset = namedRef.getParent();
      }
      PrefixSearchOptions searchOptions = new PrefixSearchOptions();
      return performCompletionSearch(offset, mr, module, nodeAtOffset, searchOptions);
    } else if(nodeAtOffset instanceof RefModule) {
      RefModule refModule = (RefModule) nodeAtOffset;
      // RefModule has a specialized way to setup prefix len things
     
      String source = parseResult.source;
      PrefixSearchOptions searchOptions = codeCompletionRefModule(offset, tokenAtOffsetRight, source, refModule);
      return performCompletionSearch(offset, mr, module, nodeAtOffset, searchOptions);
    }
   
    if(nameToken != null) {
      assertTrue(nameToken.getSourceRange().contains(offset));
     
      PrefixSearchOptions searchOptions = new PrefixSearchOptions();
     
      String searchPrefix = nameToken.getSourceValue().substring(0, offset - nameToken.getStartPos());
      int rplLen = nameToken.getEndPos() - offset;
      searchOptions.setPrefixSearchOptions(searchPrefix, rplLen);
     
      // Because of some parser limitations, in some cases nodeForNameLookup needs to be corrected,
      // such that it won't be the same as nodeForNameLookup
      ASTNode nodeForNameLookup = getStartingNodeForNameLookup(nameToken.getStartPos(), module);
     
      return performCompletionSearch(offset, mr, module, nodeForNameLookup, searchOptions);
     
    } else {
      PrefixSearchOptions searchOptions = new PrefixSearchOptions();
View Full Code Here

   
  }
 
  protected static ASTNode getStartingNodeForNameLookup(int offset, Module module) {
    ASTNodeFinderExtension nodeFinder = new ASTNodeFinderExtension(module, offset, true);
    ASTNode node = nodeFinder.match;
    if(nodeFinder.matchOnLeft instanceof NamedReference) {
      NamedReference reference = (NamedReference) nodeFinder.matchOnLeft;
      if(reference.isMissingCoreReference()) {
        node = nodeFinder.matchOnLeft;
      }
View Full Code Here

    }
    return getMatchingParent(node.getParent(), klass);
  }
 
  public static <T> T parseSourceAndPickNode(String source, int offset, Class<T> klass) {
    ASTNode node = parseSourceAndPickNode(source, offset);
    return getMatchingParent(node, klass);
  }
View Full Code Here

      EProtection.PUBLIC, AttributeKinds.STATIC, AttributeKinds.IMMUTABLE);
  }
 
  public CommonDefinition getDefToTest(String source, String name) {
    Module module = DeeParser.parseSource(source, "attribs_test").module;
    ASTNode node = MiscNodeUtils.searchDefUnit(module, name, ASTNodeTypes.DECLARATION_ATTRIB);
    CommonDefinition def = assertCast(node, CommonDefinition.class);
    assertEquals(def.getName(), name);
    return def;
  }
View Full Code Here

TOP

Related Classes of dtool.ast.ASTNode

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.