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


Java JavaModelUtil.concatenateName方法代码示例

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


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

示例1: getImportName

import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
public static String getImportName(IBinding binding) {
	ITypeBinding declaring= null;
	switch (binding.getKind()) {
	case IBinding.TYPE:
		return getRawQualifiedName((ITypeBinding) binding);
	case IBinding.PACKAGE:
		return binding.getName() + ".*"; //$NON-NLS-1$
	case IBinding.METHOD:
		declaring= ((IMethodBinding) binding).getDeclaringClass();
		break;
	case IBinding.VARIABLE:
		declaring= ((IVariableBinding) binding).getDeclaringClass();
		if (declaring == null) {
			return binding.getName(); // array.length
		}

		break;
	default:
		return binding.getName();
	}
	return JavaModelUtil.concatenateName(getRawQualifiedName(declaring), binding.getName());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:23,代码来源:Bindings.java

示例2: getImportName

import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
public static String getImportName(IBinding binding) {
	ITypeBinding declaring= null;
	switch (binding.getKind()) {
		case IBinding.TYPE:
			return getRawQualifiedName((ITypeBinding) binding);
		case IBinding.PACKAGE:
			return binding.getName() + ".*"; //$NON-NLS-1$
		case IBinding.METHOD:
			declaring= ((IMethodBinding) binding).getDeclaringClass();
			break;
		case IBinding.VARIABLE:
			declaring= ((IVariableBinding) binding).getDeclaringClass();
			if (declaring == null) {
				return binding.getName(); // array.length
			}

			break;
		default:
			return binding.getName();
	}
	return JavaModelUtil.concatenateName(getRawQualifiedName(declaring), binding.getName());
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:Bindings.java

示例3: initialize

import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
private void initialize() throws JavaModelException {
	fQualifiedTypeName= JavaModelUtil.concatenateName(fType.getPackageFragment().getElementName(), fType.getElementName());
	fEnclosingInstanceFieldName= getInitialNameForEnclosingInstanceField();
	fSourceRewrite= new CompilationUnitRewrite(fType.getCompilationUnit());
	fIsInstanceFieldCreationPossible= !(JdtFlags.isStatic(fType) || fType.isAnnotation() || fType.isEnum() || (fType.getDeclaringType() == null && !JavaElementUtil.isMainType(fType)));
	fIsInstanceFieldCreationMandatory= fIsInstanceFieldCreationPossible && isInstanceFieldCreationMandatory();
	fCreateInstanceField= fIsInstanceFieldCreationMandatory;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:MoveInnerToTopRefactoring.java

示例4: createType

import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
public Type createType(boolean asTopLevelClass, CompilationUnitRewrite cuRewrite, int position) {
	String qualifier= asTopLevelClass ? fPackage : fEnclosingType;
	String concatenateName= JavaModelUtil.concatenateName(qualifier, fClassName);
	
	ImportRewrite importRewrite= cuRewrite.getImportRewrite();
	ContextSensitiveImportRewriteContext context= createParameterClassAwareContext(asTopLevelClass, cuRewrite, position);
	String addedImport= importRewrite.addImport(concatenateName, context);
	cuRewrite.getImportRemover().registerAddedImport(addedImport);
	AST ast= cuRewrite.getAST();
	return ast.newSimpleType(ast.newName(addedImport));
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:ParameterObjectFactory.java

示例5: createFieldAccess

import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
private String createFieldAccess() throws JavaModelException {
	String fieldName= fField.getElementName();
	boolean nameConflict= fArgName.equals(fieldName);

	if (JdtFlags.isStatic(fField)) {
		if (nameConflict) {
			return JavaModelUtil.concatenateName(fField.getDeclaringType().getElementName(), fieldName);
		}
	} else {
		if (nameConflict || StubUtility.useThisForFieldAccess(fField.getJavaProject())) {
			return "this." + fieldName; //$NON-NLS-1$
		}
	}
	return fieldName;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:SelfEncapsulateFieldRefactoring.java

示例6: open

import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
public void open() {
	try {
		String returnTypeSignature= fMethod.getReturnType();
		int kind= Signature.getTypeSignatureKind(returnTypeSignature);
		if (kind == Signature.ARRAY_TYPE_SIGNATURE) {
			returnTypeSignature= Signature.getElementType(returnTypeSignature);
		} else if (kind == Signature.CLASS_TYPE_SIGNATURE) {
			returnTypeSignature= Signature.getTypeErasure(returnTypeSignature);
		}
		String returnType= Signature.toString(returnTypeSignature);

		String[][] resolvedType= fMethod.getDeclaringType().resolveType(returnType);
		if (resolvedType == null || resolvedType.length == 0) {
			openMethodAndShowErrorInStatusLine();
			return;
		}

		String typeName= JavaModelUtil.concatenateName(resolvedType[0][0], resolvedType[0][1]);
		IType type= fMethod.getJavaProject().findType(typeName, (IProgressMonitor)null);
		if (type != null) {
			fOpenAction.run(new StructuredSelection(type));
			return;
		}
		openMethodAndShowErrorInStatusLine();
	} catch (JavaModelException e) {
		JavaPlugin.log(e);
		return;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:JavaElementReturnTypeHyperlink.java

示例7: isSameType

import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
private boolean isSameType(ITypeBinding binding, String qualifier, String name) {
	String qualifiedName= JavaModelUtil.concatenateName(qualifier, name);
	return binding.getQualifiedName().equals(qualifiedName);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:5,代码来源:ContextSensitiveImportRewriteContext.java

示例8: createType

import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
private void createType(IPackageFragment pckg, boolean addComments)
    throws CoreException {
  IJavaProject javaProject = pckg.getJavaProject();
  final IProgressMonitor monitor = new NullProgressMonitor();

  // Method name should already have been sanitized and validated, so all we
  // should have to do to get a type name is just capitalize it
  String simpleName = StringUtilities.capitalize(getMethodName());

  // See if the type name is already used
  String qualifiedName = JavaModelUtil.concatenateName(pckg.getElementName(),
      simpleName);
  IType existingType = JavaModelSearch.findType(javaProject, qualifiedName);
  if (existingType != null) {
    if (ClientBundleUtilities.isCssResource(javaProject, existingType)) {
      // If the existing type is a CssResource, we'll assume that it wraps
      // this CSS file and use it for our ClientBundle accessor return type
      // instead of trying to generate another CssResource here.
      customCssResourceType = existingType;
      return;
    } else {
      // If it's not a CssResource, then we'll need to generate a CssResource
      // ourself, but we can't use the name. So, let's compute a similar name
      // that is not already in use.
      simpleName = StringUtilities.computeUniqueName(
          getExistingTopLevelTypeNames(pckg), simpleName);
    }
  }

  // Parse the CSS and see if there were problems
  CssParseResult result = parseCss();
  final IStatus status = result.getStatus();

  // Bail out when errors occur
  if (status.getSeverity() == IStatus.ERROR) {
    throw new CoreException(status);
  }

  // For warnings, just display them in a dialog (on the UI thread of course)
  // TODO: would nice if we could aggregate these and show them all at the end
  if (status.getSeverity() == IStatus.WARNING) {
    Display.getDefault().syncExec(new Runnable() {
      public void run() {
        MessageDialog.openWarning(null, "CSS Parsing", status.getMessage());
      }
    });
  }

  // Extract the CSS class names
  final Set<String> cssClassNames = ExtractClassNamesVisitor.exec(result.getStylesheet());

  TypeCreator gen = new TypeCreator(pckg, simpleName,
      TypeCreator.ElementType.INTERFACE,
      new String[] {ClientBundleUtilities.CSS_RESOURCE_TYPE_NAME},
      addComments) {
    @Override
    protected void createTypeMembers(IType newType, ImportRewrite imports)
        throws CoreException {
      // Create an accessor method for each CSS class
      for (String cssClass : cssClassNames) {
        newType.createMethod(computeCssClassMethodSource(newType, cssClass),
            null, true, monitor);
      }
    }
  };
  customCssResourceType = gen.createType();
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:68,代码来源:GeneratedCssResource.java

示例9: createTopLevelParameterObject

import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
public List<ResourceChange> createTopLevelParameterObject(IPackageFragmentRoot packageFragmentRoot, CreationListener listener) throws CoreException {
	List<ResourceChange> changes= new ArrayList<ResourceChange>();
	IPackageFragment packageFragment= packageFragmentRoot.getPackageFragment(getPackage());
	if (!packageFragment.exists()) {
		changes.add(new CreatePackageChange(packageFragment));
	}
	ICompilationUnit unit= packageFragment.getCompilationUnit(getClassName() + JavaModelUtil.DEFAULT_CU_SUFFIX);
	Assert.isTrue(!unit.exists());
	IJavaProject javaProject= unit.getJavaProject();
	ICompilationUnit workingCopy= unit.getWorkingCopy(null);

	try {
		// create stub with comments and dummy type
		String lineDelimiter= StubUtility.getLineDelimiterUsed(javaProject);
		String fileComment= getFileComment(workingCopy, lineDelimiter);
		String typeComment= getTypeComment(workingCopy, lineDelimiter);
		String content= CodeGeneration.getCompilationUnitContent(workingCopy, fileComment, typeComment, "class " + getClassName() + "{}", lineDelimiter); //$NON-NLS-1$ //$NON-NLS-2$
		workingCopy.getBuffer().setContents(content);

		CompilationUnitRewrite cuRewrite= new CompilationUnitRewrite(workingCopy);
		ASTRewrite rewriter= cuRewrite.getASTRewrite();
		CompilationUnit root= cuRewrite.getRoot();
		AST ast= cuRewrite.getAST();
		ImportRewrite importRewrite= cuRewrite.getImportRewrite();

		// retrieve&replace dummy type with real class
		ListRewrite types= rewriter.getListRewrite(root, CompilationUnit.TYPES_PROPERTY);
		ASTNode dummyType= (ASTNode) types.getOriginalList().get(0);
		String newTypeName= JavaModelUtil.concatenateName(getPackage(), getClassName());
		TypeDeclaration classDeclaration= createClassDeclaration(newTypeName, cuRewrite, listener);
		classDeclaration.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD));
		Javadoc javadoc= (Javadoc) dummyType.getStructuralProperty(TypeDeclaration.JAVADOC_PROPERTY);
		rewriter.set(classDeclaration, TypeDeclaration.JAVADOC_PROPERTY, javadoc, null);
		types.replace(dummyType, classDeclaration, null);

		// Apply rewrites and discard workingcopy
		// Using CompilationUnitRewrite.createChange() leads to strange
		// results
		String charset= ResourceUtil.getFile(unit).getCharset(false);
		Document document= new Document(content);
		try {
			rewriter.rewriteAST().apply(document);
			TextEdit rewriteImports= importRewrite.rewriteImports(null);
			rewriteImports.apply(document);
		} catch (BadLocationException e) {
			throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), RefactoringCoreMessages.IntroduceParameterObjectRefactoring_parameter_object_creation_error, e));
		}
		String docContent= document.get();
		CreateCompilationUnitChange compilationUnitChange= new CreateCompilationUnitChange(unit, docContent, charset);
		changes.add(compilationUnitChange);
	} finally {
		workingCopy.discardWorkingCopy();
	}
	return changes;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:56,代码来源:ParameterObjectFactory.java


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