本文整理汇总了Java中org.eclipse.dltk.core.ISourceModule类的典型用法代码示例。如果您正苦于以下问题:Java ISourceModule类的具体用法?Java ISourceModule怎么用?Java ISourceModule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ISourceModule类属于org.eclipse.dltk.core包,在下文中一共展示了ISourceModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSourceModule
import org.eclipse.dltk.core.ISourceModule; //导入依赖的package包/类
private ISourceModule getSourceModule(String target, ISourceModule currentModule)
throws ModelException {
IPath elementPath;
if (target.startsWith("//")) { //$NON-NLS-1$
elementPath =
currentModule.getScriptProject().getPath().append(new Path(target.substring(2)));
} else {
if (target.isEmpty()) {
elementPath = currentModule.getPath();
} else {
elementPath = currentModule.getParent().getPath().append(new Path(target));
}
}
if (elementPath.segmentCount() > 1) {
IScriptProject scriptProject = currentModule.getScriptProject();
IScriptFolder folder = scriptProject.findScriptFolder(elementPath.removeLastSegments(1));
if (folder != null) {
return folder.getSourceModule(elementPath.lastSegment());
}
} else {
return currentModule;
}
return null;
}
示例2: createOverrideCompletionProposal
import org.eclipse.dltk.core.ISourceModule; //导入依赖的package包/类
@Override
protected ScriptCompletionProposal createOverrideCompletionProposal(IScriptProject scriptProject,
ISourceModule compilationUnit, String name, String[] paramTypes, int start, int length,
String label, String string) {
String replacementString = name + "()";
GnCompletionProposal proposal =
new GnCompletionProposal(replacementString, start, length, null, label,
RelevanceConstants.R_INTERESTING);
proposal.setCursorPosition(replacementString.length() - 1);
return proposal;
}
示例3: parseCode
import org.eclipse.dltk.core.ISourceModule; //导入依赖的package包/类
protected IModuleDeclaration parseCode(IModuleSource code) {
if (code instanceof ISourceModule) {
return parseSourceModule((ISourceModule) code);
} else {
return parseSourceCode(code);
}
}
示例4: select
import org.eclipse.dltk.core.ISourceModule; //导入依赖的package包/类
@Override
public IModelElement[] select(IModuleSource module, int selectionStart, int selectionEnd) {
selectionEnd += 1;
String target = null;
if (selectionStart != selectionEnd) {
String source = module.getSourceContents();
if (selectionStart >= source.length()) {
return null;
}
target = source.substring(selectionStart, selectionEnd);
return selectElement((ISourceModule) module.getModelElement(), target, selectionEnd);
} else {
IModuleDeclaration moduleDeclaration = new GnSourceParser().parse(module, null);
ASTNode node = AstUtil.findMinimalNode(
(ModuleDeclaration) moduleDeclaration, selectionStart, selectionEnd);
if (node instanceof GnArgument) {
node = ((GnArgument) node).getActualNode();
}
if (node instanceof StringLiteral) {
return selectGnFileOrAction(module, ((StringLiteral) node).getValue(), selectionEnd);
} else if (node instanceof VariableReference) {
target = ((VariableReference) node).getName();
} else if (node instanceof GnFieldDeclaration) {
target = ((GnFieldDeclaration) node).getName();
} else if (node instanceof MethodDeclaration) {
target = ((MethodDeclaration) node).getName();
}
}
return selectElement((ISourceModule) module.getModelElement(), target, selectionEnd);
}
示例5: selectElement
import org.eclipse.dltk.core.ISourceModule; //导入依赖的package包/类
private IModelElement[] selectElement(ISourceModule sourceModule, String target, int position) {
if (sourceModule == null) {
return null;
}
IModelElement candidate = target != null ? sourceModule.getMethod(target) : sourceModule;
try {
if (target != null && !candidate.exists()) {
IMethod currentFunction = findFunctionForPosition(sourceModule, position);
functionChainLoop:
while (currentFunction != null) {
for (IModelElement child : currentFunction.getChildren()) {
if (child.getElementType() != IModelElement.FIELD) {
continue;
}
IField field = (IField) child;
if (target.equals(field.getElementName())) {
candidate = field;
break functionChainLoop;
}
}
IModelElement parent = currentFunction.getParent();
if (parent != null && parent.getElementType() == IModelElement.METHOD) {
currentFunction = (IMethod) parent;
} else {
currentFunction = null;
}
}
if (!candidate.exists()) {
candidate = sourceModule.getField(target);
}
}
return candidate.exists() ? new IModelElement[] {candidate} : null;
} catch (ModelException e) {
GnCorePlugin.log(e);
return null;
}
}
示例6: selectGnFileOrAction
import org.eclipse.dltk.core.ISourceModule; //导入依赖的package包/类
private IModelElement[] selectGnFileOrAction(IModuleSource module, String target, int position) {
if (target == null) {
return null;
}
String action = null;
int colonIndex = target.lastIndexOf(':');
if (colonIndex != -1) {
action = target.substring(colonIndex + 1);
target = target.substring(0, colonIndex);
}
ISourceModule currentModule = (ISourceModule) module.getModelElement();
try {
IModelElement[] result = selectElement(currentModule, target, position);
if (result == null) {
ISourceModule sourceModule = getSourceModule(target, currentModule);
if (sourceModule != null) {
result = selectElement(sourceModule, action, position);
}
}
return result;
} catch (ModelException e) {
GnCorePlugin.log(e);
return null;
}
}
示例7: findFunctionForPosition
import org.eclipse.dltk.core.ISourceModule; //导入依赖的package包/类
private IMethod findFunctionForPosition(ISourceModule currentModule, int position)
throws ModelException {
IMethod[] methods = ((AbstractSourceModule) currentModule).getMethods();
for (IMethod method : methods) {
IMethod candidate = findFunctionForPosition(method, position);
if (candidate != null) {
return candidate;
}
}
return null;
}
示例8: createContext
import org.eclipse.dltk.core.ISourceModule; //导入依赖的package包/类
public ScriptTemplateContext createContext(IDocument document, int completionPosition,
int length, ISourceModule sourceModule) {
return new JuliaTemplateContext(this, document, completionPosition, length, sourceModule);
}
示例9: JuliaTemplateContext
import org.eclipse.dltk.core.ISourceModule; //导入依赖的package包/类
protected JuliaTemplateContext(TemplateContextType type, IDocument document,
int completionOffset, int completionLength, ISourceModule sourceModule) {
super(type, document, completionOffset, completionLength, sourceModule);
}
示例10: JuliaCompletionProposalCollector
import org.eclipse.dltk.core.ISourceModule; //导入依赖的package包/类
public JuliaCompletionProposalCollector(ISourceModule module) {
super(module);
}
示例11: createOverrideCompletionProposal
import org.eclipse.dltk.core.ISourceModule; //导入依赖的package包/类
protected ScriptCompletionProposal createOverrideCompletionProposal(IScriptProject scriptProject,
ISourceModule compilationUnit, String name, String[] paramTypes, int start, int length,
String displayName, String completionProposal) {
return new ScriptOverrideCompletionProposal(scriptProject, compilationUnit, name, paramTypes,
start, length, displayName, completionProposal);
}
示例12: GnCompletionProposalCollector
import org.eclipse.dltk.core.ISourceModule; //导入依赖的package包/类
public GnCompletionProposalCollector(ISourceModule sourceModule) {
super(sourceModule);
}
示例13: parseSourceModule
import org.eclipse.dltk.core.ISourceModule; //导入依赖的package包/类
private IModuleDeclaration parseSourceModule(final ISourceModule sourceModule) {
return SourceParserUtil.parse(sourceModule, null);
}
示例14: SilverStripeTemplateContext
import org.eclipse.dltk.core.ISourceModule; //导入依赖的package包/类
public SilverStripeTemplateContext(ScriptTemplateContextType phpTemplateContextType, IDocument document, int offset, int length, ISourceModule sourceModule) {
super(phpTemplateContextType, document, offset, length, sourceModule);
}
示例15: createContext
import org.eclipse.dltk.core.ISourceModule; //导入依赖的package包/类
@Override
public ScriptTemplateContext createContext(IDocument document, int offset, int length, ISourceModule sourceModule) {
return new SilverStripeTemplateContext(this, document, offset, length, sourceModule);
}