private static ILocationData createLocationData(ITraceURIConverter converter, ILocationInFileProvider locationProvider, EObject object, ILocationInFileProviderExtension.RegionDescription query, boolean skipEmpty) { ITextRegion textRegion = locationProvider instanceof ILocationInFileProviderExtension ? ((ILocationInFileProviderExtension) locationProvider).getTextRegion(object, query) : locationProvider.getFullTextRegion(object); if (!(textRegion instanceof ITextRegionWithLineInformation)) { if (log.isDebugEnabled()) log.debug("location provider returned text region without line information.", new Exception()); if (textRegion != null) textRegion = new TextRegionWithLineInformation(textRegion.getOffset(), textRegion.getLength(), 0, 0); else return null; } // usually we want to skip empty regions but if the root region is empty, we want to use it to store the path information along // with the empty offset / length pair if (skipEmpty && textRegion == ITextRegion.EMPTY_REGION) { return null; } ILocationData newData = createLocationData(converter, object, (ITextRegionWithLineInformation) textRegion); return newData; }
private void loadCycleInfo(final int offset, final int length, XtextEditor editor, final IDocument doc) { final ILocationInFileProvider locationInFileProvider = Z80Activator.getInstance().getInjector(Z80Activator.ORG_EFRY_Z80EDITOR_Z80).getInstance(ILocationInFileProvider.class); editor.getDocument().readOnly(new IUnitOfWork<Boolean, XtextResource>() { @Override public Boolean exec(XtextResource state) throws Exception { Z80OperationTypeWalker operationInstructions = new Z80OperationTypeWalker(state, locationInFileProvider, offset, offset + length); Z80CycleCalculator calc = new Z80CycleCalculator(); for (Operation o : operationInstructions) { ITextRegion region = locationInFileProvider.getFullTextRegion(o); calc.addOperation(o, doc.get(region.getOffset(), region.getLength())); } label.setText(calc.getHtmlFormattedText()); return Boolean.TRUE; } }); }
public TreeAppendable(ImportManager importManager, ITraceURIConverter converter, ILocationInFileProvider locationProvider, IJvmModelAssociations jvmModelAssociations, EObject source, String indentation, String lineSeparator) { this( new SharedAppendableState(indentation, lineSeparator, importManager, source.eResource()), converter, locationProvider, jvmModelAssociations, source); }
protected TreeAppendable(SharedAppendableState state, ITraceURIConverter converter, ILocationInFileProvider locationProvider, IJvmModelAssociations jvmModelAssociations, EObject source) { this( state, converter, locationProvider, jvmModelAssociations, createAllLocationData( converter, locationProvider, jvmModelAssociations, source, ILocationInFileProviderExtension.RegionDescription.INCLUDING_COMMENTS, false), // don't skip empty root regions false); }
protected TreeAppendable(SharedAppendableState state, final ITraceURIConverter converter, ILocationInFileProvider locationProvider, IJvmModelAssociations jvmModelAssociations, Set<ILocationData> sourceLocations, boolean useForDebugging) { this.state = state; this.traceURIConverter = converter; this.locationProvider = locationProvider; this.jvmModelAssociations = jvmModelAssociations; this.children = Lists.newArrayList(); this.locationData = sourceLocations; this.useForDebugging = useForDebugging; this.lightweightTypeReferenceSerializer = createLightweightTypeReferenceSerializer(); }
public ErrorTreeAppendable(SharedAppendableState state, ITraceURIConverter converter, ILocationInFileProvider locationProvider, IJvmModelAssociations jvmModelAssociations, Set<ILocationData> sourceLocations, boolean useForDebugging) { super(state, converter, locationProvider, jvmModelAssociations, sourceLocations, useForDebugging); encoder = getOrCreateURIEncoder(); }
public ITreeAppendable traceWithComments(final ITreeAppendable appendable, final EObject source) { ITreeAppendable _xifexpression = null; if ((appendable instanceof TreeAppendable)) { _xifexpression = ((TreeAppendable)appendable).trace(source, ILocationInFileProviderExtension.RegionDescription.INCLUDING_COMMENTS, false); } else { ITreeAppendable _xblockexpression = null; { ITextRegion _switchResult = null; final ILocationInFileProvider locationProvider = this.locationProvider; boolean _matched = false; if (locationProvider instanceof ILocationInFileProviderExtension) { _matched=true; _switchResult = ((ILocationInFileProviderExtension)this.locationProvider).getTextRegion(source, ILocationInFileProviderExtension.RegionDescription.INCLUDING_COMMENTS); } if (!_matched) { _switchResult = this.locationProvider.getFullTextRegion(source); } final ITextRegionWithLineInformation it = ((ITextRegionWithLineInformation) _switchResult); ITreeAppendable _xifexpression_1 = null; if (((it != null) && (it != ITextRegion.EMPTY_REGION))) { int _offset = it.getOffset(); int _length = it.getLength(); int _lineNumber = it.getLineNumber(); int _endLineNumber = it.getEndLineNumber(); LocationData _locationData = new LocationData(_offset, _length, _lineNumber, _endLineNumber, null); _xifexpression_1 = appendable.trace(_locationData); } else { _xifexpression_1 = appendable; } _xblockexpression = _xifexpression_1; } _xifexpression = _xblockexpression; } return _xifexpression; }
private void loadHtmlOpcodeInfo(final int offset, final int length, XtextEditor editor) { final ILocationInFileProvider locationInFileProvider = Z80Activator.getInstance().getInjector(Z80Activator.ORG_EFRY_Z80EDITOR_Z80).getInstance(ILocationInFileProvider.class); editor.getDocument().readOnly(new IUnitOfWork<Boolean, XtextResource>() { @Override public Boolean exec(XtextResource state) throws Exception { Z80OperationTypeWalker operationInstructions = new Z80OperationTypeWalker(state, locationInFileProvider, offset, offset + length); Iterator<Operation> itr = operationInstructions.iterator(); if (itr.hasNext()) { Operation o = itr.next(); InputStream in = this.getClass().getClassLoader().getResourceAsStream("resources/z80opCodes/" + o.getOpcode() + ".html"); if (in != null) { InputStreamReader r = new InputStreamReader(in); try { String desc = CharStreams.toString(r); r.close(); in.close(); label.setText("<h2>" + Z80OpCodes.valueOf(o).name() + ": " + Z80OpCodes.valueOf(o).getDescription() + "</h2>" + desc); } catch (IOException e) { throw new RuntimeException(e); } } } return Boolean.TRUE; } }); }
/** * Bind the {@link ILocationInFileProvider} that is aware of derived elements. */ public Class<? extends ILocationInFileProvider> bindILocationInFileProvider() { return N4JSLocationInFileProvider.class; }
public Class<? extends ILocationInFileProvider> bindILocationInFileProvider() { return JvmLocationInFileProvider.class; }
public Class<? extends ILocationInFileProvider> bindILocationInFileProvider() { return XbaseLocationInFileProvider.class; }
protected ILocationInFileProvider getLocationInFileProvider() { return locationInFileProvider; }
/** * @since 2.4 */ protected TreeAppendable createChild(SharedAppendableState state, ILocationInFileProvider locationProvider, IJvmModelAssociations jvmModelAssociations, Set<ILocationData> newData, boolean useForDebugging) { return new TreeAppendable(state, traceURIConverter, locationProvider, jvmModelAssociations, newData, useForDebugging); }
protected static ILocationData createLocationData(ITraceURIConverter converter, ILocationInFileProvider locationProvider, EObject object, ILocationInFileProviderExtension.RegionDescription query) { return createLocationData(converter, locationProvider, object, query, true); }
private static Set<ILocationData> createAllLocationData(ITraceURIConverter converter, ILocationInFileProvider locationProvider, IJvmModelAssociations jvmModelAssociations, EObject object, ILocationInFileProviderExtension.RegionDescription query) { return createAllLocationData(converter, locationProvider, jvmModelAssociations, object, query, true); }
@Override protected TreeAppendable createChild(SharedAppendableState state, ILocationInFileProvider locationProvider, IJvmModelAssociations jvmModelAssociations, Set<ILocationData> newData, boolean useForDebugging) { return this; }
@Override public Set<Binding> getGuiceBindingsRt(Grammar grammar) { if (!usesXbaseGrammar(grammar)) return emptySet(); BindFactory config = new BindFactory() // overrides binding from org.eclipse.xtext.generator.exporting.QualifiedNamesFragment .addTypeToType(IQualifiedNameProvider.class.getName(), "org.eclipse.xtext.xbase.scoping.XbaseQualifiedNameProvider"); if (useInferredJvmModel) { config = config .addTypeToType(ILocationInFileProvider.class.getName(), "org.eclipse.xtext.xbase.jvmmodel.JvmLocationInFileProvider") .addTypeToType(IGlobalScopeProvider.class.getName(), "org.eclipse.xtext.common.types.xtext.TypesAwareDefaultGlobalScopeProvider") .addTypeToType("org.eclipse.xtext.xbase.validation.FeatureNameValidator", "org.eclipse.xtext.xbase.validation.LogicalContainerAwareFeatureNameValidator") .addTypeToType("org.eclipse.xtext.xbase.typesystem.internal.DefaultBatchTypeResolver", "org.eclipse.xtext.xbase.typesystem.internal.LogicalContainerAwareBatchTypeResolver") .addTypeToType("org.eclipse.xtext.xbase.typesystem.internal.DefaultReentrantTypeResolver", "org.eclipse.xtext.xbase.typesystem.internal.LogicalContainerAwareReentrantTypeResolver") .addTypeToType(IResourceValidator.class.getCanonicalName(), "org.eclipse.xtext.xbase.annotations.validation.DerivedStateAwareResourceValidator"); if(generateXtendInferrer) { config = config .addTypeToType("org.eclipse.xtext.xbase.jvmmodel.IJvmModelInferrer", getJvmModelInferrerName(grammar, getNaming())); } } else { config = config .addTypeToType(ILocationInFileProvider.class.getName(), "org.eclipse.xtext.xbase.resource.XbaseLocationInFileProvider"); } if (usesXImportSection(grammar)) { config = config.addConfiguredBinding( IScopeProvider.class.getName() + "Delegate", "binder.bind(" + IScopeProvider.class.getName() + ".class).annotatedWith(com.google.inject.name.Names.named(" + AbstractDeclarativeScopeProvider.class.getName() + ".NAMED_DELEGATE)).to("+ getImportScopeProvider(grammar)+")"); } return config.getBindings(); }
public Class<? extends ILocationInFileProvider> bindILocationInFileProvider() { return DefaultLocationInFileProvider.class; }
@Override public Class<? extends ILocationInFileProvider> bindILocationInFileProvider() { return XtextLocationInFileProvider.class; }
protected void contributeRuntimeGuiceBindings() { final GuiceModuleAccess.BindingFactory bindingFactory = new GuiceModuleAccess.BindingFactory().addTypeToType(TypeReference.typeRef(IQualifiedNameProvider.class), TypeReference.typeRef("org.eclipse.xtext.xbase.scoping.XbaseQualifiedNameProvider")); boolean _usesXImportSection = this._xbaseUsageDetector.usesXImportSection(this.getGrammar()); boolean _not = (!_usesXImportSection); if (_not) { StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append("binder.bind("); _builder.append(Boolean.class); _builder.append(".TYPE)"); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.append(".annotatedWith("); _builder.append(Names.class, "\t"); _builder.append(".named("); TypeReference _typeReference = new TypeReference("org.eclipse.xtext.xbase.imports", "RewritableImportSection.Factory"); _builder.append(_typeReference, "\t"); _builder.append(".REWRITABLEIMPORTSECTION_ENABLEMENT))"); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.append(".toInstance("); _builder.append(Boolean.class, "\t"); _builder.append(".FALSE);"); _builder.newLineIfNotEmpty(); } }; bindingFactory.addConfiguredBinding("RewritableImportSectionEnablement", _client); } if (this.useInferredJvmModel) { bindingFactory.addTypeToType(TypeReference.typeRef(ILocationInFileProvider.class), TypeReference.typeRef("org.eclipse.xtext.xbase.jvmmodel.JvmLocationInFileProvider")).addTypeToType(TypeReference.typeRef(IGlobalScopeProvider.class), TypeReference.typeRef("org.eclipse.xtext.common.types.xtext.TypesAwareDefaultGlobalScopeProvider")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.xbase.validation.FeatureNameValidator"), TypeReference.typeRef("org.eclipse.xtext.xbase.validation.LogicalContainerAwareFeatureNameValidator")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.xbase.typesystem.internal.DefaultBatchTypeResolver"), TypeReference.typeRef("org.eclipse.xtext.xbase.typesystem.internal.LogicalContainerAwareBatchTypeResolver")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.xbase.typesystem.internal.DefaultReentrantTypeResolver"), TypeReference.typeRef("org.eclipse.xtext.xbase.typesystem.internal.LogicalContainerAwareReentrantTypeResolver")).addTypeToType(TypeReference.typeRef(IResourceValidator.class), TypeReference.typeRef("org.eclipse.xtext.xbase.annotations.validation.DerivedStateAwareResourceValidator")); if (this.generateXtendInferrer) { bindingFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.xbase.jvmmodel.IJvmModelInferrer"), this.getJvmModelInferrer()); } } else { bindingFactory.addTypeToType(TypeReference.typeRef(ILocationInFileProvider.class), TypeReference.typeRef("org.eclipse.xtext.xbase.resource.XbaseLocationInFileProvider")); } bindingFactory.contributeTo(this.getLanguage().getRuntimeGenModule()); boolean _inheritsXbaseWithAnnotations = this._xbaseUsageDetector.inheritsXbaseWithAnnotations(this.getLanguage().getGrammar()); if (_inheritsXbaseWithAnnotations) { GuiceModuleAccess _runtimeGenModule = this.getLanguage().getRuntimeGenModule(); _runtimeGenModule.setSuperClass(TypeReference.typeRef("org.eclipse.xtext.xbase.annotations.DefaultXbaseWithAnnotationsRuntimeModule")); } else { GuiceModuleAccess _runtimeGenModule_1 = this.getLanguage().getRuntimeGenModule(); _runtimeGenModule_1.setSuperClass(TypeReference.typeRef("org.eclipse.xtext.xbase.DefaultXbaseRuntimeModule")); } }
@Override public Class<? extends ILocationInFileProvider> bindILocationInFileProvider() { return ScopeLocationInFileProvider.class; }
@Override public Class<? extends ILocationInFileProvider> bindILocationInFileProvider() { return CheckLocationInFileProvider.class; }
public ILocationInFileProvider getLocationInFileProvider() { return locationInFileProvider; }
public Z80OperationTypeWalker(XtextResource resource, ILocationInFileProvider l, int startOffset, int endOffset) { this.resource = resource; this.locationInFileProvider = l; this.startOffset = startOffset; this.endOffset = endOffset; }
public OperationSelectionIterator(XtextResource resource, ILocationInFileProvider locationInFileProvider, int startOffset, int endOffset) { this.resource = resource; this.locationInFileProvider = locationInFileProvider; this.startOffset = startOffset; this.endOffset = endOffset; }
public Class<? extends ILocationInFileProvider> bindILocationInFileProvider() { return BTSLocationInFileProvider.class; }
/** * For testing. */ public DefaultOutlineTreeProvider(ILabelProvider labelProvider, ILocationInFileProvider locationInFileProvider) { this.labelProvider = labelProvider; this.locationInFileProvider = locationInFileProvider; }
@Deprecated public DefaultFoldingRegionProvider(ILocationInFileProvider locationInFileProvider) { this.locationInFileProvider = locationInFileProvider; this.tokenTypeToPartitionTypeMapperExtension = new TerminalsTokenTypeToPartitionMapper(); }
public void setLocationProvider(ILocationInFileProvider locationProvider) { this.locationProvider = locationProvider; }
public ILocationInFileProvider getLocationProvider() { return locationProvider; }
/** * Custom location in file provider used for revealing and highlighting a model element in the editor. * <p> * {@inheritDoc} */ @Override public Class<? extends ILocationInFileProvider> bindILocationInFileProvider() { return CheckCfgLocationInFileProvider.class; }