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


Java CompilationUnit类代码示例

本文整理汇总了Java中org.eclipse.gmt.modisco.java.CompilationUnit的典型用法代码示例。如果您正苦于以下问题:Java CompilationUnit类的具体用法?Java CompilationUnit怎么用?Java CompilationUnit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createAnnotation

import org.eclipse.gmt.modisco.java.CompilationUnit; //导入依赖的package包/类
/**
 * Create an annotation and add it to the current parameter
 * 
 * @param packageName
 *            the name of the package of the current parameter.
 * @param annotationName
 *            the annotation name.
 * @return the created java annotation.
 */
public JavaAnnotation createAnnotation(String packageName, String annotationName) {
	CompilationUnit compilationUnit = this.getDelegate() == null ? null : this.getDelegate()
			.getOriginalCompilationUnit();

	TypeAccess annotationType = compilationUnit != null ? TypeAccessHelper.createAnnotationTypeAccess(this,
			packageName, annotationName) : TypeAccessHelper.createOrphanAnnotationTypeAccess(this, packageName
			+ "." + annotationName);

	Annotation annotation = AnnotationBuilder.builder().setCompilationUnit(compilationUnit).setType(annotationType)
			.build();

	this.getDelegate().getAnnotations().add(annotation);

	if (compilationUnit != null) {
		MissingImportAdder.addMissingImport(compilationUnit, annotationType.getType());
	}

	return new JavaAnnotation(annotation);
}
 
开发者ID:awltech,项目名称:eclipse-optimus,代码行数:29,代码来源:Parameter.java

示例2: createAnnotation

import org.eclipse.gmt.modisco.java.CompilationUnit; //导入依赖的package包/类
/**
 * Create an annotation and add it to the current array initializer
 * instruction
 * 
 * @param packageName
 *            the name of the package of the current array initializer
 *            instruction.
 * @param annotationName
 *            the annotation name.
 * @return the created java annotation.
 */
public JavaAnnotation createAnnotation(String packageName, String annotationName) {
	CompilationUnit compilationUnit = this.getDelegate() == null ? null : this.getDelegate()
			.getOriginalCompilationUnit();

	TypeAccess annotationType = compilationUnit != null ? TypeAccessHelper.createAnnotationTypeAccess(this,
			packageName, annotationName) : TypeAccessHelper.createOrphanAnnotationTypeAccess(this, packageName
			+ "." + annotationName);

	Annotation annotation = AnnotationBuilder.builder().setCompilationUnit(compilationUnit).setType(annotationType)
			.build();

	((ArrayInitializer) this.getDelegate()).getExpressions().add(annotation);

	if (compilationUnit != null) {
		MissingImportAdder.addMissingImport(compilationUnit, annotationType.getType());
	}

	return new JavaAnnotation(annotation);
}
 
开发者ID:awltech,项目名称:eclipse-optimus,代码行数:31,代码来源:ArrayInitializerInstruction.java

示例3: addMissingImport

import org.eclipse.gmt.modisco.java.CompilationUnit; //导入依赖的package包/类
/**
 * Adds import if missing in the compilation unit for the provided type
 * 
 * @param compilationUnit
 *            the compilation unit.
 * @param type
 *            the type.
 */
public static void addMissingImport(CompilationUnit compilationUnit, Type type) {
	if (type instanceof UnresolvedAnnotationDeclaration || compilationUnit == null) {
		return;
	}

	boolean hasMatchingImport = false;
	Iterator<ImportDeclaration> importIterator = compilationUnit.getImports().iterator();
	while (importIterator.hasNext() && hasMatchingImport == false) {
		hasMatchingImport = importIterator.next().getImportedElement().equals(type);
	}

	if (!hasMatchingImport) {
		ImportDeclaration declaration = ImportDeclarationBuilder.builder().setImportedElement(type).build();
		compilationUnit.getImports().add(declaration);
	}
}
 
开发者ID:awltech,项目名称:eclipse-optimus,代码行数:25,代码来源:MissingImportAdder.java

示例4: createAnnotation

