Package org.eclipse.dltk.core

Examples of org.eclipse.dltk.core.IModelElement


          }
        } else if (element instanceof IImplForPhp) {
          element = ((IImplForPhp) element).getModelElement();
          if (element != null && ActionUtil.isEditable(getShell(), (IModelElement) element)) {
            if (element instanceof ISourceModule && selection instanceof ITextSelection) {
              IModelElement sourceElement = getSourceElement((ISourceModule) element, ((ITextSelection) selection).getOffset(), ((ITextSelection) selection).getLength());
              if (sourceElement != null && ActionUtil.isEditable(getShell(), sourceElement) && isRenameAvailable(sourceElement)) {
                run(sourceElement);
                return;
              }
            }
View Full Code Here


  public void run(ITextSelection selection) {
    if (editor != null && ActionUtil.isEditable(editor)) {
      try {
        IModelElement[] elements = SelectionConverter.codeResolve(editor);
        if (elements != null && elements.length == 1) {
          IModelElement sourceElement = getSourceElement(elements[0], selection.getOffset(), selection.getLength());
          if (sourceElement != null && ActionUtil.isEditable(getShell(), sourceElement) && isRenameAvailable(sourceElement)) {
            run(sourceElement);
            return;
          }
        }
View Full Code Here

    return getSourceElement(sourceModule, offset, length);
  }

  private static IModelElement getSourceElement(ISourceModule sourceModule, int offset, int length) throws CoreException {
    IModelElement sourceElement = PDTModelUtils.getSourceElement(sourceModule, offset, length);
    if (sourceElement instanceof IMethod) {
      IMethod farthestOverriddenMethod = new PHPMethod((IMethod) sourceElement).getFarthestOverriddenMethod();
      if (sourceElement.equals(farthestOverriddenMethod)) {
        return sourceElement;
      } else {
        return farthestOverriddenMethod;
      }
    } else {
View Full Code Here

 
  @SuppressWarnings("rawtypes")
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {

    IModelElement element = getCurrentModelElement(event);
   
    if (element == null) {     
        return exitMessage();
    }
   
    if (!(element instanceof SourceType)) {     
      while(element.getParent() != null) {       
        element = element.getParent();       
        if (element instanceof SourceType) {
          break;
        }
      }
    }
View Full Code Here

        .getTextEditor();

    try {

      if (textEditor instanceof PHPStructuredEditor) {
        IModelElement editorElement = ((PHPStructuredEditor) textEditor)
            .getModelElement();
        if (editorElement != null) {

          char indentChar = FormatterUtils
              .getFormatterCommonPrferences()
View Full Code Here

      public Object visitDubElement(IDubElement dubElement) {
        return dubElement.getParent();
      }
      @Override
      public Object visitModelElement(IModelElement element, IParent elementAsParent) {
        IModelElement parent = element.getParent();
        if(parent instanceof IProjectFragment) {
          // TODO: need to map to DepSourceContainer
          return null;
        }
        return parent;
View Full Code Here

          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) &&
View Full Code Here

        }
        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) {
            imports.add(namespaceStack.peek() + "." + modelElement.getElementName());
          } else if (appendPath) {
            imports.add(path + "." + modelElement.getElementName());
          } else {
            imports.add(modelElement.getElementName());
          }
        }
        if (elementType == IModelElement.METHOD) {
          String nSpace = namespaceStack.empty() ? modelElement.getElementName() : namespaceStack
                  .peek() + "." + modelElement.getElementName();
          namespaceStack.push(nSpace);
          imports.addAll(collectElements((IMethod) modelElement, type, namespaceStack));
          namespaceStack.pop();
        }
      }
View Full Code Here

  }

  private static Set<String> collectElements(IMethod element, int type, Stack stack)
          throws ModelException {
    Set<String> fieldsCollection = new HashSet<String>();
    IModelElement elements[] = element.getChildren();
    if (elements == null) {
      return fieldsCollection;
    }
    for (int i = 0; i < elements.length; i++) {
      IModelElement modelElement = elements[i];
      int elementType = modelElement.getElementType();
      if (elementType == type) {
        if (elementType == IModelElement.FIELD) {
          fieldsCollection.add(modelElement.getElementName());
        }
        fieldsCollection.add(stack.peek() + "." + modelElement.getElementName());
      }
      if (elementType == IModelElement.METHOD) {
        stack.push(stack.peek() + "." + modelElement.getElementName());
        fieldsCollection.addAll(collectElements((IMethod) modelElement, type, stack));
        stack.pop();
      }
    }
    return fieldsCollection;
View Full Code Here

      // referring to a non-ruta project
      // RutaIdePlugin.error(e);
    }
    if (scriptFolders != null) {
      for (IScriptFolder eachScriptFolder : scriptFolders) {
        IModelElement parent = eachScriptFolder.getParent();
        if (parent != null) {
          IResource resource = parent.getResource();
          if (resource != null && resource instanceof IFolder) {
            if (!result.contains(resource)) {
              result.add((IFolder) resource);
            }
          }
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.