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


Java Util.getNameWithoutJavaLikeExtension方法代码示例

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


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

示例1: JavaSearchNameEnvironment

import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
public JavaSearchNameEnvironment(IJavaProject javaProject, org.eclipse.jdt.core.ICompilationUnit[] copies) {
	computeClasspathLocations(javaProject.getProject().getWorkspace().getRoot(), (JavaProject) javaProject);
	try {
		int length = copies == null ? 0 : copies.length;
		this.workingCopies = new HashMap(length);
		if (copies != null) {
			for (int i = 0; i < length; i++) {
				org.eclipse.jdt.core.ICompilationUnit workingCopy = copies[i];
				IPackageDeclaration[] pkgs = workingCopy.getPackageDeclarations();
				String pkg = pkgs.length > 0 ? pkgs[0].getElementName() : ""; //$NON-NLS-1$
				String cuName = workingCopy.getElementName();
				String mainTypeName = Util.getNameWithoutJavaLikeExtension(cuName);
				String qualifiedMainTypeName = pkg.length() == 0 ? mainTypeName : pkg.replace('.', '/') + '/' + mainTypeName;
				this.workingCopies.put(qualifiedMainTypeName, workingCopy);
			}
		}
	} catch (JavaModelException e) {
		// working copy doesn't exist: cannot happen
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:JavaSearchNameEnvironment.java

示例2: findPrimaryType

import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
/**
 * @see ICompilationUnit#findPrimaryType()
 */
public IType findPrimaryType() {
	String typeName = Util.getNameWithoutJavaLikeExtension(getElementName());
	IType primaryType= getType(typeName);
	if (primaryType.exists()) {
		return primaryType;
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:CompilationUnit.java

示例3: updateTypeName

import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
/**
 * Renames the main type in <code>cu</code>.
 */
private void updateTypeName(ICompilationUnit cu, CompilationUnit astCU, String oldName, String newName, ASTRewrite rewriter) throws JavaModelException {
	if (newName != null) {
		String oldTypeName= Util.getNameWithoutJavaLikeExtension(oldName);
		String newTypeName= Util.getNameWithoutJavaLikeExtension(newName);
		AST ast = astCU.getAST();
		// update main type name
		IType[] types = cu.getTypes();
		for (int i = 0, max = types.length; i < max; i++) {
			IType currentType = types[i];
			if (currentType.getElementName().equals(oldTypeName)) {
				AbstractTypeDeclaration typeNode = (AbstractTypeDeclaration) ((JavaElement) currentType).findNode(astCU);
				if (typeNode != null) {
					// rename type
					rewriter.replace(typeNode.getName(), ast.newSimpleName(newTypeName), null);
					// rename constructors
					Iterator bodyDeclarations = typeNode.bodyDeclarations().iterator();
					while (bodyDeclarations.hasNext()) {
						Object bodyDeclaration = bodyDeclarations.next();
						if (bodyDeclaration instanceof MethodDeclaration) {
							MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclaration;
							if (methodDeclaration.isConstructor()) {
								SimpleName methodName = methodDeclaration.getName();
								if (methodName.getIdentifier().equals(oldTypeName)) {
									rewriter.replace(methodName, ast.newSimpleName(newTypeName), null);
								}
							}
						}
					}
				}
			}
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:37,代码来源:CopyResourceElementsOperation.java

示例4: removeJavaLikeExtension

import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
/**
 * Removes the file extension from the given file name, if it has a Java-like file
 * extension. Otherwise the file name itself is returned.
 * Note this removes the dot ('.') before the extension as well.
 *
 * @param fileName the name of a file
 * @return the fileName without the Java-like extension
 * @since 3.2
 */
public static String removeJavaLikeExtension(String fileName) {
	return Util.getNameWithoutJavaLikeExtension(fileName);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:JavaCore.java


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