import org.eclipse.gmt.modisco.java.CompilationUnit; //导入依赖的package包/类
/**
 * Create an annotation and add it to the current array initializer
 * instruction
 * 
 * @param packageName
 *            the name of the package of the current array initializer
 *            instruction.
 * @param annotationName
 *            the annotation name.
 * @return the created java annotation.
 */
public JavaAnnotation createAnnotation(String packageName, String annotationName, String propertyName) {
	Annotation annotation = this.getDelegate();
	CompilationUnit compilationUnit = this.getDelegate() == null ? null : this.getDelegate()
			.getOriginalCompilationUnit();
	AnnotationMemberValuePair pair = null;
	if (annotation.getValues().size() == 0) {
		pair = JavaFactory.eINSTANCE.createAnnotationMemberValuePair();
		if (propertyName != null) {
			AnnotationTypeMemberDeclaration annotationTypeMemberDeclaration = AnnotationTypeMemberDeclarationHelper
					.createTypeMemberDeclaration(annotation, propertyName);
			pair.setMember(annotationTypeMemberDeclaration);
		}
		annotation.getValues().add(pair);
	} else
		pair = annotation.getValues().get(0);
	ArrayInitializer initializer = null;
	if (pair.getValue() == null || !(pair.getValue() instanceof ArrayInitializer)) {
		initializer = JavaFactory.eINSTANCE.createArrayInitializer();
		pair.setValue(initializer);
		initializer.setOriginalCompilationUnit(compilationUnit);
	} else
		initializer = (ArrayInitializer) pair.getValue();
	return new ArrayInitializerInstruction(initializer).createAnnotation(packageName, annotationName);
}
 
开发者ID:awltech,项目名称:eclipse-optimus,代码行数:36,代码来源:JavaAnnotation.java

示例5: queryCommentsTagContent

