Package org.eclipse.dltk.core

Examples of org.eclipse.dltk.core.IModelElement


        if (match.isInsideDocComment()) {
          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) {
View Full Code Here


            }
          }
        }
        String nodeName = getNodeChildName(node);
        if (nodeName != null) {
          IModelElement e = null;
          if (nodeName.startsWith("::")) {
            nodeName = nodeName.substring(2);
            e = findChildrenByName(nodeName, sourceModule);
          } else {
            e = findChildrenByName(nodeName, element);
          }
          if (e == null && resolver != null) {
            e = resolver.findElementParent(node, nodeName, element);

          }
          if (e != null) {
            List toRemove = new ArrayList();
            for (int k = 0; k < selectionElements.size(); ++k) {
              IModelElement ke = (IModelElement) selectionElements.get(k);
              String keName = ke.getElementName();
              if (keName.equals(nodeName)) {
                toRemove.add(ke);
              }
            }
            for (int k = 0; k < toRemove.size(); ++k) {
              selectionElements.remove(toRemove.get(k));
            }
            selectionElements.add(e);
          }
        }
        return;
      }
      if (nde.sourceStart() <= node.sourceStart() && node.sourceEnd() <= nde.sourceEnd()) {
        if (element instanceof IParent) {
          if (nde instanceof TypeDeclaration) {
            TypeDeclaration type = (TypeDeclaration) nde;
            String typeName = getNodeChildName(type);
            IModelElement e = findChildrenByName(typeName, element);
            if (e == null && type.getName().startsWith("::")) {
              try {
                e = (IModelElement) findTypeFrom(sourceModule.getChildren(), "", type.getName()
                        .replaceAll("::", "\\$"), '$');
              } catch (ModelException e1) {
View Full Code Here

          return;
        }
      }
      methodName = RutaResolver.getNodeChildName(nde);
    }
    IModelElement e = RutaResolver.findChildrenByName(methodName, element);
    if (e != null && e instanceof IParent) {
      List stats = ((MethodDeclaration) nde).getStatements();
      searchAddElementsTo(stats, node, (IParent) e, selectionElements);
    }
  }
View Full Code Here

        if (match(startPart, string)) {
          addProposal(startPart, string, CompletionProposal.TYPE_REF);
        }
      }
    } else {
      IModelElement modelElement = sourceModule.getModelElement();
      if (modelElement instanceof SourceModule) {
        SourceModule sm = (SourceModule) modelElement;
        try {
          IField[] fields = sm.getFields();
          for (IField iField : fields) {
View Full Code Here

          final String type = TextUtilities.getContentType(viewer.getDocument(),
                  RutaPartitions.RUTA_PARTITIONING, selection.x, true);
          if (type.equals(IDocument.DEFAULT_CONTENT_TYPE) && selection.y == 0) {

            try {
              final IModelElement element = getElementAt(selection.x, true);
              if (element != null && element.exists()) {

                final int kind = element.getElementType();
                if (kind == IModelElement.TYPE || kind == IModelElement.METHOD) {

                  final ISourceReference reference = (ISourceReference) element;
                  final ISourceRange range = reference.getSourceRange();
View Full Code Here

    if (region == null || !(fTextEditor instanceof ScriptEditor))
      return null;

    int offset = region.getOffset();

    IModelElement input = EditorUtility.getEditorInputModelElement(fTextEditor, false);
    if (input == null)
      return null;

    try {
      IDocument document = fTextEditor.getDocumentProvider().getDocument(
              fTextEditor.getEditorInput());
      IRegion wordRegion = ScriptWordFinder.findWord(document, offset);
      if (wordRegion == null)
        return null;
      if (input instanceof ISourceModule) {
        ISourceModule sm = (ISourceModule) input;
        IModelElement modelElement = sm.getModelElement();
        RutaSelectionParser parser = new RutaSelectionParser();
        ModuleDeclaration moduleDeclaration = parser.parse(sm);
        String word = document.get(wordRegion.getOffset(), wordRegion.getLength());
        RutaReferenceVisitor referenceVisitor = new RutaReferenceVisitor(wordRegion.getOffset());
        moduleDeclaration.traverse(referenceVisitor);
        ASTNode node = referenceVisitor.getResult();
        if (node instanceof RutaVariableReference
                && moduleDeclaration instanceof RutaModuleDeclaration) {
          RutaVariableReference vr = (RutaVariableReference) node;
          RutaModuleDeclaration parsed = (RutaModuleDeclaration) moduleDeclaration;
          if (vr.getType() == RutaTypeConstants.RUTA_TYPE_AT) {
            String nodeText = vr.getStringRepresentation();
            Collection<String> importedTypeSystems = parsed.descriptorInfo.getImportedTypeSystems();
            List<IHyperlink> result = new ArrayList<IHyperlink>();
            for (String tsString : importedTypeSystems) {
              IFolder folder = modelElement.getScriptProject().getProject()
                      .getFolder(RutaProjectUtils.getDefaultDescriptorLocation());
              String xmlFilePath = tsString.replaceAll("\\.", "/");
              xmlFilePath = xmlFilePath.substring(0, xmlFilePath.length()) + ".xml";
              Set<String> types = getTypes(folder, xmlFilePath);
              if (types.contains(nodeText)) {
View Full Code Here

          IQuickAssistInvocationContext invocationContext) {
    final Annotation[] annotations = fAssistant.getAnnotationsAtOffset();
    final ScriptEditor editor = (ScriptEditor) this.fAssistant.getEditor();
    final IAnnotationModel model = DLTKUIPlugin.getDocumentProvider().getAnnotationModel(
            editor.getEditorInput());
    final IModelElement element = editor.getInputModelElement();
    final IScriptProject scriptProject = element.getScriptProject();
    List proposals = null;
    for (int i = 0; i < annotations.length; i++) {
      final Annotation annotation = annotations[i];
      ICompletionProposal proposal = null;
      if (annotation instanceof MarkerAnnotation) {
View Full Code Here

  private PairBlock[] computePairRanges(final int offset, String contents) {
    ISourceParser pp = null;
    pp = DLTKLanguageManager.getSourceParser(RutaNature.NATURE_ID);
    ModuleDeclaration md = null;// pp.parse(null, contents.toCharArray(),
    // null);
    IModelElement el = this.editor.getInputModelElement();
    if (el != null && el instanceof ISourceModule) {
      md = SourceParserUtil.getModuleDeclaration((ISourceModule) el, null);
    }
    if (md == null) {
      md = (ModuleDeclaration) pp.parse(new ModuleSource(contents), null);
View Full Code Here

    return true;
  }
 
  @Override
  public IModelElement getAncestor(int ancestorType) {
    IModelElement element = this;
    while (element != null) {
      if (element.getElementType() == ancestorType)
        return element;
      element = element.getParent();
    }
    return null;
  }
View Full Code Here

  }
 
  @SuppressWarnings("unchecked")
  @Override
  public <E extends IModelElement> E getAncestor(Class<E> elementClass) {
    IModelElement element = this;
    do {
      if (elementClass.isInstance(element)) {
        return (E) element;
      }
      element = element.getParent();
    } while (element != null);
    return null;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.dltk.core.IModelElement

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.