本文整理汇总了Java中org.spoofax.jsglr.client.imploder.ImploderAttachment类的典型用法代码示例。如果您正苦于以下问题:Java ImploderAttachment类的具体用法?Java ImploderAttachment怎么用?Java ImploderAttachment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImploderAttachment类属于org.spoofax.jsglr.client.imploder包,在下文中一共展示了ImploderAttachment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: fromStrategoTerm
import org.spoofax.jsglr.client.imploder.ImploderAttachment; //导入依赖的package包/类
public static INodeSource fromStrategoTerm(IStrategoTerm aterm) {
AbstractTermAttachment attachment = null;
ImploderAttachment imploderAttachment = null;
if (aterm.getAttachment(OriginAttachment.TYPE) != null) {
OriginAttachment originAttachment = aterm
.getAttachment(OriginAttachment.TYPE);
imploderAttachment = originAttachment.getOrigin().getAttachment(
ImploderAttachment.TYPE);
attachment = originAttachment;
} else if (aterm.getAttachment(ImploderAttachment.TYPE) != null) {
imploderAttachment = aterm.getAttachment(ImploderAttachment.TYPE);
attachment = imploderAttachment;
}
return imploderAttachment != null ? new NodeSource(imploderAttachment,
attachment) : null;
}
开发者ID:metaborg,项目名称:dynsem,代码行数:19,代码来源:NodeSource.java
示例2: create
import org.spoofax.jsglr.client.imploder.ImploderAttachment; //导入依赖的package包/类
public IndexEntry create(IStrategoTerm key, IStrategoTerm value, IStrategoTerm source) {
final ImploderAttachment origin = getImploderAttachment(value);
// TODO: what is the performance of attachment stripping operations?
key = stripper.strip(key);
value = stripper.strip(value);
if (origin != null) {
ImploderAttachment.putImploderAttachment(value, false,
origin.getSort(), origin.getLeftToken(),
origin.getRightToken(), origin.isBracket(), origin.isCompletion(), origin.isNestedCompletion(), origin.isSinglePlaceholderCompletion());
}
final IndexEntry entry = new IndexEntry(key, value, source, origin);
return entry;
}
开发者ID:metaborg,项目名称:mb-rep,代码行数:17,代码来源:IndexEntryFactory.java
示例3: getSorts
import org.spoofax.jsglr.client.imploder.ImploderAttachment; //导入依赖的package包/类
public static SortType[] getSorts(ISimpleTerm term) {
TypesmartSortAttachment attach = get(term);
if(attach != null) {
return attach.getSorts().ar;
} else {
ImploderAttachment imploderAttach = ImploderAttachment.get(term);
if(imploderAttach != null) {
if(imploderAttach.isSequenceAttachment()) {
return new SortType[] { new TList(new TSort(imploderAttach.getElementSort())) };
} else {
return new SortType[] { new TSort(imploderAttach.getSort()) };
}
} else {
IStrategoTerm origin = OriginAttachment.getOrigin(term);
if(origin != null) {
return getSorts(origin);
} else {
return null;
}
}
}
}
开发者ID:metaborg,项目名称:mb-rep,代码行数:23,代码来源:TypesmartSortAttachment.java
示例4: getResource
import org.spoofax.jsglr.client.imploder.ImploderAttachment; //导入依赖的package包/类
public static FileObject getResource(ISimpleTerm term, IResourceService resourceService) {
final SourceAttachment resource = ParentAttachment.getRoot(term).getAttachment(TYPE);
if(resource != null) {
return resource.resource;
}
while(!hasImploderOrigin(term) && term.getSubtermCount() > 0) {
term = term.getSubterm(0);
}
if(term.getAttachment(ImploderAttachment.TYPE) == null) {
term = getOrigin(term);
}
if(term == null || term.getAttachment(ImploderAttachment.TYPE) == null) {
return null;
}
final String fileName = ImploderAttachment.getFilename(term);
return resourceService.resolve(fileName);
}
开发者ID:metaborg,项目名称:spoofax,代码行数:21,代码来源:SourceAttachment.java
示例5: calculatePrefix
import org.spoofax.jsglr.client.imploder.ImploderAttachment; //导入依赖的package包/类
private String calculatePrefix(int cursorPosition, IStrategoTerm proposalTerm) {
String prefix = "";
ITokens tokenizer = proposalTerm.getAttachment(ImploderAttachment.TYPE).getLeftToken().getTokenizer();
IToken leftToken = proposalTerm.getAttachment(ImploderAttachment.TYPE).getLeftToken();
IToken rightToken = proposalTerm.getAttachment(ImploderAttachment.TYPE).getRightToken();
IToken current = leftToken;
int endOffsetPrefix = Integer.MIN_VALUE;
while(current.getEndOffset() < cursorPosition && current != rightToken) {
if(endOffsetPrefix < current.getEndOffset()) {
prefix += current.toString();
endOffsetPrefix = current.getEndOffset();
}
current = tokenizer.getTokenAt(current.getIndex() + 1);
}
return prefix;
}
开发者ID:metaborg,项目名称:spoofax,代码行数:19,代码来源:JSGLRCompletionService.java
示例6: calculateSuffix
import org.spoofax.jsglr.client.imploder.ImploderAttachment; //导入依赖的package包/类
private String calculateSuffix(int cursorPosition, IStrategoTerm proposalTerm) {
String suffix = "";
ITokens tokenizer = proposalTerm.getAttachment(ImploderAttachment.TYPE).getLeftToken().getTokenizer();
IToken leftToken = proposalTerm.getAttachment(ImploderAttachment.TYPE).getLeftToken();
IToken rightToken = proposalTerm.getAttachment(ImploderAttachment.TYPE).getRightToken();
IToken current = rightToken;
int startOffsetSuffix = Integer.MAX_VALUE;
while(current.getStartOffset() >= cursorPosition && current != leftToken) {
if(startOffsetSuffix > current.getStartOffset()) {
suffix = current.toString() + suffix;
startOffsetSuffix = current.getStartOffset();
}
current = tokenizer.getTokenAt(current.getIndex() - 1);
}
return suffix;
}
开发者ID:metaborg,项目名称:spoofax,代码行数:19,代码来源:JSGLRCompletionService.java
示例7: getPlaceholder
import org.spoofax.jsglr.client.imploder.ImploderAttachment; //导入依赖的package包/类
private @Nullable IStrategoAppl getPlaceholder(int position, final Iterable<IStrategoTerm> terms) {
for(IStrategoTerm term : terms) {
if(term instanceof IStrategoAppl) {
IToken left = ImploderAttachment.getLeftToken(term);
IToken right = ImploderAttachment.getRightToken(term);
final IStrategoAppl appl = (IStrategoAppl) term;
if(appl.getConstructor().getName().endsWith("-Plhdr") && position > left.getStartOffset()
&& position <= right.getEndOffset()) {
return appl;
}
}
}
return null;
}
开发者ID:metaborg,项目名称:spoofax,代码行数:17,代码来源:JSGLRCompletionService.java
示例8: getLists
import org.spoofax.jsglr.client.imploder.ImploderAttachment; //导入依赖的package包/类
private @Nullable Iterable<IStrategoList> getLists(final Iterable<IStrategoTerm> terms,
Map<IStrategoTerm, Boolean> leftRecursiveTerms, Map<IStrategoTerm, Boolean> rightRecursiveTerms) {
Collection<IStrategoList> lists = Lists.newLinkedList();
for(IStrategoTerm term : terms) {
if(term instanceof IStrategoList) {
final IStrategoList list = (IStrategoList) term;
lists.add(list);
} else {
IToken left = ImploderAttachment.getLeftToken(term);
IToken right = ImploderAttachment.getRightToken(term);
// if term is not nullable, nor a list nor left or right recursive stop the search
if(left.getStartOffset() <= right.getEndOffset()) {
boolean isLeftRecursive = leftRecursiveTerms.containsKey(term);
boolean isRightRecursive = rightRecursiveTerms.containsKey(term);
if(!isLeftRecursive && !isRightRecursive) {
break;
}
}
}
}
return lists;
}
开发者ID:metaborg,项目名称:spoofax,代码行数:25,代码来源:JSGLRCompletionService.java
示例9: getOptionals
import org.spoofax.jsglr.client.imploder.ImploderAttachment; //导入依赖的package包/类
private @Nullable Iterable<IStrategoTerm> getOptionals(final Iterable<IStrategoTerm> terms,
Map<IStrategoTerm, Boolean> leftRecursiveTerms, Map<IStrategoTerm, Boolean> rightRecursiveTerms) {
Collection<IStrategoTerm> optionals = Lists.newLinkedList();
for(IStrategoTerm term : terms) {
IToken left = ImploderAttachment.getLeftToken(term);
IToken right = ImploderAttachment.getRightToken(term);
if(!(term instanceof IStrategoList) && left.getStartOffset() > right.getEndOffset()) {
optionals.add(term);
} else if(term instanceof IStrategoList) {
continue;
// if term is not nullable, nor a list nor left or right recursive stop the search
} else {
boolean isLeftRecursive = leftRecursiveTerms.containsKey(term);
boolean isRightRecursive = rightRecursiveTerms.containsKey(term);
if(!isLeftRecursive && !isRightRecursive) {
break;
}
}
}
return optionals;
}
开发者ID:metaborg,项目名称:spoofax,代码行数:24,代码来源:JSGLRCompletionService.java
示例10: getRightRecursiveTerms
import org.spoofax.jsglr.client.imploder.ImploderAttachment; //导入依赖的package包/类
private Iterable<IStrategoTerm> getRightRecursiveTerms(int position, Iterable<IStrategoTerm> terms,
Map<IStrategoTerm, Boolean> rightRecursiveTerms) {
Collection<IStrategoTerm> rightRecursive = Lists.newLinkedList();
for(IStrategoTerm term : terms) {
boolean isRightRecursive = rightRecursiveTerms.containsKey(term);
IToken left = ImploderAttachment.getLeftToken(term);
IToken right = ImploderAttachment.getRightToken(term);
if(isRightRecursive && position <= left.getStartOffset()) {
rightRecursive.add(term);
} else if(term instanceof IStrategoList || left.getStartOffset() > right.getEndOffset()) {
continue;
} else {
break;
}
}
return rightRecursive;
}
开发者ID:metaborg,项目名称:spoofax,代码行数:22,代码来源:JSGLRCompletionService.java
示例11: getLeftRecursiveTerms
import org.spoofax.jsglr.client.imploder.ImploderAttachment; //导入依赖的package包/类
private Iterable<IStrategoTerm> getLeftRecursiveTerms(int position, Iterable<IStrategoTerm> terms,
Map<IStrategoTerm, Boolean> leftRecursiveTerms) {
Collection<IStrategoTerm> leftRecursive = Lists.newLinkedList();
for(IStrategoTerm term : terms) {
boolean isLeftRecursive = leftRecursiveTerms.containsKey(term);
IToken left = ImploderAttachment.getLeftToken(term);
IToken right = ImploderAttachment.getRightToken(term);
if(isLeftRecursive && position > right.getEndOffset()) {
leftRecursive.add(term);
} else if(term instanceof IStrategoList || left.getStartOffset() > right.getEndOffset()) {
continue;
} else {
break;
}
}
return leftRecursive;
}
开发者ID:metaborg,项目名称:spoofax,代码行数:21,代码来源:JSGLRCompletionService.java
示例12: findCompletionTerm
import org.spoofax.jsglr.client.imploder.ImploderAttachment; //导入依赖的package包/类
private Collection<IStrategoTerm> findCompletionTerm(StrategoTerm ast) {
final Collection<IStrategoTerm> completionTerms = Lists.newLinkedList();
final IStrategoTermVisitor visitor = new AStrategoTermVisitor() {
@Override public boolean visit(IStrategoTerm term) {
ImploderAttachment ia = term.getAttachment(ImploderAttachment.TYPE);
if(ia.isNestedCompletion()) {
return false;
}
if(ia.isCompletion()) {
completionTerms.add(term);
return false;
}
return true;
}
};
StrategoTermVisitee.topdown(visitor, ast);
return completionTerms;
}
开发者ID:metaborg,项目名称:spoofax,代码行数:23,代码来源:JSGLRCompletionService.java
示例13: findCompletionTermInsideNested
import org.spoofax.jsglr.client.imploder.ImploderAttachment; //导入依赖的package包/类
private Collection<IStrategoTerm> findCompletionTermInsideNested(final StrategoTerm ast) {
final Collection<IStrategoTerm> completionTerms = Lists.newLinkedList();
final IStrategoTermVisitor visitor = new AStrategoTermVisitor() {
@Override public boolean visit(IStrategoTerm term) {
ImploderAttachment ia = term.getAttachment(ImploderAttachment.TYPE);
if(ia.isNestedCompletion() && !term.equals(ast)) {
return false;
}
if(ia.isCompletion()) {
completionTerms.add(term);
return false;
}
return true;
}
};
StrategoTermVisitee.topdown(visitor, ast);
return completionTerms;
}
开发者ID:metaborg,项目名称:spoofax,代码行数:22,代码来源:JSGLRCompletionService.java
示例14: findNestedCompletionTerm
import org.spoofax.jsglr.client.imploder.ImploderAttachment; //导入依赖的package包/类
private Collection<IStrategoTerm> findNestedCompletionTerm(final StrategoTerm ast, final boolean excludeIdTerm) {
final Collection<IStrategoTerm> completionTerms = Lists.newLinkedList();
final IStrategoTermVisitor visitor = new AStrategoTermVisitor() {
@Override public boolean visit(IStrategoTerm term) {
ImploderAttachment ia = term.getAttachment(ImploderAttachment.TYPE);
if(excludeIdTerm && term.equals(ast)) {
return true;
}
if(ia.isNestedCompletion()) {
completionTerms.add(term);
return false;
}
return true;
}
};
StrategoTermVisitee.topdown(visitor, ast);
return completionTerms;
}
开发者ID:metaborg,项目名称:spoofax,代码行数:22,代码来源:JSGLRCompletionService.java
示例15: sortConsCategory
import org.spoofax.jsglr.client.imploder.ImploderAttachment; //导入依赖的package包/类
private ICategory sortConsCategory(StylerFacet facet, IStrategoTerm term) {
final ImploderAttachment imploderAttachment = ImploderAttachment.get(term);
final String sort = imploderAttachment.getSort();
if(sort == null) {
return null;
}
// LEGACY: for some reason, when using concrete syntax extensions, all sorts are appended with _sort.
final String massagedSort = sort.replace("_sort", "");
if(term.getTermType() == IStrategoTerm.APPL) {
final String cons = ((IStrategoAppl) term).getConstructor().getName();
if(facet.hasSortConsStyle(massagedSort, cons)) {
return new SortConsCategory(massagedSort, cons);
} else if(facet.hasConsStyle(cons)) {
return new ConsCategory(cons);
} else if(facet.hasSortStyle(massagedSort)) {
return new SortCategory(massagedSort);
}
return null;
}
if(facet.hasSortStyle(massagedSort)) {
return new SortCategory(massagedSort);
}
return null;
}
开发者ID:metaborg,项目名称:spoofax,代码行数:27,代码来源:CategorizerService.java
示例16: detectEditRegions
import org.spoofax.jsglr.client.imploder.ImploderAttachment; //导入依赖的package包/类
public void detectEditRegions(IStrategoTerm lastErr0AST, String erroneousInput) {
String correctInput = ImploderAttachment.getTokenizer(lastErr0AST).getInput();
ArrayList<Character> correctChars = asCharacterList(correctInput);
ArrayList<Character> erroneousChars = asCharacterList(erroneousInput);
LCS<Character> lcs = new LCS<Character>(new LCSCommand<Character>() {
public boolean isMatch(Character c1, Character c2) {
return c1.charValue() == c2.charValue();
}});
lcs.createLCSResultsOptimized(correctChars, erroneousChars);
System.out.println("LCS size: " + lcs.getLCSSize());
System.out.println(" deleted: " + lcs.getResultUnmatched1());
System.out.println("inserted: " + lcs.getResultUnmatched2());
System.out.println(" unmatched_correct: " + lcs.getUnMatchedIndices1());
System.out.println("unmatched_erroneous: " + lcs.getUnMatchedIndices2());
ArrayList<IStrategoTerm> affectedListTerms = getAffectedListTerms(lastErr0AST, lcs.getUnMatchedIndices1(), false);
System.out.println("affected list terms: " + affectedListTerms);
}
开发者ID:metaborg,项目名称:jsglr,代码行数:18,代码来源:tricky.base.java
示例17: call
import org.spoofax.jsglr.client.imploder.ImploderAttachment; //导入依赖的package包/类
@Override
public final boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars) {
final IStrategoTerm location = tvars[0];
if(!Tools.isTermTuple(location) && location.getSubtermCount() != 4)
return false;
final String filename = Tools.asJavaString(location.getSubterm(0));
final int line = Tools.asJavaInt(location.getSubterm(1));
final int column = Tools.asJavaInt(location.getSubterm(2));
final int startOffset = Tools.asJavaInt(location.getSubterm(3));
final int endOffset = Tools.asJavaInt(location.getSubterm(4));
final ImploderAttachment attachment =
ImploderAttachment.createCompactPositionAttachment(filename, line, column, startOffset, endOffset);
env.current().putAttachment(attachment);
return true;
}
开发者ID:metaborg,项目名称:jsglr,代码行数:19,代码来源:OriginSetLocationOffsetPrimitive.java
示例18: preceedingSibEndLine
import org.spoofax.jsglr.client.imploder.ImploderAttachment; //导入依赖的package包/类
private int preceedingSibEndLine() {
if(isFirstListElement())
return -1;
if(listParent == null)
return -1;
int indexPreceedingSib = -1;
if(node instanceof StrategoSubList){
indexPreceedingSib = ((StrategoSubList)node).getIndexStart() - 1;
assert(listParent == ((StrategoSubList)node).getCompleteList());
}
else{
for (int i = 1; i < listParent.getSubtermCount(); i++) {
if(listParent.getSubterm(i)==node)
indexPreceedingSib = i-1;
}
}
if(indexPreceedingSib == -1)
return -1;
assert(indexPreceedingSib >= 0 && indexPreceedingSib < listParent.getSubtermCount());
ISimpleTerm preceedingNode = listParent.getSubterm(indexPreceedingSib);
if(!ImploderAttachment.hasImploderOrigin(preceedingNode))
return -1;
return getRightToken(preceedingNode).getEndLine();
}
开发者ID:metaborg,项目名称:jsglr,代码行数:25,代码来源:LayoutStructure.java
示例19: getCategory
import org.spoofax.jsglr.client.imploder.ImploderAttachment; //导入依赖的package包/类
@Nullable
private ICategory getCategory(final IStrategoTerm term) {
final ImploderAttachment rootImploderAttachment = ImploderAttachment.get(term);
final IToken token = rootImploderAttachment.getLeftToken();
final ISourceRegion region = JSGLRSourceRegionFactory.fromToken(token);
for (final IRegionCategory<IStrategoTerm> category : this.categories) {
if ((category.fragment() != null && category.fragment().equals(term)) || category.region().equals(region)) {
return category.category();
}
}
return null;
}
开发者ID:metaborg,项目名称:spoofax-intellij,代码行数:13,代码来源:ATermAstElementTypeProvider.java
示例20: NodeSource
import org.spoofax.jsglr.client.imploder.ImploderAttachment; //导入依赖的package包/类
private NodeSource(ImploderAttachment imploderAttachment,
AbstractTermAttachment attachment) {
final IToken leftToken = imploderAttachment.getLeftToken();
final IToken rightToken = imploderAttachment.getRightToken();
line = leftToken.getLine() + 1;
column = leftToken.getColumn() + 1;
fragment = leftToken.getTokenizer().toString(leftToken, rightToken);
filename = leftToken.getTokenizer().getFilename();
this.attachment = attachment;
}
开发者ID:metaborg,项目名称:dynsem,代码行数:11,代码来源:NodeSource.java
注:本文中的org.spoofax.jsglr.client.imploder.ImploderAttachment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论