import org.eclipse.gmt.modisco.java.CompilationUnit; //导入依赖的package包/类
public static Query<Integer> queryCommentsTagContent(Resource resource) {
    return () -> {
        Set<TextElement> result = new HashSet<>();

        try {
            Model model = (Model) resource.getContents().get(0);
            if (model.getName().equals("org.eclipse.gmt.modisco.java.neoemf") || model.getName().equals("org.eclipse.jdt.core")) {
                for (CompilationUnit cu : model.getCompilationUnits()) {
                    for (Comment comment : cu.getCommentList()) {
                        if (comment instanceof Javadoc) {
                            Javadoc javadoc = (Javadoc) comment;
                            for (TagElement te : javadoc.getTags()) {
                                for (ASTNode node : te.getFragments()) {
                                    if (node instanceof TextElement) {
                                        result.add((TextElement) node);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        catch (NullPointerException e) {
            log.error("Null pointer", e);
        }

        return result.size();
    };
}
 
开发者ID:atlanmod,项目名称:NeoEMF,代码行数:31,代码来源:QueryFactoryASE2015.java

示例6: chunkPackage

import org.eclipse.gmt.modisco.java.CompilationUnit; //导入依赖的package包/类
/**
 * Update the processed package
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
private static void chunkPackage(final Package pack) {
	final String name = pack.getName();
	final String[] nameChunks = name.split("\\.");
	if (nameChunks.length > 1) {
		final Package[] packages = new Package[nameChunks.length];
		packages[0] = pack;
		pack.setName(nameChunks[0]);
		for (int i = 1; i < nameChunks.length; i++) {
			final Package packageChunk = JavaFactory.eINSTANCE.createPackage();
			packageChunk.setName(nameChunks[i]);
			packages[i] = packageChunk;
			packageChunk.setPackage(packages[i - 1]);
		}
		final Package lastPackage = packages[nameChunks.length - 1];
		final Collection<EObject> contentsToProcess = new ArrayList<EObject>();
		contentsToProcess.addAll(pack.eContents());
		for (final EObject eObject : contentsToProcess)
			if (!(eObject instanceof Package)) {
				final EReference eReference = eObject.eContainmentFeature();
				if (eReference.isMany())
					((EList) lastPackage.eGet(eReference)).add(eObject);
				else
					lastPackage.eSet(eReference, eObject);
			}
		for (final CompilationUnit compilationUnit : pack.getModel().getCompilationUnits())
			if (compilationUnit.getPackage() == pack)
				compilationUnit.setPackage(lastPackage);
	}
}
 
开发者ID:awltech,项目名称:eclipse-optimus,代码行数:34,代码来源:PackageChunker.java

示例7: createAnnotation

import org.eclipse.gmt.modisco.java.CompilationUnit; //导入依赖的package包/类
/**
 * Create an annotation and add it to the current abstract declaration
 * 
 * @param packageName
 *            the name of the package of the annotation.
 * @param annotationName
 *            the annotation name.
 * @return the created java annotation.
 */
public JavaAnnotation createAnnotation(String packageName, String annotationName) {
	CompilationUnit compilationUnit = this.getDelegate() == null ? null : this.getDelegate()
			.getOriginalCompilationUnit();
	TypeAccess annotationType = compilationUnit != null ? TypeAccessHelper.createAnnotationTypeAccess(this,
			packageName, annotationName) : TypeAccessHelper.createOrphanAnnotationTypeAccess(this, packageName
			+ "." + annotationName);
	Annotation annotation = AnnotationBuilder.builder().setCompilationUnit(compilationUnit).setType(annotationType)
			.build();
	if (this.getDelegate() != null) {
		this.getDelegate().getAnnotations().add(annotation);
		MissingImportAdder.addMissingImport(this.getDelegate(), annotationType.getType());
	}
	return new JavaAnnotation(annotation);
}
 
开发者ID:awltech,项目名称:eclipse-optimus,代码行数:24,代码来源:AbstractDeclaration.java

示例8: InterfaceHelper

import org.eclipse.gmt.modisco.java.CompilationUnit; //导入依赖的package包/类
/**
 * Private constructor : a new interface (public, proxy state set to false,
 * no interface and abstract state set to false by default)
 * 
 * @param javaPackage
 *            the package a the interface under construction.
 * @param interfaceName
 *            the name of the interface under construction.
 */
private InterfaceHelper(JavaPackage javaPackage, String interfaceName) {
	org.eclipse.gmt.modisco.java.Package internalPackage = javaPackage.getDelegate();
	CompilationUnit compilationUnit = CompilationUnitBuilder.builder().setName(interfaceName + ".java")
			.setPackage(internalPackage).build();
	Modifier modifier = ModifierBuilder.builder().setVisibility(VisibilityKind.PUBLIC)
			.setInheritance(InheritanceKind.NONE).setCompilationUnit(compilationUnit).build();
	this.buildInterface = InterfaceDeclarationBuilder.builder().setName(interfaceName).setPackage(internalPackage)
			.setProxy(false).setModifier(modifier).setCompilationUnit(compilationUnit).build();
	TypeParameterHelper.addTypeParametersToTypeDeclaration(this.buildInterface);
	compilationUnit.getTypes().add(this.buildInterface);
	ASTElementFinder.findModel(internalPackage).getCompilationUnits().add(compilationUnit);
}
 
开发者ID:awltech,项目名称:eclipse-optimus,代码行数:22,代码来源:InterfaceHelper.java

示例9: ClassHelper

import org.eclipse.gmt.modisco.java.CompilationUnit; //导入依赖的package包/类
/**
 * Private constructor : a new class (public, proxy state set to false, no
 * super class, no interface and inheritance state set to none by default)
 * 
 * @param javaPackage
 *            the package a the class under construction.
 * @param className
 *            the name of the class under construction.
 */
private ClassHelper(JavaPackage javaPackage, String className) {
	org.eclipse.gmt.modisco.java.Package internalPackage = javaPackage.getDelegate();
	CompilationUnit compilationUnit = CompilationUnitBuilder.builder().setName(className + ".java")
			.setPackage(internalPackage).build();
	Modifier modifier = ModifierBuilder.builder().setVisibility(VisibilityKind.PUBLIC)
			.setInheritance(InheritanceKind.NONE).setCompilationUnit(compilationUnit).build();
	this.buildClass = ClassDeclarationBuilder.builder().setName(className).setPackage(internalPackage)
			.setProxy(false).setModifier(modifier).setCompilationUnit(compilationUnit).build();
	compilationUnit.getTypes().add(this.buildClass);
	TypeParameterHelper.addTypeParametersToTypeDeclaration(this.buildClass);
	ASTElementFinder.findModel(internalPackage).getCompilationUnits().add(compilationUnit);
}
 
开发者ID:awltech,项目名称:eclipse-optimus,代码行数:22,代码来源:ClassHelper.java

示例10: EnumHelper

import org.eclipse.gmt.modisco.java.CompilationUnit; //导入依赖的package包/类
/**
 * Private constructor : a new enumeration (public, proxy state set to false
 * and no interface by default)
 * 
 * @param javaPackage
 *            the package a the enumeration under construction.
 * @param enumName
 *            the name of the enumeration under construction.
 */
private EnumHelper(JavaPackage javaPackage, String enumName) {
	org.eclipse.gmt.modisco.java.Package internalPackage = javaPackage.getDelegate();
	CompilationUnit compilationUnit = CompilationUnitBuilder.builder().setName(enumName + ".java")
			.setPackage(internalPackage).build();
	Modifier modifier = ModifierBuilder.builder().setVisibility(VisibilityKind.PUBLIC)
			.setInheritance(InheritanceKind.NONE).setCompilationUnit(compilationUnit).build();
	this.buildEnum = EnumDeclarationBuilder.builder().setName(enumName).setPackage(internalPackage).setProxy(false)
			.setModifier(modifier).setCompilationUnit(compilationUnit).build();
	compilationUnit.getTypes().add(this.buildEnum);
	ASTElementFinder.findModel(internalPackage).getCompilationUnits().add(compilationUnit);
}
 
开发者ID:awltech,项目名称:eclipse-optimus,代码行数:21,代码来源:EnumHelper.java

示例11: getOriginalCompilationUnit

import org.eclipse.gmt.modisco.java.CompilationUnit; //导入依赖的package包/类
public CompilationUnit getOriginalCompilationUnit() {
	return null;
}
 
开发者ID:markus1978,项目名称:srcrepo,代码行数:4,代码来源:PendingElement.java

示例12: setOriginalCompilationUnit

import org.eclipse.gmt.modisco.java.CompilationUnit; //导入依赖的package包/类
public void setOriginalCompilationUnit(final CompilationUnit value) {
	return;
}
 
开发者ID:markus1978,项目名称:srcrepo,代码行数:4,代码来源:PendingElement.java

示例13: getCompilationUnit

import org.eclipse.gmt.modisco.java.CompilationUnit; //导入依赖的package包/类
public CompilationUnit getCompilationUnit() {
	return this.getDelegate().getOriginalCompilationUnit();
}
 
开发者ID:awltech,项目名称:eclipse-optimus,代码行数:4,代码来源:AbstractMethod.java

示例14: getOriginalCompilationUnit

import org.eclipse.gmt.modisco.java.CompilationUnit; //导入依赖的package包/类
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public CompilationUnit getOriginalCompilationUnit() {
	return (CompilationUnit)eGet(JavaPackage.eINSTANCE.getASTNode_OriginalCompilationUnit(), true);
}
 
开发者ID:markus1978,项目名称:srcrepo,代码行数:9,代码来源:ASTNodeImpl.java

示例15: setOriginalCompilationUnit

import org.eclipse.gmt.modisco.java.CompilationUnit; //导入依赖的package包/类
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setOriginalCompilationUnit(CompilationUnit newOriginalCompilationUnit) {
	eSet(JavaPackage.eINSTANCE.getASTNode_OriginalCompilationUnit(), newOriginalCompilationUnit);
}
 
开发者ID:markus1978,项目名称:srcrepo,代码行数:9,代码来源:ASTNodeImpl.java


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