当前位置: 首页>>代码示例>>Java>>正文


Java ISourceRange.getLength方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.ISourceRange.getLength方法的典型用法代码示例。如果您正苦于以下问题:Java ISourceRange.getLength方法的具体用法?Java ISourceRange.getLength怎么用?Java ISourceRange.getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.ISourceRange的用法示例。


在下文中一共展示了ISourceRange.getLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleType

import org.eclipse.jdt.core.ISourceRange; //导入方法依赖的package包/类
private void handleType(IType type, IFile file, List<ServiceImplementation> serviceImplementations) throws JavaModelException {
	/* Parcourt les méthodes. */
	for (IMethod method : type.getMethods()) {
		/* Filtre pour ne garder que les méthodes publiques d'instance */
		if (method.isConstructor() || Flags.isStatic(method.getFlags()) || Flags.isPrivate(method.getFlags())) {
			continue;
		}

		/* Créé le ServiceImplementation. */
		String javaName = method.getElementName();
		ISourceRange nameRange = method.getNameRange();
		FileRegion fileRegion = new FileRegion(file, nameRange.getOffset(), nameRange.getLength());
		ServiceImplementation serviceImplementation = new ServiceImplementation(fileRegion, javaName);
		serviceImplementations.add(serviceImplementation);
	}
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:17,代码来源:ServiceManager.java

示例2: handleType

import org.eclipse.jdt.core.ISourceRange; //导入方法依赖的package包/类
private void handleType(IType type, IFile file, List<DaoImplementation> daoImplementations) throws JavaModelException {
	/* Parcourt les méthodes. */
	for (IMethod method : type.getMethods()) {
		/* Filtre pour ne garder que les méthodes publiques d'instance */
		if (method.isConstructor() || Flags.isStatic(method.getFlags()) || Flags.isPrivate(method.getFlags())) {
			continue;
		}

		/* Créé le DaoImplementation. */
		String javaName = method.getElementName();
		ISourceRange nameRange = method.getNameRange();
		FileRegion fileRegion = new FileRegion(file, nameRange.getOffset(), nameRange.getLength());
		DaoImplementation daoImplementation = new DaoImplementation(fileRegion, javaName);
		daoImplementations.add(daoImplementation);
	}
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:17,代码来源:DaoManager.java

示例3: internalGetContentReader

import org.eclipse.jdt.core.ISourceRange; //导入方法依赖的package包/类
/**
 * Gets a reader for an IMember's Javadoc comment content from the source attachment.
 * The content does contain only the text from the comment without the Javadoc leading star characters.
 * Returns <code>null</code> if the member does not contain a Javadoc comment or if no source is available.
 * @param member The member to get the Javadoc of.
 * @return Returns a reader for the Javadoc comment content or <code>null</code> if the member
 * does not contain a Javadoc comment or if no source is available
 * @throws JavaModelException is thrown when the elements javadoc can not be accessed
 * @since 3.4
 */
private static Reader internalGetContentReader(IMember member) throws JavaModelException {
	IBuffer buf= member.getOpenable().getBuffer();
	if (buf == null) {
		return null; // no source attachment found
	}

	ISourceRange javadocRange= member.getJavadocRange();
	if (javadocRange != null) {
		JavaDocCommentReader reader= new JavaDocCommentReader(buf, javadocRange.getOffset(), javadocRange.getOffset() + javadocRange.getLength() - 1);
		if (!containsOnlyInheritDoc(reader, javadocRange.getLength())) {
			reader.reset();
			return reader;
		}
	}

	return null;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:28,代码来源:JavadocContentAccess.java

示例4: getUnresolvedJavaElement

import org.eclipse.jdt.core.ISourceRange; //导入方法依赖的package包/类
/** Returns the IInitializer that contains the given local variable in the given type */
public static JavaElement getUnresolvedJavaElement(
    int localSourceStart, int localSourceEnd, JavaElement type) {
  try {
    if (!(type instanceof IType)) return null;
    IInitializer[] initializers = ((IType) type).getInitializers();
    for (int i = 0; i < initializers.length; i++) {
      IInitializer initializer = initializers[i];
      ISourceRange sourceRange = initializer.getSourceRange();
      if (sourceRange != null) {
        int initializerStart = sourceRange.getOffset();
        int initializerEnd = initializerStart + sourceRange.getLength();
        if (initializerStart <= localSourceStart && localSourceEnd <= initializerEnd) {
          return (JavaElement) initializer;
        }
      }
    }
    return null;
  } catch (JavaModelException e) {
    return null;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:Util.java

示例5: internalGetContentReader

import org.eclipse.jdt.core.ISourceRange; //导入方法依赖的package包/类
/**
 * Gets a reader for an IMember's Javadoc comment content from the source attachment. The content
 * does contain only the text from the comment without the Javadoc leading star characters.
 * Returns <code>null</code> if the member does not contain a Javadoc comment or if no source is
 * available.
 *
 * @param member The member to get the Javadoc of.
 * @return Returns a reader for the Javadoc comment content or <code>null</code> if the member
 *     does not contain a Javadoc comment or if no source is available
 * @throws org.eclipse.jdt.core.JavaModelException is thrown when the elements javadoc can not be
 *     accessed
 * @since 3.4
 */
private static Reader internalGetContentReader(IMember member) throws JavaModelException {
  IBuffer buf = member.getOpenable().getBuffer();
  if (buf == null) {
    return null; // no source attachment found
  }

  ISourceRange javadocRange = member.getJavadocRange();
  if (javadocRange != null) {
    JavaDocCommentReader reader =
        new JavaDocCommentReader(
            buf,
            javadocRange.getOffset(),
            javadocRange.getOffset() + javadocRange.getLength() - 1);
    if (!containsOnlyInheritDoc(reader, javadocRange.getLength())) {
      reader.reset();
      return reader;
    }
  }

  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:35,代码来源:JavadocContentAccess.java

示例6: collectIntersectingJavadocRanges

import org.eclipse.jdt.core.ISourceRange; //导入方法依赖的package包/类
private void collectIntersectingJavadocRanges(IJavaElement element, IRegion region, List<ISourceRange> elements) throws JavaModelException {
	if (element instanceof IParent) {
		for (IJavaElement child : ((IParent) element).getChildren()) {
			collectIntersectingJavadocRanges(child, region, elements);
		}
	}

	if (element instanceof IMember) {
		ISourceRange range = ((IMember) element).getJavadocRange();
		if (range != null) {
			if (range.getOffset() <= region.getOffset() + region.getLength() && range.getOffset() + range.getLength() >= region.getOffset()) {
				elements.add(range);
			}
		}
	}

}
 
开发者ID:umlet,项目名称:umlet,代码行数:18,代码来源:ImageRefHyperlinkDetector.java

示例7: internalGetNewSelectionRange

import org.eclipse.jdt.core.ISourceRange; //导入方法依赖的package包/类
@Override
ISourceRange internalGetNewSelectionRange(ISourceRange oldSourceRange, ISourceReference sr, SelectionAnalyzer selAnalyzer) throws JavaModelException{
	if (oldSourceRange.getLength() == 0 && selAnalyzer.getLastCoveringNode() != null) {
		ASTNode previousNode= NextNodeAnalyzer.perform(oldSourceRange.getOffset(), selAnalyzer.getLastCoveringNode());
		if (previousNode != null)
			return getSelectedNodeSourceRange(sr, previousNode);
	}
	ASTNode first= selAnalyzer.getFirstSelectedNode();
	if (first == null)
		return getLastCoveringNodeRange(oldSourceRange, sr, selAnalyzer);

	ASTNode parent= first.getParent();
	if (parent == null)
		return getLastCoveringNodeRange(oldSourceRange, sr, selAnalyzer);

	ASTNode lastSelectedNode= selAnalyzer.getSelectedNodes()[selAnalyzer.getSelectedNodes().length - 1];
	ASTNode nextNode= getNextNode(parent, lastSelectedNode);
	if (nextNode == parent)
		return getSelectedNodeSourceRange(sr, first.getParent());
	int offset= oldSourceRange.getOffset();
	int end= Math.min(sr.getSourceRange().getLength(), nextNode.getStartPosition() + nextNode.getLength() - 1);
	return StructureSelectionAction.createSourceRange(offset, end);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:StructureSelectNextAction.java

示例8: createDtoFile

import org.eclipse.jdt.core.ISourceRange; //导入方法依赖的package包/类
/**
 * Parse un fichier candidat de DTO.
 * 
 * @param file Fichier.
 * @param javaProject Projet Java du fichier.
 * @return Le DTO, <code>null</code> sinon.
 */
private DtoFile createDtoFile(IFile file, IJavaProject javaProject) {

	/* Charge l'AST du fichier Java. */
	ICompilationUnit compilationUnit = JdtUtils.getCompilationUnit(file, javaProject);
	if (compilationUnit == null) {
		return null;
	}
	List<String> dtoParentClassesList = LegacyManager.getInstance().getDtoParentsClasseList(javaProject.getProject());
	try {
		LegacyStrategy strategy = LegacyManager.getInstance().getStrategy(file);
		/* Parcourt les types du fichier Java. */
		for (IType type : compilationUnit.getAllTypes()) {

			/* Vérifie que c'est un Dto */
			boolean isDtoType = strategy.isDtoType(type) || JdtUtils.isSubclass(type, dtoParentClassesList);

			if (!isDtoType) {
				continue;
			}

			/* Parse les champs. */
			List<DtoField> fields = strategy.parseDtoFields(type);

			/* Créé le DtoFile. */
			String javaName = type.getElementName();
			String packageName = type.getPackageFragment().getElementName();
			ISourceRange nameRange = type.getNameRange();
			FileRegion fileRegion = new FileRegion(file, nameRange.getOffset(), nameRange.getLength());
			return new DtoFile(fileRegion, javaName, packageName, fields);
		}
	} catch (JavaModelException e) {
		ErrorUtils.handle(e);
	}

	return null;
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:44,代码来源:DtoManager.java

示例9: handleMethod

import org.eclipse.jdt.core.ISourceRange; //导入方法依赖的package包/类
private void handleMethod(IMethod method, String pathPrefix, IFile file, List<WsRoute> wsRoutes) throws JavaModelException {
	/* Filtre pour ne garder que les méthodes publiques d'instance */
	if (method.isConstructor() || Flags.isStatic(method.getFlags()) || Flags.isPrivate(method.getFlags())) {
		return;
	}

	/* Parcourt les verbes HTTP */
	for (String verb : HTTP_VERBS) {

		/* Extrait l'annotation du verbe. */
		IAnnotation verbAnnotation = JdtUtils.getAnnotation(method, verb);
		if (verbAnnotation == null) {
			continue;
		}

		/* Extrait la route partielle. */
		String routePatternSuffix = JdtUtils.getMemberValue(verbAnnotation);

		/* Calcule la route complète. */
		String routePattern = pathPrefix + routePatternSuffix;

		/* Créé la WsRoute. */
		String javaName = method.getElementName();
		ISourceRange nameRange = method.getNameRange();
		FileRegion fileRegion = new FileRegion(file, nameRange.getOffset(), nameRange.getLength());
		WsRoute wsRoute = new WsRoute(fileRegion, javaName, routePattern, verb);
		wsRoutes.add(wsRoute);
	}
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:30,代码来源:WsRouteManager.java

示例10: createJavaClassFile

import org.eclipse.jdt.core.ISourceRange; //导入方法依赖的package包/类
/**
 * Parse un fichier de classe Java.
 * 
 * @param file Fichier.
 * @param javaProject Projet Java du fichier.
 * @return Le fichier de classe Java, <code>null</code> sinon.
 */
private JavaClassFile createJavaClassFile(IFile file, IJavaProject javaProject) {

	/* Charge l'AST du fichier Java. */
	ICompilationUnit compilationUnit = JdtUtils.getCompilationUnit(file, javaProject);
	if (compilationUnit == null) {
		return null;
	}
	try {
		/* Parcourt les types du fichier Java. */
		for (IType type : compilationUnit.getAllTypes()) {

			if (!type.isClass()) {
				continue;
			}

			/* Créé le JavaClassFile. */
			String javaName = type.getElementName();
			String packageName = type.getPackageFragment().getElementName();
			ISourceRange nameRange = type.getNameRange();
			FileRegion fileRegion = new FileRegion(file, nameRange.getOffset(), nameRange.getLength());
			return new JavaClassFile(fileRegion, javaName, packageName);
		}
	} catch (JavaModelException e) {
		ErrorUtils.handle(e);
	}

	return null;
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:36,代码来源:JavaClassManager.java

示例11: addDeclarationUpdate

import org.eclipse.jdt.core.ISourceRange; //导入方法依赖的package包/类
private void addDeclarationUpdate(TextChangeManager manager) throws CoreException {

    if (getDelegateUpdating()) {
      // create the delegate
      CompilationUnitRewrite rewrite = new CompilationUnitRewrite(getDeclaringCU());
      rewrite.setResolveBindings(true);
      MethodDeclaration methodDeclaration =
          ASTNodeSearchUtil.getMethodDeclarationNode(getMethod(), rewrite.getRoot());
      DelegateMethodCreator creator = new DelegateMethodCreator();
      creator.setDeclaration(methodDeclaration);
      creator.setDeclareDeprecated(getDeprecateDelegates());
      creator.setSourceRewrite(rewrite);
      creator.setCopy(true);
      creator.setNewElementName(getNewElementName());
      creator.prepareDelegate();
      creator.createEdit();
      CompilationUnitChange cuChange = rewrite.createChange(true);
      if (cuChange != null) {
        cuChange.setKeepPreviewEdits(true);
        manager.manage(getDeclaringCU(), cuChange);
      }
    }

    String editName = RefactoringCoreMessages.RenameMethodRefactoring_update_declaration;
    ISourceRange nameRange = getMethod().getNameRange();
    ReplaceEdit replaceEdit =
        new ReplaceEdit(nameRange.getOffset(), nameRange.getLength(), getNewElementName());
    addTextEdit(manager.get(getDeclaringCU()), editName, replaceEdit);
  }
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:RenameNonVirtualMethodProcessor.java

示例12: addDeclarationUpdate

import org.eclipse.jdt.core.ISourceRange; //导入方法依赖的package包/类
private void addDeclarationUpdate() throws CoreException {
  ISourceRange nameRange = fField.getNameRange();
  TextEdit textEdit =
      new ReplaceEdit(nameRange.getOffset(), nameRange.getLength(), getNewElementName());
  ICompilationUnit cu = fField.getCompilationUnit();
  String groupName = RefactoringCoreMessages.RenameFieldRefactoring_Update_field_declaration;
  addTextEdit(fChangeManager.get(cu), groupName, textEdit);
}
 
开发者ID:eclipse,项目名称:che,代码行数:9,代码来源:RenameFieldProcessor.java

示例13: resolveEnclosingElement

import org.eclipse.jdt.core.ISourceRange; //导入方法依赖的package包/类
public static IJavaElement resolveEnclosingElement(IJavaElement input, ITextSelection selection)
    throws JavaModelException {
  IJavaElement atOffset = null;
  if (input instanceof ICompilationUnit) {
    ICompilationUnit cunit = (ICompilationUnit) input;
    JavaModelUtil.reconcile(cunit);
    atOffset = cunit.getElementAt(selection.getOffset());
  } else if (input instanceof IClassFile) {
    IClassFile cfile = (IClassFile) input;
    atOffset = cfile.getElementAt(selection.getOffset());
  } else {
    return null;
  }
  if (atOffset == null) {
    return input;
  } else {
    int selectionEnd = selection.getOffset() + selection.getLength();
    IJavaElement result = atOffset;
    if (atOffset instanceof ISourceReference) {
      ISourceRange range = ((ISourceReference) atOffset).getSourceRange();
      while (range.getOffset() + range.getLength() < selectionEnd) {
        result = result.getParent();
        if (!(result instanceof ISourceReference)) {
          result = input;
          break;
        }
        range = ((ISourceReference) result).getSourceRange();
      }
    }
    return result;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:33,代码来源:SelectionConverter.java

示例14: convertAnnotations

import org.eclipse.jdt.core.ISourceRange; //导入方法依赖的package包/类
private Annotation[] convertAnnotations(IAnnotatable element) throws JavaModelException {
  IAnnotation[] annotations = element.getAnnotations();
  int length = annotations.length;
  Annotation[] astAnnotations = new Annotation[length];
  if (length > 0) {
    char[] cuSource = getSource();
    int recordedAnnotations = 0;
    for (int i = 0; i < length; i++) {
      ISourceRange positions = annotations[i].getSourceRange();
      int start = positions.getOffset();
      int end = start + positions.getLength();
      char[] annotationSource = CharOperation.subarray(cuSource, start, end);
      if (annotationSource != null) {
        Expression expression = parseMemberValue(annotationSource);
        /*
         * expression can be null or not an annotation if the source has changed between
         * the moment where the annotation source positions have been retrieved and the moment were
         * this parsing occurred.
         * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=90916
         */
        if (expression instanceof Annotation) {
          astAnnotations[recordedAnnotations++] = (Annotation) expression;
        }
      }
    }
    if (length != recordedAnnotations) {
      // resize to remove null annotations
      System.arraycopy(
          astAnnotations,
          0,
          (astAnnotations = new Annotation[recordedAnnotations]),
          0,
          recordedAnnotations);
    }
  }
  return astAnnotations;
}
 
开发者ID:eclipse,项目名称:che,代码行数:38,代码来源:SourceTypeConverter.java

示例15: isMovedReference

import org.eclipse.jdt.core.ISourceRange; //导入方法依赖的package包/类
protected boolean isMovedReference(final SearchMatch match) throws JavaModelException {
	ISourceRange range= null;
	for (int index= 0; index < fMembersToMove.length; index++) {
		range= fMembersToMove[index].getSourceRange();
		if (range.getOffset() <= match.getOffset() && range.getOffset() + range.getLength() >= match.getOffset())
			return true;
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:HierarchyProcessor.java


注:本文中的org.eclipse.jdt.core.ISourceRange.getLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。