本文整理汇总了Java中org.eclipse.jdt.internal.core.SourceType类的典型用法代码示例。如果您正苦于以下问题:Java SourceType类的具体用法?Java SourceType怎么用?Java SourceType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SourceType类属于org.eclipse.jdt.internal.core包,在下文中一共展示了SourceType类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: ClassDetails
import org.eclipse.jdt.internal.core.SourceType; //导入依赖的package包/类
public ClassDetails(SourceType javaClassFile, String jarFileName, String packageName, boolean isUserDefined) {
Logger LOGGER = LogFactory.INSTANCE.getLogger(ClassDetails.class);
LOGGER.debug("Extracting methods from " + cName);
try {
this.javaDoc=getJavaDoc(javaClassFile);
intialize(javaClassFile, jarFileName, packageName, isUserDefined);
for (IJavaElement iJavaElement : javaClassFile.getChildren()) {
if (iJavaElement instanceof SourceMethod) {
addMethodsToClass((IMethod) iJavaElement);
}
}
} catch (JavaModelException e) {
LOGGER.error("Error occurred while fetching methods from class" + cName);
}
}
开发者ID:capitalone,项目名称:Hydrograph,代码行数:17,代码来源:ClassDetails.java
示例2: intialize
import org.eclipse.jdt.internal.core.SourceType; //导入依赖的package包/类
private void intialize(SourceType javaClassFile, String jarFileName, String packageName, boolean isUserDefined) {
this.cName=javaClassFile.getElementName();
displayName=cName;
if(StringUtils.isNotBlank(jarFileName)){
jarName=jarFileName;
}
if(StringUtils.isNotBlank(packageName)){
this.packageName=packageName;
}
if(StringUtils.isBlank(javaDoc)){
javaDoc=Constants.EMPTY_STRING;
}
if(isUserDefined){
isUserDefined=true;
displayName=cName+Constants.SRC_CLASS_SUFFIX;
updateJavaDocForSorceClass(jarFileName, packageName);
}
}
开发者ID:capitalone,项目名称:Hydrograph,代码行数:19,代码来源:ClassDetails.java
示例3: handleManifestmainclassBrowse
import org.eclipse.jdt.internal.core.SourceType; //导入依赖的package包/类
/**
* Uses the standard container selection dialog to
* choose the new value for the container field.
*/
private void handleManifestmainclassBrowse() {
String mainClass = getManifestmainclass();
ILabelProvider lp= new WorkbenchLabelProvider();
ITreeContentProvider cp= new WorkbenchContentProvider();
IResource[] res=jproject.getResource();
IJavaSearchScope searchScope= JavaSearchScopeFactory.getInstance().createJavaSearchScope(res, true);
SelectionDialog dialog = JavaUI.createMainTypeDialog(getShell(), getContainer(), searchScope, 0, false);
dialog.setMessage("Select Main-Class for JAR file");
dialog.setTitle("Fat Jar Config");
if (dialog.open() == SelectionDialog.OK) {
Object[] elements= dialog.getResult();
if (elements.length == 1) {
SourceType mainElement = (SourceType)elements[0];
mainClass = mainElement.getFullyQualifiedName();
manifestmainclassText.setText(mainClass);
}
}
}
开发者ID:thahn0720,项目名称:agui_eclipse_plugin,代码行数:28,代码来源:ConfigPage.java
示例4: convert
import org.eclipse.jdt.internal.core.SourceType; //导入依赖的package包/类
private QualifiedAllocationExpression convert(
IJavaElement localType, FieldDeclaration enumConstant, CompilationResult compilationResult)
throws JavaModelException {
TypeDeclaration anonymousLocalTypeDeclaration =
convert((SourceType) localType, compilationResult);
QualifiedAllocationExpression expression =
new QualifiedAllocationExpression(anonymousLocalTypeDeclaration);
expression.type = anonymousLocalTypeDeclaration.superclass;
anonymousLocalTypeDeclaration.superclass = null;
anonymousLocalTypeDeclaration.superInterfaces = null;
anonymousLocalTypeDeclaration.allocation = expression;
if (enumConstant != null) {
anonymousLocalTypeDeclaration.modifiers &= ~ClassFileConstants.AccEnum;
expression.enumConstant = enumConstant;
expression.type = null;
}
return expression;
}
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:SourceTypeConverter.java
示例5: getJavaDoc
import org.eclipse.jdt.internal.core.SourceType; //导入依赖的package包/类
private String getJavaDoc(SourceType javaClassFile) throws JavaModelException {
StringBuffer source = new StringBuffer(javaClassFile.getSource());
try {
String javaDoc = StringUtils.substring(source.toString(), 0, javaClassFile.getJavadocRange().getLength());
javaDoc = StringUtils.replaceEachRepeatedly(javaDoc, new String[] { "/*", "*/", "*" },
new String[] { Constants.EMPTY_STRING, Constants.EMPTY_STRING, Constants.EMPTY_STRING });
} catch (Exception exception) {
LOGGER.warn("Failed to build java-doc for :{}", javaClassFile);
}
return javaDoc;
}
开发者ID:capitalone,项目名称:Hydrograph,代码行数:12,代码来源:ClassDetails.java
示例6: handleManifestmainclassBrowse
import org.eclipse.jdt.internal.core.SourceType; //导入依赖的package包/类
/**
* Uses the standard container selection dialog to choose the new value for
* the container field.
*/
private void handleManifestmainclassBrowse() {
try {
String mainClass = getManifestmainclass();
ILabelProvider lp = new WorkbenchLabelProvider();
ITreeContentProvider cp = new WorkbenchContentProvider();
IResource[] res = { jproject.getCorrespondingResource() };
IJavaSearchScope searchScope = JavaSearchScopeFactory.getInstance().createJavaSearchScope(res, true);
SelectionDialog dialog = JavaUI.createMainTypeDialog(getShell(), getContainer(), searchScope, 0, false);
dialog.setMessage("Select Main-Class for JAR file");
dialog.setTitle("Fat Jar Config");
if (dialog.open() == SelectionDialog.OK) {
Object[] elements = dialog.getResult();
if (elements.length == 1) {
SourceType mainElement = (SourceType) elements[0];
mainClass = mainElement.getFullyQualifiedName();
manifestmainclassText.setText(mainClass);
}
}
} catch (JavaModelException e) {
e.printStackTrace();
}
}
开发者ID:thahn0720,项目名称:agui_eclipse_plugin,代码行数:31,代码来源:FJExportWizardConfigPage.java
示例7: createTypeHandle
import org.eclipse.jdt.internal.core.SourceType; //导入依赖的package包/类
protected SourceType createTypeHandle(JavaElement parent, TypeInfo typeInfo) {
String nameString= new String(typeInfo.name);
AssistSourceType type = new AssistSourceType(parent, nameString, this.bindingCache, this.newElements);
if (typeInfo.node.binding != null) {
this.bindingCache.put(type, typeInfo.node.binding);
this.elementCache.put(typeInfo.node.binding, type);
} else {
this.elementWithProblemCache.put(typeInfo.node, type);
}
return type;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:CompletionUnitStructureRequestor.java
示例8: MatchLocator
import org.eclipse.jdt.internal.core.SourceType; //导入依赖的package包/类
public MatchLocator(
SearchPattern pattern,
SearchRequestor requestor,
IJavaSearchScope scope,
IProgressMonitor progressMonitor) {
this.pattern = pattern;
this.patternLocator = PatternLocator.patternLocator(this.pattern);
this.matchContainer = this.patternLocator == null ? 0 : this.patternLocator.matchContainer();
this.requestor = requestor;
this.scope = scope;
this.progressMonitor = progressMonitor;
if (pattern instanceof PackageDeclarationPattern) {
this.searchPackageDeclaration = true;
} else if (pattern instanceof OrPattern) {
this.searchPackageDeclaration = ((OrPattern)pattern).hasPackageDeclaration();
} else {
this.searchPackageDeclaration = false;
}
if (pattern instanceof MethodPattern) {
IType type = ((MethodPattern) pattern).declaringType;
if (type != null && !type.isBinary()) {
SourceType sourceType = (SourceType) type;
IMember local = sourceType.getOuterMostLocalContext();
if (local instanceof IMethod) { // remember this method's range so we don't purge its statements.
try {
ISourceRange range = local.getSourceRange();
this.sourceStartOfMethodToRetain = range.getOffset();
this.sourceEndOfMethodToRetain = this.sourceStartOfMethodToRetain + range.getLength() - 1; // offset is 0 based.
} catch (JavaModelException e) {
// drop silently.
}
}
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:37,代码来源:MatchLocator.java
示例9: calculateSizeModifiedMethods
import org.eclipse.jdt.internal.core.SourceType; //导入依赖的package包/类
public void calculateSizeModifiedMethods() {
for (StereotypeIdentifier identifier : identifiers) {
try {
if (null != identifier.getCompilationUnit() && identifier.getCompilationUnit().exists()) {
IType[] allTypes = identifier.getCompilationUnit().getAllTypes();
for (IType iType : allTypes) {
if(iType.isAnonymous()) {
System.out.println("INNER");
}
IMethod[] methods = iType.getMethods();
if (methods != null) {
//se acumula la cantidad total de métodos afectados por el conjunto de cambios.
total += methods.length;
}
IJavaElement[] children = iType.getChildren();
for (IJavaElement childrenElement : children) {
if(childrenElement instanceof SourceType) {
total += ((SourceType) childrenElement).getMethods().length;
}
}
}
}
} catch (JavaModelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
System.out.println("Total methods: " + total);
}
开发者ID:SEMERU-WM,项目名称:ChangeScribe,代码行数:31,代码来源:Impact.java
示例10: addClass
import org.eclipse.jdt.internal.core.SourceType; //导入依赖的package包/类
public void addClass(SourceType javaFile, String jarFileName, String packageName, boolean isUserDefined) {
classList.add(new ClassDetails(javaFile, jarFileName, packageName,isUserDefined));
}
开发者ID:capitalone,项目名称:Hydrograph,代码行数:4,代码来源:ClassRepo.java
示例11: searchImpactSet
import org.eclipse.jdt.internal.core.SourceType; //导入依赖的package包/类
public void searchImpactSet() {
for (final StereotypeIdentifier identifier : identifiers) {
SearchRequestor findMethod = new SearchRequestor() {
@SuppressWarnings("unused")
@Override
public void acceptSearchMatch(SearchMatch match) throws CoreException {
IJavaElement type = null;
if(match.getElement() instanceof SourceType) {
addMatched(identifier, match);
} else if(match.getElement() instanceof ResolvedSourceType) {
type = ((ResolvedSourceType )match.getElement()).getParent();
addMatched(identifier, match);
} else if(match.getElement() instanceof ResolvedSourceField) {
type = ((ResolvedSourceField)match.getElement()).getParent();
addMatched(identifier, match);
} else if(match.getElement() instanceof ResolvedSourceMethod) {
type = ((ResolvedSourceMethod)match.getElement()).getParent();
addMatched(identifier, match);
}
}
};
SearchEngine engine = new SearchEngine();
IJavaSearchScope workspaceScope = null;
if(getProject() != null) {
workspaceScope = SearchEngine.createJavaSearchScope(createSearchScope());
} else {
workspaceScope = SearchEngine.createWorkspaceScope();
}
String typeName = Constants.EMPTY_STRING;
if(null != identifier.getCompilationUnit() && identifier.getCompilationUnit().findPrimaryType() != null) {
typeName = identifier.getCompilationUnit().findPrimaryType().getElementName();
} else {
if(null != identifier.getCompilationUnit()) {
typeName = identifier.getCompilationUnit().getElementName();
if(typeName.endsWith(Constants.JAVA_EXTENSION)) {
typeName = typeName.replace(Constants.JAVA_EXTENSION, Constants.EMPTY_STRING);
}
}
}
SearchPattern pattern = SearchPattern
.createPattern(
typeName,
IJavaSearchConstants.TYPE,
IJavaSearchConstants.REFERENCES,
SearchPattern.R_EXACT_MATCH);
SearchParticipant[] participant = new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() };
try {
engine.search(pattern, participant, workspaceScope, findMethod, new NullProgressMonitor());
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
开发者ID:SEMERU-WM,项目名称:ChangeScribe,代码行数:58,代码来源:Impact.java
示例12: calculateImpactPercenje
import org.eclipse.jdt.internal.core.SourceType; //导入依赖的package包/类
public void calculateImpactPercenje() {
double total = 0d;
for(StereotypeIdentifier identifier : identifiers) {
double methods = 0d;
if(identifier.getRelatedTypes() != null) {
for(SearchMatch match : identifier.getRelatedTypes()) {
IType[] types = null;
try {
if(match.getElement() instanceof SourceType) {
types = ((SourceType) match.getElement()).getCompilationUnit().getAllTypes();
} else if(match.getElement() instanceof ResolvedSourceField) {
types = ((SourceField) match.getElement()).getCompilationUnit().getAllTypes();
} else if(match.getElement() instanceof ResolvedSourceMethod) {
types = ((SourceMethod) match.getElement()).getCompilationUnit().getAllTypes();
} else {
System.out.println("hola");
}
for (IType iType : types) {
IType type = null;
@SuppressWarnings("unused")
String typeName = Constants.EMPTY_STRING;
if(identifier.getCompilationUnit().getAllTypes() != null && identifier.getCompilationUnit().getAllTypes().length > 0) {
type = identifier.getCompilationUnit().getAllTypes()[0];
typeName = type.getFullyQualifiedName();
}
methods += iType.getMethods().length;
}
} catch (JavaModelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
identifier.setImpactPercentaje((methods / getTotal()) * 100);
} else {
identifier.setImpactPercentaje(0d);
}
total += identifier.getImpactPercentaje();
System.out.println("Impact (" + methods + " / " + getTotal() + ")" + identifier.getCompilationUnit().getElementName() + ": " + identifier.getImpactPercentaje());
}
System.out.println(total);
}
开发者ID:SEMERU-WM,项目名称:ChangeScribe,代码行数:42,代码来源:Impact.java
注:本文中的org.eclipse.jdt.internal.core.SourceType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论