Package org.eclim.util.file

Examples of org.eclim.util.file.Position


        AbstractPyRefactoring.getPyRefactoring();
      Map<Tuple<String,File>, HashSet<ASTEntry>> refs =
        pyRefactoring.findAllOccurrences(request);
      for (Tuple<String,File> tuple : refs.keySet()){
        for (ASTEntry entry : refs.get(tuple)){
          Position position = Position.fromLineColumn(
            tuple.o2.toString().replace('\\', '/'),
            entry.getName(),
            entry.node.beginLine,
            entry.node.beginColumn);
          if (!results.contains(position)){
            results.add(position);
          }
        }
      }

    // find declaration
    }else{
      IPyRefactoring pyRefactoring = AbstractPyRefactoring.getPyRefactoring();
      ItemPointer[] defs = pyRefactoring.findDefinition(request);

      for (ItemPointer item : defs){
        if (item.file == null || item.file.toString().endsWith(".so")){
          continue;
        }
        Position position = Position.fromLineColumn(
          item.file.toString().replace('\\', '/'),
          item.definition.value,
          item.start.line + 1,
          item.start.column + 1);
        if (!results.contains(position)){
View Full Code Here


      if (element != null){
        int elementType = element.getElementType();
        if (elementType != IJavaElement.PACKAGE_FRAGMENT &&
            elementType != IJavaElement.PACKAGE_FRAGMENT_ROOT)
        {
          Position result = createPosition(project, match);
          if(result != null){
            results.add(result);
          }
        }
      }
View Full Code Here

            "\\[\\]\\s*(" + name + "\\s*\\()\\)", " $1int index)");
        stub = stub.replaceFirst("(return\\s+\\w+)(.*?;)", "$1[index]$2");

        IMethod inserted = type.createMethod(stub, sibling, false, null);
        // format the inserted method according to the user's preferences
        Position position = TypeUtils.getPosition(type, inserted);
        JavaUtils.format(
            src, CodeFormatter.K_COMPILATION_UNIT,
            position.getOffset(), position.getLength());
      }
    }

    if (setter != null){
      IMethod existing = getBeanMethod(type, setter, TYPE_SET_INDEX);
      if (existing == null) {
        IJavaElement sibling = getSibling(type, fields, setter, TYPE_SET_INDEX);
        String name = GetterSetterUtil.getSetterName(setter, null);
        String stub = GetterSetterUtil.getSetterStub(
            setter, name, settings.createComments, Modifier.PUBLIC);
        stub = stub.replaceFirst(
            "\n(\\s*\\*\\s*@param)",
            "\n * @param index the index to set\n$1");
        stub = stub.replaceFirst(
            "(" + name + "\\s*\\()(.*?)\\[\\](\\s*.*?)\\)",
            "$1int index, $2$3)");
        stub = stub.replaceFirst("(\\w+)(\\s*=\\s*)", "$1[index]$2");

        IMethod inserted = type.createMethod(stub, sibling, false, null);
        // format the inserted method according to the user's preferences
        Position position = TypeUtils.getPosition(type, inserted);
        JavaUtils.format(
            src, CodeFormatter.K_COMPILATION_UNIT,
            position.getOffset(), position.getLength());
      }
    }
  }
View Full Code Here

        if (!file.exists() || !file.isFile()){
          // ignoring results that don't have a file that exists.
          return;
        }

        Position position = Position.fromOffset(
            filename, StringUtils.EMPTY, match.getOffset(), match.getLength());

        int index = matches.indexOf(position);
        String name = SearchCommand.this.getElement(match.getElement());
        if(index == -1){
          position.setMessage(name);
          if(!matches.contains(position)){
            matches.add(position);
          }
        }else if (!StringUtils.EMPTY.equals(name)){
          // the second occurrence should be the one with the name.
          position = matches.get(index);
          position.setMessage(name);
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.eclim.util.file.Position

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.