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


Java VariableElement.getEnclosingElement方法代码示例

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


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

示例1: visitVariable

import javax.lang.model.element.VariableElement; //导入方法依赖的package包/类
@Override
public StringBuilder visitVariable(VariableElement e, Boolean p) {
    if (p != Boolean.TRUE || e.getEnclosingElement() == null) {
        return DEFAULT_VALUE.append(e.getSimpleName());
    } else {
        return e.getEnclosingElement().accept(this, p).
            append(".").
            append(e.getSimpleName());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ElementUtilities.java

示例2: visitVariable

import javax.lang.model.element.VariableElement; //导入方法依赖的package包/类
@Override
public Void visitVariable(VariableElement e, Boolean highlightName) {
    modifier(e.getModifiers());
    
    result.append(getTypeName(info, e.asType(), true));
    
    result.append(' ');
    
    boldStartCheck(highlightName);

    result.append(e.getSimpleName());
    
    boldStopCheck(highlightName);
    
    if (highlightName) {
        if (e.getConstantValue() != null) {
            result.append(" = ");
            result.append(StringEscapeUtils.escapeHtml(e.getConstantValue().toString()));
        }
        
        Element enclosing = e.getEnclosingElement();
        
        if (e.getKind() != ElementKind.PARAMETER && e.getKind() != ElementKind.LOCAL_VARIABLE
                && e.getKind() != ElementKind.RESOURCE_VARIABLE && e.getKind() != ElementKind.EXCEPTION_PARAMETER) {
            result.append(" in ");

            //short typename:
            result.append(getTypeName(info, enclosing.asType(), true));
        }
    }
    
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:GoToSupport.java

示例3: generate

import javax.lang.model.element.VariableElement; //导入方法依赖的package包/类
public boolean generate(VariableElement variableElement, List<ClassGeneratingParams> classGeneratingParamsList) {
	final Element enclosingElement = variableElement.getEnclosingElement();

	if (!(enclosingElement instanceof TypeElement)) {
		throw new RuntimeException("Only class fields could be annotated as @InjectPresenter: " + variableElement + " at " + enclosingElement);
	}

	if (mPresentersContainers.contains(enclosingElement)) {
		return false;
	}

	TypeElement presentersContainer = (TypeElement) enclosingElement;

	mPresentersContainers.add(presentersContainer);

	String fullClassName = Util.getFullClassName(presentersContainer);

	ClassGeneratingParams classGeneratingParams = new ClassGeneratingParams();
	classGeneratingParams.setName(fullClassName + MvpProcessor.PRESENTER_BINDER_SUFFIX);

	String parentClassName = presentersContainer.toString();

	final String viewClassName = fullClassName.substring(fullClassName.lastIndexOf(".") + 1);

	String builder = "package " + fullClassName.substring(0, fullClassName.lastIndexOf(".")) + ";\n" +
	                 "\n" +
	                 "import java.util.ArrayList;\n" +
	                 "import java.util.List;\n" +
	                 "\n" +
	                 "import com.arellomobile.mvp.PresenterBinder;\n" +
	                 "import com.arellomobile.mvp.presenter.PresenterField;\n" +
	                 "import com.arellomobile.mvp.MvpPresenter;\n" +
	                 "import com.arellomobile.mvp.presenter.PresenterType;\n" +
	                 "\n" +
	                 "public class " + viewClassName + MvpProcessor.PRESENTER_BINDER_SUFFIX + " extends PresenterBinder<" + parentClassName + "> {\n";

	List<Field> fields = collectFields(presentersContainer);

	List<PresenterProvider> presenterProviders = collectPresenterProviders(presentersContainer);

	List<TagProvider> tagProviders = collectTagProviders(presentersContainer);

	bindProvidersToFields(fields, presenterProviders);

	bindTagProvidersToFields(fields, tagProviders);

	for (Field field : fields) {
		builder = generatePresenterBinderClass(builder, parentClassName, field);
	}

	builder = generateGetPresentersMethod(builder, fields, parentClassName);

	builder += "}\n";

	classGeneratingParams.setBody(builder);
	classGeneratingParamsList.add(classGeneratingParams);

	return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:60,代码来源:PresenterBinderClassGenerator.java

示例4: getDeclaringClassForField

import javax.lang.model.element.VariableElement; //导入方法依赖的package包/类
public TypeElement getDeclaringClassForField(VariableElement f) {
    return (TypeElement) f.getEnclosingElement();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:ApNavigator.java


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