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


Java IClassFile类代码示例

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


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

示例1: classFileNavigation

import org.eclipse.jdt.core.IClassFile; //导入依赖的package包/类
private OpenDeclarationDescriptor classFileNavigation(IClassFile classFile, IJavaElement element)
    throws JavaModelException {
  OpenDeclarationDescriptor dto =
      DtoFactory.getInstance().createDto(OpenDeclarationDescriptor.class);
  dto.setPath(classFile.getType().getFullyQualifiedName());
  dto.setLibId(classFile.getAncestor(IPackageFragmentRoot.PACKAGE_FRAGMENT_ROOT).hashCode());
  dto.setBinary(true);
  if (classFile.getSourceRange() != null) {
    if (element instanceof ISourceReference) {
      ISourceRange nameRange = ((ISourceReference) element).getNameRange();
      dto.setOffset(nameRange.getOffset());
      dto.setLength(nameRange.getLength());
    }
  }
  return dto;
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:JavaNavigation.java

示例2: createJavaProjectThroughActiveEditor

import org.eclipse.jdt.core.IClassFile; //导入依赖的package包/类
private IJavaProject createJavaProjectThroughActiveEditor() {
	
	IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	 	    if(page.getActiveEditor().getEditorInput() instanceof IFileEditorInput)
	 	    {	
	 		IFileEditorInput input = (IFileEditorInput) page.getActiveEditor().getEditorInput();
	 		IFile file = input.getFile();
	 		IProject activeProject = file.getProject();
	 		IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(activeProject.getName());
	 		return JavaCore.create(project);
	 	    }
	 	    else if(page.getActiveEditor().getEditorInput() instanceof IClassFileEditorInput)
	 	    {
	  IClassFileEditorInput classFileEditorInput=(InternalClassFileEditorInput)page.getActiveEditor().getEditorInput() ;
	  IClassFile classFile=classFileEditorInput.getClassFile();
	  return classFile.getJavaProject();
	 	    }
	 	    return null;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:20,代码来源:ValidatorUtility.java

示例3: createClassRepo

import org.eclipse.jdt.core.IClassFile; //导入依赖的package包/类
public void createClassRepo(String jarFileName, String Package) {
	ClassRepo.INSTANCE.flusRepo();
	try {
		IPackageFragmentRoot iPackageFragmentRoot = getIPackageFragment(jarFileName);
		if (iPackageFragmentRoot != null) {
			IPackageFragment fragment = iPackageFragmentRoot.getPackageFragment(Package);
			if (fragment != null) {
				for (IClassFile element : fragment.getClassFiles()) {
					ClassRepo.INSTANCE.addClass(element,"","",false);
				}
			} else {
				new CustomMessageBox(SWT.ERROR, Package + " Package not found in jar "
						+ iPackageFragmentRoot.getElementName(), "ERROR").open();
			}
		}
	} catch (JavaModelException e) {
		LOGGER.error("Error occurred while loading class from jar {}", jarFileName, e);
	}
	loadClassesFromSettingsFolder();
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:21,代码来源:BuildExpressionEditorDataSturcture.java

示例4: ClassDetails

import org.eclipse.jdt.core.IClassFile; //导入依赖的package包/类
public ClassDetails(IClassFile classFile, String jarFileName, String packageName, boolean isUserDefined) {
	LOGGER.debug("Extracting methods from "+classFile.getElementName());

	try {
		this.javaDoc=getJavaDoc(classFile);	
		intialize(classFile,jarFileName,packageName, isUserDefined);
		for (IJavaElement iJavaElement : classFile.getChildren()) {
			if (iJavaElement instanceof IType) {
				IType iType = (IType) iJavaElement;
				for (IMethod iMethod : iType.getMethods()) {
					addMethodsToClass(iMethod);
				}
			}
		}
	} catch (JavaModelException e) {
		LOGGER.error("Error occurred while fetching methods from class"+cName);
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:19,代码来源:ClassDetails.java

示例5: intialize

import org.eclipse.jdt.core.IClassFile; //导入依赖的package包/类
private void intialize(IClassFile classFile, String jarFileName, String packageName, boolean isUserDefined) {
	this.cName = StringUtils.removeEndIgnoreCase(classFile.getElementName(), Constants.CLASS_EXTENSION);
	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.USER_DEFINED_SUFFIX;
		updateJavaDoc(jarFileName, packageName);
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:19,代码来源:ClassDetails.java

示例6: findSourceElement

import org.eclipse.jdt.core.IClassFile; //导入依赖的package包/类
/**
 * Given a source name info, search the associated source file or class file from the source container list.
 *
 * @param sourcePath
 *                  the target source name (e.g. com\microsoft\java\debug\xxx.java).
 * @param containers
 *                  the source container list.
 * @return the associated source file or class file.
 */
public static Object findSourceElement(String sourcePath, ISourceContainer[] containers) {
    if (containers == null) {
        return null;
    }
    for (ISourceContainer container : containers) {
        try {
            Object[] objects = container.findSourceElements(sourcePath);
            if (objects.length > 0 && (objects[0] instanceof IResource || objects[0] instanceof IClassFile)) {
                return objects[0];
            }
        } catch (CoreException e) {
            // do nothing.
        }
    }
    return null;
}
 
开发者ID:Microsoft,项目名称:java-debug,代码行数:26,代码来源:JdtUtils.java

示例7: findProject

import org.eclipse.jdt.core.IClassFile; //导入依赖的package包/类
/**
 * Given a stack frame, find the target project that the associated source file belongs to.
 *
 * @param stackFrame
 *                  the stack frame.
 * @param containers
 *                  the source container list.
 * @return the context project.
 */
public static IProject findProject(StackFrame stackFrame, ISourceContainer[] containers) {
    Location location = stackFrame.location();
    try {
        Object sourceElement = findSourceElement(location.sourcePath(), containers);
        if (sourceElement instanceof IResource) {
            return ((IResource) sourceElement).getProject();
        } else if (sourceElement instanceof IClassFile) {
            IJavaProject javaProject = ((IClassFile) sourceElement).getJavaProject();
            if (javaProject != null) {
                return javaProject.getProject();
            }
        }
    } catch (AbsentInformationException e) {
        // When the compiled .class file doesn't contain debug source information, return null.
    }
    return null;
}
 
开发者ID:Microsoft,项目名称:java-debug,代码行数:27,代码来源:JdtUtils.java

示例8: getSourceFileURI

import org.eclipse.jdt.core.IClassFile; //导入依赖的package包/类
@Override
public String getSourceFileURI(String fullyQualifiedName, String sourcePath) {
    if (sourcePath == null) {
        return null;
    }

    Object sourceElement = JdtUtils.findSourceElement(sourcePath, getSourceContainers());
    if (sourceElement instanceof IResource) {
        return getFileURI((IResource) sourceElement);
    } else if (sourceElement instanceof IClassFile) {
        try {
            IClassFile file = (IClassFile) sourceElement;
            if (file.getBuffer() != null) {
                return getFileURI(file);
            }
        } catch (JavaModelException e) {
            // do nothing.
        }
    }
    return null;
}
 
开发者ID:Microsoft,项目名称:java-debug,代码行数:22,代码来源:JdtSourceLookUpProvider.java

示例9: getContents

import org.eclipse.jdt.core.IClassFile; //导入依赖的package包/类
private String getContents(IClassFile cf) {
    String source = null;
    if (cf != null) {
        try {
            IBuffer buffer = cf.getBuffer();
            if (buffer != null) {
                source = buffer.getContents();
            }
        } catch (JavaModelException e) {
            logger.log(Level.SEVERE, String.format("Failed to parse the source contents of the class file: %s", e.toString()), e);
        }
        if (source == null) {
            source = "";
        }
    }
    return source;
}
 
开发者ID:Microsoft,项目名称:java-debug,代码行数:18,代码来源:JdtSourceLookUpProvider.java

示例10: resolveClassFile

import org.eclipse.jdt.core.IClassFile; //导入依赖的package包/类
private static IClassFile resolveClassFile(String uriString) {
    if (uriString == null || uriString.isEmpty()) {
        return null;
    }
    try {
        URI uri = new URI(uriString);
        if (uri != null && JDT_SCHEME.equals(uri.getScheme()) && "contents".equals(uri.getAuthority())) {
            String handleId = uri.getQuery();
            IJavaElement element = JavaCore.create(handleId);
            IClassFile cf = (IClassFile) element.getAncestor(IJavaElement.CLASS_FILE);
            return cf;
        }
    } catch (URISyntaxException e) {
        // ignore
    }
    return null;
}
 
开发者ID:Microsoft,项目名称:java-debug,代码行数:18,代码来源:JdtSourceLookUpProvider.java

示例11: testTraverse1

import org.eclipse.jdt.core.IClassFile; //导入依赖的package包/类
@Test
public void testTraverse1() throws Exception {
  final Set<String> expected = new HashSet<String>(
      Arrays.asList(EXPECTEDTYPES));
  TypeTraverser t = new TypeTraverser(root);
  t.process(new ITypeVisitor() {
    public void visit(IType type, String vmname) {
      assertTrue("Unexpected type: " + vmname, expected.remove(vmname));
    }

    public void visit(ICompilationUnit unit) throws JavaModelException {
    }

    public void visit(IClassFile classfile) throws JavaModelException {
    }
  }, MONITOR);
  assertTrue("Not all types processed: " + expected, expected.isEmpty());
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:19,代码来源:TypeTraverserTest.java

示例12: toLocation

import org.eclipse.jdt.core.IClassFile; //导入依赖的package包/类
/**
 * Creates a location for a given java element.
 * Element can be a {@link ICompilationUnit} or {@link IClassFile}
 *
 * @param element
 * @return location or null
 * @throws JavaModelException
 */
public static Location toLocation(IJavaElement element) throws JavaModelException{
	ICompilationUnit unit = (ICompilationUnit) element.getAncestor(IJavaElement.COMPILATION_UNIT);
	IClassFile cf = (IClassFile) element.getAncestor(IJavaElement.CLASS_FILE);
	if (unit == null && cf == null) {
		return null;
	}
	if (element instanceof ISourceReference) {
		ISourceRange nameRange = getNameRange(element);
		if (SourceRange.isAvailable(nameRange)) {
			if (cf == null) {
				return toLocation(unit, nameRange.getOffset(), nameRange.getLength());
			} else {
				return toLocation(cf, nameRange.getOffset(), nameRange.getLength());
			}
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:27,代码来源:JDTUtils.java

示例13: appendClassFileLabel

import org.eclipse.jdt.core.IClassFile; //导入依赖的package包/类
/**
 * Appends the label for a class file. Considers the CF_* flags.
 *
 * @param classFile the element to render
 * @param flags the rendering flags. Flags with names starting with 'CF_' are considered.
 */
public void appendClassFileLabel(IClassFile classFile, long flags) {
	if (getFlag(flags, JavaElementLabels.CF_QUALIFIED)) {
		IPackageFragment pack= (IPackageFragment) classFile.getParent();
		if (!pack.isDefaultPackage()) {
			appendPackageFragmentLabel(pack, (flags & QUALIFIER_FLAGS));
			fBuilder.append('.');
		}
	}
	fBuilder.append(classFile.getElementName());

	if (getFlag(flags, JavaElementLabels.CF_POST_QUALIFIED)) {
		fBuilder.append(JavaElementLabels.CONCAT_STRING);
		appendPackageFragmentLabel((IPackageFragment) classFile.getParent(), flags & QUALIFIER_FLAGS);
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:22,代码来源:JavaElementLabelComposer.java

示例14: getSource

import org.eclipse.jdt.core.IClassFile; //导入依赖的package包/类
@Override
public String getSource(IClassFile classFile, IProgressMonitor monitor) throws CoreException {
	String source = null;
	try {
		IBuffer buffer = classFile.getBuffer();
		if (buffer != null) {
			if (monitor.isCanceled()) {
				return null;
			}
			source = buffer.getContents();
			JavaLanguageServerPlugin.logInfo("ClassFile contents request completed");
		}
	} catch (JavaModelException e) {
		JavaLanguageServerPlugin.logException("Exception getting java element ", e);
	}
	return source;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:18,代码来源:SourceContentProvider.java

示例15: computeDefinitionNavigation

import org.eclipse.jdt.core.IClassFile; //导入依赖的package包/类
private Location computeDefinitionNavigation(ITypeRoot unit, int line, int column, IProgressMonitor monitor) {
	try {
		IJavaElement element = JDTUtils.findElementAtSelection(unit, line, column, this.preferenceManager, monitor);
		if (element == null) {
			return null;
		}
		ICompilationUnit compilationUnit = (ICompilationUnit) element.getAncestor(IJavaElement.COMPILATION_UNIT);
		IClassFile cf = (IClassFile) element.getAncestor(IJavaElement.CLASS_FILE);
		if (compilationUnit != null || (cf != null && cf.getSourceRange() != null)  ) {
			return JDTUtils.toLocation(element);
		}
		if (element instanceof IMember && ((IMember) element).getClassFile() != null) {
			return JDTUtils.toLocation(((IMember) element).getClassFile());
		}
	} catch (JavaModelException e) {
		JavaLanguageServerPlugin.logException("Problem computing definition for" +  unit.getElementName(), e);
	}
	return null;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:20,代码来源:NavigateToDefinitionHandler.java


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