use of org.absmodels.abs.plugin.util.InternalASTNode in project abstools by abstools.
the class NewModuleWizard method setInitialInput.
private void setInitialInput() {
if (firstSelection instanceof IFile) {
IFile file = (IFile) firstSelection;
if (file.getName().endsWith("." + Constants.ABS_FILE_EXTENSION)) {
page.setInitialFileResource(file);
}
} else if (firstSelection instanceof InternalASTNode<?>) {
InternalASTNode<?> node = (InternalASTNode<?>) firstSelection;
if (node.hasASTNodeOfType(ModuleDecl.class)) {
ModuleDecl m = (ModuleDecl) node.getASTNode();
page.setInitialValue(m.getName() + ".");
IFile file = UtilityFunctions.getFileOfModuleDecl(m);
page.setInitialFileResource(file);
}
} else if (firstSelection instanceof ModulePath) {
ModulePath mp = (ModulePath) firstSelection;
page.setInitialValue(mp.getModulePath() + ".");
InternalASTNode<ModuleDecl> moduleDecl = mp.getModuleDecl();
if (moduleDecl.hasASTNodeOfType(ModuleDecl.class)) {
IFile fileOfModuleDecl = UtilityFunctions.getFileOfModuleDecl(mp.getModuleDecl().getASTNode());
page.setInitialFileResource(fileOfModuleDecl);
}
}
}
use of org.absmodels.abs.plugin.util.InternalASTNode in project abstools by abstools.
the class UtilityFunctionsTest method testGetPathOfModuleDecl.
@Test
public void testGetPathOfModuleDecl() throws Exception {
ModuleDecl md = mock(ModuleDecl.class);
CompilationUnit cd = mock(CompilationUnit.class);
AbsNature nature = mock(AbsNature.class);
InternalASTNode<ModuleDecl> internalASTNode = new InternalASTNode<ModuleDecl>(md, nature);
when(cd.getFileName()).thenReturn("C:/test.abs");
when(md.getCompilationUnit()).thenReturn(cd);
IPath pathOfModuleDecl = getPathOfModuleDecl(internalASTNode);
assertEquals("C:/test.abs", pathOfModuleDecl.toString());
assertSame(getPathOfModuleDecl(null), null);
}
use of org.absmodels.abs.plugin.util.InternalASTNode in project abstools by abstools.
the class WizardUtilsTests method testGetProjectOfModuleDecl.
@Test
public void testGetProjectOfModuleDecl() {
AbsNature natureMock = mock(AbsNature.class);
IProject project = mock(IProject.class);
when(project.getName()).thenReturn("");
when(natureMock.getProject()).thenReturn(project);
ModuleDecl moduleMock = mock(ModuleDecl.class);
InternalASTNode<ModuleDecl> node = new InternalASTNode<ModuleDecl>(moduleMock, natureMock);
assertSame(node.getProject(), project);
}
use of org.absmodels.abs.plugin.util.InternalASTNode in project abstools by abstools.
the class ModuleDecorator method decorate.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public void decorate(Object element, IDecoration decoration) {
if (element instanceof InternalASTNode<?>) {
InternalASTNode<?> node = (InternalASTNode<?>) element;
if (node.hasASTNodeOfType(ModuleDecl.class)) {
checkModuleDecl(decoration, (InternalASTNode<ModuleDecl>) node);
}
} else if (element instanceof ModulePath) {
ModulePath m = (ModulePath) element;
checkModulePath(decoration, m);
} else if (element instanceof IProject) {
IProject project = (IProject) element;
checkProject(project, decoration);
}
}
use of org.absmodels.abs.plugin.util.InternalASTNode in project abstools by abstools.
the class OpenTypeHierarchyDelegate method getNodeUnderCursor.
InternalASTNode<?> getNodeUnderCursor(ABSEditor abseditor, TextSelection sel) {
InternalASTNode<CompilationUnit> cu = abseditor.getCompilationUnit();
if (cu == null) {
return null;
}
IDocument doc = abseditor.getDocumentProvider().getDocument(editor.getEditorInput());
synchronized (cu.getNature()) {
try {
ASTNode<?> node = UtilityFunctions.getASTNodeOfOffset(doc, cu.getASTNode(), sel.getOffset());
return new InternalASTNode(node, cu.getNature());
} catch (BadLocationException e) {
e.printStackTrace();
}
}
return null;
}
Aggregations